Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update global masking rules (#7950)

ecmadaoad90eebbd648
diff --git a/frontend/src/components/SensitiveData/DataFeatureView.vue b/frontend/src/components/SensitiveData/DataFeatureView.vue
new file mode 100644
index 0000000000..5f35d90339
--- /dev/null
+++ b/frontend/src/components/SensitiveData/DataFeatureView.vue
@@ -0,0 +1,4 @@
+<template>
+ <div class="w-full mt-4 space-y-4"></div>
+</template>
+<script lang="ts" setup></script>
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRule.vue b/frontend/src/components/SensitiveData/GlobalMaskingRule.vue
deleted file mode 100644
index ea18bb5c9a..0000000000
--- a/frontend/src/components/SensitiveData/GlobalMaskingRule.vue
+++ /dev/null
@@ -1,213 +0,0 @@
-<template>
- <div class="w-full mt-4 space-y-4">
- <div class="flex items-center justify-between">
- <!-- Filter -->
- <div class="flex items-center gap-x-3">
- <div class="textlabel">
- {{ $t("settings.sensitive-data.masking-level.self") }}
- </div>
- <label
- v-for="item in levelFilterItemList"
- :key="item.value"
- class="flex items-center gap-x-2 text-sm text-gray-600"
- >
- <NCheckbox
- :checked="state.checkedLevel.has(item.value)"
- @update:checked="toggleCheckLevel(item.value, $event)"
- >
- <BBBadge
- class="whitespace-nowrap"
- :text="item.label"
- :can-remove="false"
- :badge-style="item.style"
- size="small"
- />
- </NCheckbox>
- </label>
- </div>
- <NButton
- type="primary"
- :disabled="!hasPermission || !hasSensitiveDataFeature"
- @click="addNewRule"
- >
- {{ $t("settings.sensitive-data.add-rule") }}
- </NButton>
- </div>
- <div class="space-y-5 divide-y-2 pb-10 divide-gray-100">
- <div
- v-if="filteredRuleList.length === 0"
- class="border-4 border-dashed border-gray-200 rounded-lg h-96 flex justify-center items-center"
- >
- <div class="text-center flex flex-col justify-center items-center">
- <img src="../../assets/illustration/no-data.webp" class="w-52" />
- </div>
- </div>
- <MaskingRuleConfig
- v-for="item in filteredRuleList"
- :key="item.rule.id"
- :readonly="!hasPermission"
- :masking-rule="item.rule"
- :is-create="item.mode === 'CREATE'"
- @cancel="onCancel(item.rule.id, item.mode)"
- @confirm="(rule: MaskingRulePolicy_MaskingRule) => onConfirm(rule)"
- />
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NCheckbox } from "naive-ui";
-import { v4 as uuidv4 } from "uuid";
-import { computed, reactive, nextTick, watchEffect } from "vue";
-import { useI18n } from "vue-i18n";
-import BBBadge, { type BBBadgeStyle } from "@/bbkit/BBBadge.vue";
-import { featureToRef, pushNotification, useCurrentUserV1 } from "@/store";
-import { usePolicyListByResourceTypeAndPolicyType } from "@/store/modules/v1/policy";
-import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";
-import {
- PolicyType,
- MaskingRulePolicy_MaskingRule,
- PolicyResourceType,
-} from "@/types/proto/v1/org_policy_service";
-import { hasWorkspacePermissionV1 } from "@/utils";
-
-type MaskingRuleMode = "CREATE" | "EDIT";
-
-type LevelFilterItem = {
- value: number;
- label: string;
- style: BBBadgeStyle;
-};
-
-interface MaskingRuleItem {
- mode: MaskingRuleMode;
- rule: MaskingRulePolicy_MaskingRule;
-}
-
-interface LocalState {
- checkedLevel: Set<MaskingLevel>;
- maskingRuleItemList: MaskingRuleItem[];
-}
-
-const { t } = useI18n();
-const state = reactive<LocalState>({
- checkedLevel: new Set<MaskingLevel>(),
- maskingRuleItemList: [],
-});
-
-const currentUserV1 = useCurrentUserV1();
-const hasPermission = computed(() => {
- return hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-sensitive-data",
- currentUserV1.value.userRole
- );
-});
-const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
-
-watchEffect(() => {
- const policyList = usePolicyListByResourceTypeAndPolicyType({
- resourceType: PolicyResourceType.WORKSPACE,
- policyType: PolicyType.MASKING_RULE,
- showDeleted: false,
- });
- if (policyList.value.length !== 1) {
- return;
- }
-
- const policy = policyList.value[0].maskingRulePolicy;
- state.maskingRuleItemList = (policy?.rules ?? []).map((rule) => {
- return {
- mode: "EDIT",
- rule,
- };
- });
-});
-
-const levelFilterItemList = computed(() => {
- return [
- MaskingLevel.FULL,
- MaskingLevel.PARTIAL,
- MaskingLevel.NONE,
- ].map<LevelFilterItem>((level) => {
- return {
- value: level,
- label: t(
- `settings.sensitive-data.masking-level.${maskingLevelToJSON(
- level
- ).toLowerCase()}`
- ),
- style:
- level === MaskingLevel.FULL
- ? "CRITICAL"
- : level === MaskingLevel.PARTIAL
- ? "WARN"
- : level === MaskingLevel.NONE
- ? "INFO"
- : "DISABLED",
- };
- });
-});
-
-const filteredRuleList = computed(() => {
- return state.maskingRuleItemList.filter((item) => {
- return (
- state.checkedLevel.size === 0 ||
- state.checkedLevel.has(item.rule.maskingLevel)
- );
- });
-});
-
-const toggleCheckLevel = (level: number, checked: boolean) => {
- if (checked) state.checkedLevel.add(level);
- else state.checkedLevel.delete(level);
-};
-
-const addNewRule = () => {
- state.maskingRuleItemList.push({
- mode: "CREATE",
- rule: MaskingRulePolicy_MaskingRule.fromJSON({
- id: uuidv4(),
- maskingLevel: MaskingLevel.FULL,
- }),
- });
- nextTick(() => {
- const elem = document.querySelector("#bb-layout-main");
- elem?.scrollTo(
- 0,
- document.body.scrollHeight || document.documentElement.scrollHeight
- );
- });
-};
-
-const onCancel = (id: string, mode: MaskingRuleMode) => {
- if (mode !== "CREATE") {
- return;
- }
- const index = state.maskingRuleItemList.findIndex(
- (item) => item.rule.id === id
- );
- if (index < 0) {
- return;
- }
- state.maskingRuleItemList.splice(index, 1);
-};
-
-const onConfirm = (rule: MaskingRulePolicy_MaskingRule) => {
- const index = state.maskingRuleItemList.findIndex(
- (item) => item.rule.id === rule.id
- );
- if (index < 0) {
- return;
- }
- state.maskingRuleItemList[index] = {
- mode: "EDIT",
- rule,
- };
- // TODO(ed): call backend api
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-};
-</script>
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
new file mode 100644
index 0000000000..5d2d8a6ad0
--- /dev/null
+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
@@ -0,0 +1,370 @@
+<template>
+ <div class="w-full mt-4 space-y-4">
+ <div class="flex items-center justify-between">
+ <!-- Filter -->
+ <div class="flex items-center gap-x-3">
+ <div class="textlabel">
+ {{ $t("settings.sensitive-data.masking-level.self") }}
+ </div>
+ <label
+ v-for="item in levelFilterItemList"
+ :key="item.value"
+ class="flex items-center gap-x-2 text-sm text-gray-600"
+ >
+ <NCheckbox
+ :checked="state.checkedLevel.has(item.value)"
+ @update:checked="toggleCheckLevel(item.value, $event)"
+ >
+ <BBBadge
+ class="whitespace-nowrap"
+ :text="item.label"
+ :can-remove="false"
+ :badge-style="item.style"
+ size="small"
+ />
+ </NCheckbox>
+ </label>
+ </div>
+ <div v-if="state.reorderRules" class="flex items-center space-x-3">
+ <NButton
+ :disabled="state.processing"
+ @click="
+ () => {
+ state.reorderRules = false;
+ updateList();
+ }
+ "
+ >
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="state.processing"
+ @click="onReorderSubmit"
+ >
+ {{ $t("common.confirm") }}
+ </NButton>
+ </div>
+ <div v-else class="flex items-center space-x-3">
+ <NButton
+ secondary
+ type="primary"
+ :disabled="
+ !hasPermission ||
+ !hasSensitiveDataFeature ||
+ state.maskingRuleItemList.length <= 1
+ "
+ @click="
+ () => {
+ state.checkedLevel.clear();
+ state.reorderRules = true;
+ }
+ "
+ >
+ {{ $t("settings.sensitive-data.global-rules.re-order") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!hasPermission || !hasSensitiveDataFeature"
+ @click="addNewRule"
+ >
+ {{ $t("settings.sensitive-data.global-rules.add-rule") }}
+ </NButton>
+ </div>
+ </div>
+ <div class="space-y-5 divide-y-2 pb-10 divide-gray-100">
+ <div
+ v-if="filteredRuleList.length === 0"
+ class="border-4 border-dashed border-gray-200 rounded-lg h-96 flex justify-center items-center"
+ >
+ <div class="text-center flex flex-col justify-center items-center">
+ <img src="../../assets/illustration/no-data.webp" class="w-52" />
+ </div>
+ </div>
+ <div
+ v-for="(item, index) in filteredRuleList"
+ :key="item.rule.id"
+ class="flex items-start space-x-5"
+ >
+ <div v-if="state.reorderRules" class="mt-4">
+ <button @click="onReorder(item, -1)">
+ <heroicons-solid:arrow-circle-up
+ v-if="index !== 0"
+ class="w-6 h-6"
+ />
+ </button>
+ <button @click="onReorder(item, 1)">
+ <heroicons-solid:arrow-circle-down
+ v-if="index !== filteredRuleList.length - 1"
+ class="w-6 h-6"
+ />
+ </button>
+ </div>
+ <NPopconfirm v-else @positive-click="onRuleDelete(item)">
+ <template #trigger>
+ <button
+ class="mt-4 w-5 h-5 p-0.5 hover:bg-gray-300 rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"
+ @click.stop=""
+ >
+ <heroicons-outline:trash class="w-4 h-4" />
+ </button>
+ </template>
+ <div class="whitespace-nowrap">
+ {{ $t("settings.sensitive-data.global-rules.delete-rule-tip") }}
+ </div>
+ </NPopconfirm>
+ <MaskingRuleConfig
+ :readonly="!hasPermission || state.reorderRules"
+ :disabled="state.processing"
+ :masking-rule="item.rule"
+ :is-create="item.mode === 'CREATE'"
+ @cancel="onCancel(item.rule.id, item.mode)"
+ @confirm="(rule: MaskingRulePolicy_MaskingRule) => onConfirm(rule)"
+ />
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { NCheckbox, NPopconfirm } from "naive-ui";
+import { v4 as uuidv4 } from "uuid";
+import { computed, reactive, nextTick, onMounted } from "vue";
+import { useI18n } from "vue-i18n";
+import BBBadge, { type BBBadgeStyle } from "@/bbkit/BBBadge.vue";
+import {
+ featureToRef,
+ pushNotification,
+ useCurrentUserV1,
+ usePolicyV1Store,
+} from "@/store";
+import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";
+import {
+ Policy,
+ PolicyType,
+ PolicyResourceType,
+ MaskingRulePolicy_MaskingRule,
+} from "@/types/proto/v1/org_policy_service";
+import { arraySwap, hasWorkspacePermissionV1 } from "@/utils";
+
+type MaskingRuleMode = "CREATE" | "EDIT";
+
+type LevelFilterItem = {
+ value: number;
+ label: string;
+ style: BBBadgeStyle;
+};
+
+interface MaskingRuleItem {
+ mode: MaskingRuleMode;
+ rule: MaskingRulePolicy_MaskingRule;
+}
+
+interface LocalState {
+ checkedLevel: Set<MaskingLevel>;
+ maskingRuleItemList: MaskingRuleItem[];
+ processing: boolean;
+ reorderRules: boolean;
+}
+
+const { t } = useI18n();
+const state = reactive<LocalState>({
+ checkedLevel: new Set<MaskingLevel>(),
+ maskingRuleItemList: [],
+ processing: false,
+ reorderRules: false,
+});
+
+const policyStore = usePolicyV1Store();
+const currentUserV1 = useCurrentUserV1();
+const hasPermission = computed(() => {
+ return hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-sensitive-data",
+ currentUserV1.value.userRole
+ );
+});
+const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
+
+const updateList = async () => {
+ const policy = await policyStore.getOrFetchPolicyByParentAndType({
+ parentPath: "",
+ policyType: PolicyType.MASKING_RULE,
+ });
+ if (!policy) {
+ return;
+ }
+
+ state.maskingRuleItemList = (policy.maskingRulePolicy?.rules ?? []).map(
+ (rule) => {
+ return {
+ mode: "EDIT",
+ rule,
+ };
+ }
+ );
+};
+
+onMounted(async () => {
+ await updateList();
+});
+
+const levelFilterItemList = computed(() => {
+ return [
+ MaskingLevel.FULL,
+ MaskingLevel.PARTIAL,
+ MaskingLevel.NONE,
+ ].map<LevelFilterItem>((level) => {
+ return {
+ value: level,
+ label: t(
+ `settings.sensitive-data.masking-level.${maskingLevelToJSON(
+ level
+ ).toLowerCase()}`
+ ),
+ style:
+ level === MaskingLevel.FULL
+ ? "CRITICAL"
+ : level === MaskingLevel.PARTIAL
+ ? "WARN"
+ : level === MaskingLevel.NONE
+ ? "INFO"
+ : "DISABLED",
+ };
+ });
+});
+
+const filteredRuleList = computed(() => {
+ return state.maskingRuleItemList.filter((item) => {
+ return (
+ state.checkedLevel.size === 0 ||
+ state.checkedLevel.has(item.rule.maskingLevel)
+ );
+ });
+});
+
+const toggleCheckLevel = (level: number, checked: boolean) => {
+ if (checked) state.checkedLevel.add(level);
+ else state.checkedLevel.delete(level);
+};
+
+const addNewRule = () => {
+ state.maskingRuleItemList.push({
+ mode: "CREATE",
+ rule: MaskingRulePolicy_MaskingRule.fromJSON({
+ id: uuidv4(),
+ maskingLevel: MaskingLevel.FULL,
+ }),
+ });
+ nextTick(() => {
+ const elem = document.querySelector("#bb-layout-main");
+ elem?.scrollTo(
+ 0,
+ document.body.scrollHeight || document.documentElement.scrollHeight
+ );
+ });
+};
+
+const onCancel = (id: string, mode: MaskingRuleMode) => {
+ if (mode !== "CREATE") {
+ return;
+ }
+ const index = state.maskingRuleItemList.findIndex(
+ (item) => item.rule.id === id
+ );
+ if (index < 0) {
+ return;
+ }
+ state.maskingRuleItemList.splice(index, 1);
+};
+
+const onConfirm = async (rule: MaskingRulePolicy_MaskingRule) => {
+ if (state.processing) {
+ return;
+ }
+
+ const index = state.maskingRuleItemList.findIndex(
+ (item) => item.rule.id === rule.id
+ );
+ if (index < 0) {
+ return;
+ }
+
+ state.processing = true;
+
+ state.maskingRuleItemList[index] = {
+ mode: "EDIT",
+ rule,
+ };
+ try {
+ await onPolicyUpsert();
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ } finally {
+ state.processing = false;
+ }
+};
+
+const onReorder = (maskingRuleItem: MaskingRuleItem, offset: number) => {
+ const index = state.maskingRuleItemList.findIndex(
+ (item) => item.rule.id === maskingRuleItem.rule.id
+ );
+ if (index < 0) {
+ return;
+ }
+
+ arraySwap(state.maskingRuleItemList, index, index + offset);
+};
+
+const onReorderSubmit = async () => {
+ await onPolicyUpsert();
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ state.reorderRules = false;
+};
+
+const onRuleDelete = async (maskingRuleItem: MaskingRuleItem) => {
+ const index = state.maskingRuleItemList.findIndex(
+ (item) => item.rule.id === maskingRuleItem.rule.id
+ );
+ if (index < 0) {
+ return;
+ }
+
+ state.maskingRuleItemList.splice(index, 1);
+ if (maskingRuleItem.mode === "CREATE") {
+ return;
+ }
+
+ await onPolicyUpsert();
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+};
+
+const onPolicyUpsert = async () => {
+ const patch: Partial<Policy> = {
+ type: PolicyType.MASKING_RULE,
+ resourceType: PolicyResourceType.WORKSPACE,
+ resourceUid: "1",
+ maskingRulePolicy: {
+ rules: state.maskingRuleItemList
+ .filter((item) => item.mode === "EDIT")
+ .map((item) => item.rule),
+ },
+ };
+
+ await policyStore.upsertPolicy({
+ parentPath: "",
+ policy: patch,
+ updateMask: ["payload"],
+ });
+};
+</script>
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnView.vue b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
index ef3f7ba8f7..8c70cd0a6a 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnView.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
@@ -1,11 +1,36 @@
<template>
<div class="w-full mt-4 space-y-4">
- <div class="flex justify-between">
+ <div>
<EnvironmentTabFilter
- :environment="state.environment"
+ :environment="state.selectedEnvironmentName"
:include-all="true"
- @update:environment="state.environment = $event"
+ @update:environment="state.selectedEnvironmentName = $event"
/>
+ </div>
+ <div class="flex justify-between items-center">
+ <div class="flex items-center">
+ <ProjectSelect
+ :project="state.selectedProjectUid"
+ :include-default-project="true"
+ :include-all="true"
+ :disabled="false"
+ @update:project="
+ state.selectedProjectUid = $event ?? String(UNKNOWN_ID)
+ "
+ />
+ <InstanceSelect
+ :instance="state.selectedInstanceUid"
+ :include-all="true"
+ :environment="environment?.uid"
+ @update:instance="onInstanceSelect($event)"
+ />
+ <DatabaseSelect
+ :project="state.selectedProjectUid"
+ :instance="state.selectedInstanceUid"
+ :database="state.selectedDatabaseUid"
+ @update:database="onDatabaseSelect($event)"
+ />
+ </div>
<NButton
type="primary"
:disabled="
@@ -88,15 +113,21 @@ import { uniq } from "lodash-es";
import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import {
+ ProjectSelect,
+ InstanceSelect,
+ DatabaseSelect,
+} from "@/components/v2/Select";
import {
usePolicyListByResourceTypeAndPolicyType,
featureToRef,
useDatabaseV1Store,
useCurrentUserV1,
+ useEnvironmentV1Store,
pushNotification,
usePolicyV1Store,
} from "@/store";
-import { UNKNOWN_ENVIRONMENT_NAME } from "@/types";
+import { UNKNOWN_ID, UNKNOWN_ENVIRONMENT_NAME } from "@/types";
import {
PolicyType,
PolicyResourceType,
@@ -106,7 +137,10 @@ import { SensitiveColumn } from "./types";
import { getMaskDataIdentifier, isCurrentColumnException } from "./utils";
interface LocalState {
- environment: string;
+ selectedEnvironmentName: string;
+ selectedProjectUid: string;
+ selectedInstanceUid: string;
+ selectedDatabaseUid: string;
showFeatureModal: boolean;
isLoading: boolean;
sensitiveColumnList: SensitiveColumn[];
@@ -121,7 +155,10 @@ const state = reactive<LocalState>({
showFeatureModal: false,
isLoading: false,
sensitiveColumnList: [],
- environment: UNKNOWN_ENVIRONMENT_NAME,
+ selectedEnvironmentName: UNKNOWN_ENVIRONMENT_NAME,
+ selectedProjectUid: String(UNKNOWN_ID),
+ selectedInstanceUid: String(UNKNOWN_ID),
+ selectedDatabaseUid: String(UNKNOWN_ID),
pendingGrantAccessColumnIndex: [],
showGrantAccessDrawer: false,
showSensitiveColumnDrawer: false,
@@ -129,6 +166,7 @@ const state = reactive<LocalState>({
const databaseStore = useDatabaseV1Store();
const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
const policyStore = usePolicyV1Store();
+const environmentStore = useEnvironmentV1Store();
const policyList = usePolicyListByResourceTypeAndPolicyType({
resourceType: PolicyResourceType.DATABASE,
@@ -267,12 +305,52 @@ const onRowClick = async (
const filteredColumnList = computed(() => {
return state.sensitiveColumnList.filter((column) => {
- if (state.environment === UNKNOWN_ENVIRONMENT_NAME) {
- return true;
+ if (
+ state.selectedEnvironmentName !== UNKNOWN_ENVIRONMENT_NAME &&
+ column.database.effectiveEnvironmentEntity.name !==
+ state.selectedEnvironmentName
+ ) {
+ return false;
+ }
+ if (
+ state.selectedProjectUid !== String(UNKNOWN_ID) &&
+ column.database.projectEntity.uid !== state.selectedProjectUid
+ ) {
+ return false;
+ }
+ if (
+ state.selectedInstanceUid !== String(UNKNOWN_ID) &&
+ column.database.instanceEntity.uid !== state.selectedInstanceUid
+ ) {
+ return false;
+ }
+ if (
+ state.selectedDatabaseUid !== String(UNKNOWN_ID) &&
+ column.database.uid !== state.selectedDatabaseUid
+ ) {
+ return false;
}
- return (
- column.database.effectiveEnvironmentEntity.name === state.environment
- );
+ return true;
});
});
+
+const environment = computed(() => {
+ if (state.selectedEnvironmentName === UNKNOWN_ENVIRONMENT_NAME) {
+ return;
+ }
+ return environmentStore.getEnvironmentByName(state.selectedEnvironmentName);
+});
+
+const onInstanceSelect = (instanceUid: string | undefined) => {
+ state.selectedInstanceUid = instanceUid ?? String(UNKNOWN_ID);
+ state.selectedDatabaseUid = String(UNKNOWN_ID);
+};
+
+const onDatabaseSelect = (databaseUid: string | undefined) => {
+ state.selectedDatabaseUid = databaseUid ?? String(UNKNOWN_ID);
+ if (databaseUid) {
+ const database = databaseStore.getDatabaseByUID(databaseUid);
+ state.selectedInstanceUid = database.instanceEntity.uid;
+ }
+};
</script>
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index bb0497aaf3..1e57eb1884 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -1,5 +1,5 @@
<template>
- <div class="gap-y-4">
+ <div class="gap-y-4 w-full">
<div class="flex items-stretch gap-x-4 overflow-hidden">
<div class="flex-1 space-y-2 py-4 overflow-x-hidden overflow-y-auto">
<h3 class="font-medium text-sm text-control">
@@ -25,7 +25,7 @@
:options="options"
:placeholder="$t('settings.sensitive-data.masking-level.selet-level')"
:consistent-menu-width="false"
- :disabled="readonly"
+ :disabled="readonly || disabled"
@update:value="state.dirty = true"
/>
</div>
@@ -34,10 +34,14 @@
v-if="(state.dirty || isCreate) && !readonly"
class="flex justify-end gap-x-3"
>
- <NButton @click="onCancel">
+ <NButton :disabled="disabled" @click="onCancel">
{{ $t("common.cancel") }}
</NButton>
- <NButton type="primary" :disabled="!isValid" @click="onConfirm">
+ <NButton
+ type="primary"
+ :disabled="!isValid || disabled"
+ @click="onConfirm"
+ >
{{ $t("common.confirm") }}
</NButton>
</div>
@@ -47,7 +51,7 @@
<script lang="ts" setup>
import { cloneDeep } from "lodash-es";
import { NSelect, SelectOption } from "naive-ui";
-import { computed, ref, onMounted } from "vue";
+import { computed, ref, onMounted, nextTick } from "vue";
import { useI18n } from "vue-i18n";
import ExprEditor from "@/components/ExprEditor";
import type { ConditionGroupExpr } from "@/plugins/cel";
@@ -78,6 +82,7 @@ import {
const props = defineProps<{
isCreate?: boolean;
readonly: boolean;
+ disabled: boolean;
maskingRule: MaskingRulePolicy_MaskingRule;
}>();
@@ -121,6 +126,7 @@ const options = computed(() => {
const onCancel = async () => {
await resetLocalState();
emit("cancel");
+ nextTick(() => (state.value.dirty = false));
};
const resetLocalState = async () => {
diff --git a/frontend/src/components/SensitiveData/index.ts b/frontend/src/components/SensitiveData/index.ts
index 5268b2fe4c..34d522267e 100644
--- a/frontend/src/components/SensitiveData/index.ts
+++ b/frontend/src/components/SensitiveData/index.ts
@@ -1,4 +1,5 @@
-import GlobalMaskingRule from "./GlobalMaskingRule.vue";
+import DataFeatureView from "./DataFeatureView.vue";
+import GlobalMaskingRulesView from "./GlobalMaskingRulesView.vue";
import SensitiveColumnView from "./SensitiveColumnView.vue";
-export { SensitiveColumnView, GlobalMaskingRule };
+export { SensitiveColumnView, GlobalMaskingRulesView, DataFeatureView };
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 16cc6cd572..0754eca6c3 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -624,9 +624,13 @@
"sensitive-column-list": "Sensitive Column List",
"global-masking-rule": "Global Masking Rule",
"data-feature": "Data Feature",
- "add-rule": "Add rule",
"grant-access": "Grant Access",
"never-expires": "Never expires",
+ "global-rules": {
+ "add-rule": "Add rule",
+ "re-order": "Re-order",
+ "delete-rule-tip": "Delete this rule?"
+ },
"column-detail": {
"masking-setting-for-column": "Masking Setting for \"{column}\"",
"access-user-list": "Access User List",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index cc9d38df44..7e716f6763 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -623,9 +623,13 @@
"sensitive-column-list": "Lista de columnas confidenciales",
"global-masking-rule": "Regla de enmascaramiento global",
"data-feature": "Característica de datos",
- "add-rule": "Agregar regla",
"grant-access": "Autorizará el acceso",
"never-expires": "Nunca expira",
+ "global-rules": {
+ "add-rule": "Agregar regla",
+ "re-order": "Reordenar",
+ "delete-rule-tip": "¿Eliminar esta regla?"
+ },
"column-detail": {
"masking-setting-for-column": "Configuración de enmascaramiento para \"{columna}\"",
"access-user-list": "Acceder a la lista de usuarios",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 952190df90..63e4ed16f7 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -622,9 +622,13 @@
"sensitive-column-list": "敏感数据列表",
"global-masking-rule": "全局脱敏规则",
"data-feature": "数据特征",
- "add-rule": "添加规则",
"grant-access": "授权访问",
"never-expires": "无过期时间",
+ "global-rules": {
+ "add-rule": "添加规则",
+ "re-order": "排序",
+ "delete-rule-tip": "删除这条规则?"
+ },
"column-detail": {
"masking-setting-for-column": "\"{column}\" 脱敏设置",
"access-user-list": "用户访问列表",
diff --git a/frontend/src/store/modules/v1/policy.ts b/frontend/src/store/modules/v1/policy.ts
index 3c3cf9837d..1f381d7b68 100644
--- a/frontend/src/store/modules/v1/policy.ts
+++ b/frontend/src/store/modules/v1/policy.ts
@@ -25,6 +25,9 @@ const replacePolicyTypeNameToLowerCase = (name: string) => {
return `${left}policies/${policyType.toLowerCase()}${right}`;
}
);
+ if (replaced.startsWith("/")) {
+ return replaced.slice(1);
+ }
return replaced;
};
diff --git a/frontend/src/views/SettingWorkspaceSensitiveData.vue b/frontend/src/views/SettingWorkspaceSensitiveData.vue
index 425ae1cdf7..0cb05509d4 100644
--- a/frontend/src/views/SettingWorkspaceSensitiveData.vue
+++ b/frontend/src/views/SettingWorkspaceSensitiveData.vue
@@ -7,7 +7,6 @@
<FeatureAttention v-else feature="bb.feature.sensitive-data" />
<BBTab
- v-if="isDev()"
:tab-item-list="tabItemList"
:selected-index="state.selectedIndex"
reorder-model="NEVER"
@@ -18,11 +17,13 @@
<SensitiveColumnView />
</BBTabPanel>
<BBTabPanel :active="state.selectedIndex === 1">
- <GlobalMaskingRule />
+ <GlobalMaskingRulesView />
+ </BBTabPanel>
+ <BBTabPanel :active="state.selectedIndex === 2">
+ <DataFeatureView />
</BBTabPanel>
</div>
</BBTab>
- <SensitiveColumnView v-else />
</div>
</template>
@@ -33,7 +34,8 @@ import { useRouter } from "vue-router";
import type { BBTabItem } from "@/bbkit/types";
import {
SensitiveColumnView,
- GlobalMaskingRule,
+ GlobalMaskingRulesView,
+ DataFeatureView,
} from "@/components/SensitiveData";
import { featureToRef } from "@/store";
import { isDev } from "@/utils";
@@ -50,7 +52,7 @@ const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
const router = useRouter();
const tabItemList = computed((): BBTabItem[] => {
- return [
+ const tabList = [
{
title: t("settings.sensitive-data.sensitive-column-list"),
id: "sensitive-column-list",
@@ -59,11 +61,14 @@ const tabItemList = computed((): BBTabItem[] => {
title: t("settings.sensitive-data.global-masking-rule"),
id: "global-masking-rule",
},
- {
+ ];
+ if (isDev()) {
+ tabList.push({
title: t("settings.sensitive-data.data-feature"),
id: "data-feature",
- },
- ];
+ });
+ }
+ return tabList;
});
onMounted(() => {