mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-28 06:04:25 +00:00
Compare commits
2 Commits
users/saks
...
copilot/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
131ffe643a | ||
|
|
9b2fb0c04e |
@@ -16,7 +16,7 @@ import {
|
|||||||
import { useIndexingPolicyStore } from "Explorer/Tabs/QueryTab/ResultsView";
|
import { useIndexingPolicyStore } from "Explorer/Tabs/QueryTab/ResultsView";
|
||||||
import { useDatabases } from "Explorer/useDatabases";
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
import { isFabricNative } from "Platform/Fabric/FabricUtil";
|
import { isFabricNative } from "Platform/Fabric/FabricUtil";
|
||||||
import { isCapabilityEnabled, isVectorSearchEnabled } from "Utils/CapabilityUtils";
|
import { isVectorSearchEnabled } from "Utils/CapabilityUtils";
|
||||||
import { isRunningOnPublicCloud } from "Utils/CloudUtils";
|
import { isRunningOnPublicCloud } from "Utils/CloudUtils";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import DiscardIcon from "../../../../images/discard.svg";
|
import DiscardIcon from "../../../../images/discard.svg";
|
||||||
@@ -70,6 +70,7 @@ import {
|
|||||||
getMongoNotification,
|
getMongoNotification,
|
||||||
getTabTitle,
|
getTabTitle,
|
||||||
hasDatabaseSharedThroughput,
|
hasDatabaseSharedThroughput,
|
||||||
|
isDataMaskingEnabled,
|
||||||
isDirty,
|
isDirty,
|
||||||
parseConflictResolutionMode,
|
parseConflictResolutionMode,
|
||||||
parseConflictResolutionProcedure,
|
parseConflictResolutionProcedure,
|
||||||
@@ -1073,8 +1074,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
|
|
||||||
newCollection.fullTextPolicy = this.state.fullTextPolicy;
|
newCollection.fullTextPolicy = this.state.fullTextPolicy;
|
||||||
|
|
||||||
// Only send data masking policy if it was modified (dirty)
|
// Only send data masking policy if it was modified (dirty) and data masking is enabled
|
||||||
if (this.state.isDataMaskingDirty && isCapabilityEnabled(Constants.CapabilityNames.EnableDynamicDataMasking)) {
|
if (this.state.isDataMaskingDirty && isDataMaskingEnabled(this.collection.dataMaskingPolicy?.())) {
|
||||||
newCollection.dataMaskingPolicy = this.state.dataMaskingContent;
|
newCollection.dataMaskingPolicy = this.state.dataMaskingContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1463,15 +1464,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if DDM should be enabled
|
if (isDataMaskingEnabled(this.collection.dataMaskingPolicy?.())) {
|
||||||
const shouldEnableDDM = (): boolean => {
|
|
||||||
const hasDataMaskingCapability = isCapabilityEnabled(Constants.CapabilityNames.EnableDynamicDataMasking);
|
|
||||||
const isSqlAccount = userContext.apiType === "SQL";
|
|
||||||
|
|
||||||
return isSqlAccount && hasDataMaskingCapability; // Only show for SQL accounts with DDM capability
|
|
||||||
};
|
|
||||||
|
|
||||||
if (shouldEnableDDM()) {
|
|
||||||
const dataMaskingComponentProps: DataMaskingComponentProps = {
|
const dataMaskingComponentProps: DataMaskingComponentProps = {
|
||||||
shouldDiscardDataMasking: this.state.shouldDiscardDataMasking,
|
shouldDiscardDataMasking: this.state.shouldDiscardDataMasking,
|
||||||
resetShouldDiscardDataMasking: this.resetShouldDiscardDataMasking,
|
resetShouldDiscardDataMasking: this.resetShouldDiscardDataMasking,
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
||||||
import * as monaco from "monaco-editor";
|
import * as monaco from "monaco-editor";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as Constants from "../../../../Common/Constants";
|
|
||||||
import * as DataModels from "../../../../Contracts/DataModels";
|
import * as DataModels from "../../../../Contracts/DataModels";
|
||||||
import { isCapabilityEnabled } from "../../../../Utils/CapabilityUtils";
|
|
||||||
import { loadMonaco } from "../../../LazyMonaco";
|
import { loadMonaco } from "../../../LazyMonaco";
|
||||||
import { titleAndInputStackProps, unsavedEditorWarningMessage } from "../SettingsRenderUtils";
|
import { titleAndInputStackProps, unsavedEditorWarningMessage } from "../SettingsRenderUtils";
|
||||||
import { isDirty as isContentDirty } from "../SettingsUtils";
|
import { isDataMaskingEnabled, isDirty as isContentDirty } from "../SettingsUtils";
|
||||||
|
|
||||||
export interface DataMaskingComponentProps {
|
export interface DataMaskingComponentProps {
|
||||||
shouldDiscardDataMasking: boolean;
|
shouldDiscardDataMasking: boolean;
|
||||||
@@ -140,7 +138,7 @@ export class DataMaskingComponent extends React.Component<DataMaskingComponentPr
|
|||||||
};
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
if (!isCapabilityEnabled(Constants.CapabilityNames.EnableDynamicDataMasking)) {
|
if (!isDataMaskingEnabled(this.props.dataMaskingContent)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import * as Constants from "../../../Common/Constants";
|
|||||||
import * as DataModels from "../../../Contracts/DataModels";
|
import * as DataModels from "../../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { isFabricNative } from "../../../Platform/Fabric/FabricUtil";
|
import { isFabricNative } from "../../../Platform/Fabric/FabricUtil";
|
||||||
|
import { userContext } from "../../../UserContext";
|
||||||
|
import { isCapabilityEnabled } from "../../../Utils/CapabilityUtils";
|
||||||
import { MongoIndex } from "../../../Utils/arm/generatedClients/cosmos/types";
|
import { MongoIndex } from "../../../Utils/arm/generatedClients/cosmos/types";
|
||||||
|
|
||||||
const zeroValue = 0;
|
const zeroValue = 0;
|
||||||
@@ -88,6 +90,19 @@ export const hasDatabaseSharedThroughput = (collection: ViewModels.Collection):
|
|||||||
return database?.isDatabaseShared() && !collection.offer();
|
return database?.isDatabaseShared() && !collection.offer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isDataMaskingEnabled = (dataMaskingPolicy?: DataModels.DataMaskingPolicy): boolean => {
|
||||||
|
const isSqlAccount = userContext.apiType === "SQL";
|
||||||
|
if (!isSqlAccount) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasDataMaskingCapability = isCapabilityEnabled(Constants.CapabilityNames.EnableDynamicDataMasking);
|
||||||
|
const hasDataMaskingPolicyFromCollection =
|
||||||
|
dataMaskingPolicy?.includedPaths?.length > 0 || dataMaskingPolicy?.excludedPaths?.length > 0;
|
||||||
|
|
||||||
|
return hasDataMaskingCapability || hasDataMaskingPolicyFromCollection;
|
||||||
|
};
|
||||||
|
|
||||||
export const parseConflictResolutionMode = (modeFromBackend: string): DataModels.ConflictResolutionMode => {
|
export const parseConflictResolutionMode = (modeFromBackend: string): DataModels.ConflictResolutionMode => {
|
||||||
// Backend can contain different casing as it does case-insensitive comparisson
|
// Backend can contain different casing as it does case-insensitive comparisson
|
||||||
if (!modeFromBackend) {
|
if (!modeFromBackend) {
|
||||||
|
|||||||
@@ -604,6 +604,60 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</PivotItem>
|
</PivotItem>
|
||||||
|
<PivotItem
|
||||||
|
headerButtonProps={
|
||||||
|
{
|
||||||
|
"data-test": "settings-tab-header/DataMaskingTab",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headerText="Masking Policy (preview)"
|
||||||
|
itemKey="DataMaskingTab"
|
||||||
|
key="DataMaskingTab"
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"backgroundColor": "var(--colorNeutralBackground1)",
|
||||||
|
"color": "var(--colorNeutralForeground1)",
|
||||||
|
"marginTop": 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
styles={
|
||||||
|
{
|
||||||
|
"root": {
|
||||||
|
"backgroundColor": "var(--colorNeutralBackground1)",
|
||||||
|
"color": "var(--colorNeutralForeground1)",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<DataMaskingComponent
|
||||||
|
dataMaskingContent={
|
||||||
|
{
|
||||||
|
"excludedPaths": [
|
||||||
|
"/excludedPath",
|
||||||
|
],
|
||||||
|
"includedPaths": [],
|
||||||
|
"isPolicyEnabled": true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataMaskingContentBaseline={
|
||||||
|
{
|
||||||
|
"excludedPaths": [
|
||||||
|
"/excludedPath",
|
||||||
|
],
|
||||||
|
"includedPaths": [],
|
||||||
|
"isPolicyEnabled": true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onDataMaskingContentChange={[Function]}
|
||||||
|
onDataMaskingDirtyChange={[Function]}
|
||||||
|
resetShouldDiscardDataMasking={[Function]}
|
||||||
|
shouldDiscardDataMasking={false}
|
||||||
|
validationErrors={[]}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</PivotItem>
|
||||||
<PivotItem
|
<PivotItem
|
||||||
headerButtonProps={
|
headerButtonProps={
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user