Skip to content

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

fix: ux issue for masking (#8101)

ecmadao32c2e55fe8ba
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
index 1d1a44eab2..f368258a1f 100644
--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
@@ -1,30 +1,6 @@
<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 class="flex items-center justify-end">
<div v-if="state.reorderRules" class="flex items-center space-x-3">
<NButton
:disabled="state.processing"
@@ -54,12 +30,7 @@
!hasSensitiveDataFeature ||
state.maskingRuleItemList.length <= 1
"
- @click="
- () => {
- state.checkedLevel.clear();
- state.reorderRules = true;
- }
- "
+ @click="state.reorderRules = true"
>
{{ $t("settings.sensitive-data.global-rules.re-order") }}
</NButton>
@@ -74,7 +45,7 @@
</div>
<div class="space-y-5 divide-y-2 pb-10 divide-gray-100">
<div
- v-if="filteredRuleList.length === 0"
+ v-if="state.maskingRuleItemList.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">
@@ -82,7 +53,7 @@
</div>
</div>
<div
- v-for="(item, index) in filteredRuleList"
+ v-for="(item, index) in state.maskingRuleItemList"
:key="item.rule.id"
class="flex items-start space-x-5"
>
@@ -95,7 +66,7 @@
</button>
<button @click="onReorder(item, 1)">
<heroicons-solid:arrow-circle-down
- v-if="index !== filteredRuleList.length - 1"
+ v-if="index !== state.maskingRuleItemList.length - 1"
class="w-6 h-6"
/>
</button>
@@ -114,6 +85,7 @@
</div>
</NPopconfirm>
<MaskingRuleConfig
+ :index="index + 1"
:readonly="!hasPermission || state.reorderRules"
:disabled="state.processing"
:masking-rule="item.rule"
@@ -129,12 +101,11 @@
</template>
<script lang="ts" setup>
-import { NCheckbox, NPopconfirm } from "naive-ui";
+import { NPopconfirm } from "naive-ui";
import type { SelectOption } 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 { Factor } from "@/plugins/cel";
import {
featureToRef,
@@ -142,7 +113,7 @@ import {
useCurrentUserV1,
usePolicyV1Store,
} from "@/store";
-import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";
+import { MaskingLevel } from "@/types/proto/v1/common";
import {
Policy,
PolicyType,
@@ -159,19 +130,12 @@ import {
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;
@@ -179,7 +143,6 @@ interface LocalState {
const { t } = useI18n();
const state = reactive<LocalState>({
- checkedLevel: new Set<MaskingLevel>(),
maskingRuleItemList: [],
processing: false,
reorderRules: false,
@@ -218,45 +181,6 @@ 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",
diff --git a/frontend/src/components/SensitiveData/GrantAccessDrawer.vue b/frontend/src/components/SensitiveData/GrantAccessDrawer.vue
index 146c65ef00..38113ac9ef 100644
--- a/frontend/src/components/SensitiveData/GrantAccessDrawer.vue
+++ b/frontend/src/components/SensitiveData/GrantAccessDrawer.vue
@@ -1,5 +1,5 @@
<template>
- <Drawer :show="show" @close="onDismiss">
+ <Drawer :show="true" @close="onDismiss">
<DrawerContent :title="$t('settings.sensitive-data.grant-access')">
<div class="divide-block-border space-y-8 w-[60rem] h-full">
<SensitiveColumnTable
@@ -110,7 +110,6 @@ import { SensitiveColumn } from "./types";
import { getExpressionsForSensitiveColumn } from "./utils";
const props = defineProps<{
- show: boolean;
columnList: SensitiveColumn[];
}>();
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
index 44951a5f76..4064e0c954 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
@@ -14,10 +14,10 @@
{{ $t("settings.sensitive-data.masking-level.self") }}
</h1>
<MaskingLevelRadioGroup
- :disabled="!hasPermission"
:level-list="MASKING_LEVELS"
:selected="state.maskingLevel"
- @update="state.maskingLevel = $event"
+ :disabled="!hasPermission || state.processing"
+ @update="onMaskingLevelUpdate($event)"
/>
</div>
<div class="w-full">
@@ -100,7 +100,8 @@
MaskingExceptionPolicy_MaskingException_Action.EXPORT
)
"
- @toggle="(checked: boolean) => onUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.EXPORT, checked))"
+ :disabled="!hasPermission || state.processing"
+ @toggle="(checked: boolean) => onAccessControlUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.EXPORT, checked))"
/>
</BBTableCell>
<BBTableCell class="bb-grid-cell">
@@ -110,15 +111,16 @@
MaskingExceptionPolicy_MaskingException_Action.QUERY
)
"
- @toggle="(checked: boolean) => onUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.QUERY, checked))"
+ :disabled="!hasPermission || state.processing"
+ @toggle="(checked: boolean) => onAccessControlUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.QUERY, checked))"
/>
</BBTableCell>
<BBTableCell class="bb-grid-cell">
<MaskingLevelDropdown
- :disabled="!hasPermission"
+ :disabled="!hasPermission || state.processing"
:selected="item.maskingLevel"
:level-list="[MaskingLevel.PARTIAL, MaskingLevel.NONE]"
- @update="(level: MaskingLevel) => onUpdate(row, (item) => item.maskingLevel = level)"
+ @update="(level: MaskingLevel) => onAccessControlUpdate(row, (item) => item.maskingLevel = level)"
/>
</BBTableCell>
<BBTableCell class="bb-grid-cell">
@@ -128,7 +130,8 @@
type="datetime"
:is-date-disabled="(date: number) => date < Date.now()"
clearable
- @update:value="(val: number | undefined) => onUpdate(row, (item) => item.expirationTimestamp = val)"
+ :disabled="!hasPermission || state.processing"
+ @update:value="(val: number | undefined) => onAccessControlUpdate(row, (item) => item.expirationTimestamp = val)"
/>
</BBTableCell>
<BBTableCell v-if="hasPermission" class="bb-grid-cell">
@@ -136,6 +139,7 @@
<template #trigger>
<button
class="w-5 h-5 p-0.5 hover:bg-control-bg-hover rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"
+ :disabled="!hasPermission || state.processing"
@click.stop=""
>
<heroicons-outline:trash class="w-4 h-4" />
@@ -162,24 +166,13 @@
<NButton @click.prevent="$emit('dismiss')">
{{ $t("common.cancel") }}
</NButton>
- <NButton
- :disabled="
- !hasPermission ||
- (!state.dirty && !maskingPolicyChanged) ||
- state.processing
- "
- type="primary"
- @click.prevent="onSubmit"
- >
- {{ $t("common.confirm") }}
- </NButton>
</div>
</div>
</template>
</DrawerContent>
<GrantAccessDrawer
- :show="state.showGrantAccessDrawer"
+ v-if="state.showGrantAccessDrawer"
:column-list="[props.column]"
@dismiss="state.showGrantAccessDrawer = false"
/>
@@ -235,7 +228,7 @@ const props = defineProps<{
column: SensitiveColumn;
}>();
-const emit = defineEmits(["dismiss"]);
+defineEmits(["dismiss"]);
const state = reactive<LocalState>({
dirty: false,
@@ -276,6 +269,8 @@ const expirationTimeRegex = /request.time < timestamp\("(.+)?"\)/;
const getAccessUsers = (
exception: MaskingExceptionPolicy_MaskingException
): AccessUser => {
+ console.log("exception");
+ console.log(exception);
let expirationTimestamp: number | undefined;
const expression = exception.condition?.expression ?? "";
const matches = expirationTimeRegex.exec(expression);
@@ -324,6 +319,8 @@ const updateAccessUserList = (policy: Policy | undefined) => {
// - 2 cannot merge: user1, action:export, level:FULL, expires at 2023-09-04
// - 3 & 4 is merged: user1, action:export+action, level:PARTIAL, expires at 2023-09-04
const userMap = new Map<string, AccessUser>();
+ console.log("policy.maskingExceptionPolicy.maskingExceptions");
+ console.log(policy.maskingExceptionPolicy.maskingExceptions);
for (const exception of policy.maskingExceptionPolicy.maskingExceptions) {
if (!isCurrentColumnException(exception, props.column)) {
continue;
@@ -388,9 +385,10 @@ const tableHeaderList = computed(() => {
return list;
});
-const onRemove = (index: number) => {
+const onRemove = async (index: number) => {
accessUserList.value.splice(index, 1);
state.dirty = true;
+ await onSubmit();
};
const toggleAction = (
@@ -409,13 +407,22 @@ const maskingPolicyChanged = computed(() => {
return state.maskingLevel !== props.column.maskData.maskingLevel;
});
-const onUpdate = (index: number, callback: (item: AccessUser) => void) => {
+const onAccessControlUpdate = async (
+ index: number,
+ callback: (item: AccessUser) => void
+) => {
const item = accessUserList.value[index];
if (!item) {
return;
}
callback(item);
state.dirty = true;
+ await onSubmit();
+};
+
+const onMaskingLevelUpdate = async (level: MaskingLevel) => {
+ state.maskingLevel = level;
+ await onSubmit();
};
const onSubmit = async () => {
@@ -427,13 +434,13 @@ const onSubmit = async () => {
}
if (state.dirty) {
await updateExceptionPolicy();
+ state.dirty = false;
}
pushNotification({
module: "bytebase",
style: "SUCCESS",
title: t("common.updated"),
});
- emit("dismiss");
} finally {
state.processing = false;
}
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnView.vue b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
index de27ecc965..dd4b335ca1 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnView.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
@@ -78,7 +78,7 @@
/>
<GrantAccessDrawer
- :show="
+ v-if="
state.showGrantAccessDrawer &&
state.pendingGrantAccessColumnIndex.length > 0
"
@@ -100,8 +100,9 @@
state.pendingGrantAccessColumnIndex.length === 1
"
:column="
- filteredColumnList[state.pendingGrantAccessColumnIndex[0]] ??
- filteredColumnList[0]
+ state.pendingGrantAccessColumnIndex.length
+ ? filteredColumnList[state.pendingGrantAccessColumnIndex[0]]
+ : filteredColumnList[0]
"
@dismiss="
() => {
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index dbeecdb7cd..b466dfdfa4 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -4,6 +4,7 @@
<div class="flex-1 space-y-2 py-4 overflow-x-hidden overflow-y-auto">
<h3 class="font-medium text-sm text-control">
{{ $t("custom-approval.security-rule.condition.self") }}
+ {{ index }}
</h3>
<ExprEditor
:expr="state.expr"
@@ -75,6 +76,7 @@ import {
import { factorSupportDropdown, factorOperatorOverrideMap } from "./utils";
const props = defineProps<{
+ index: number;
isCreate?: boolean;
readonly: boolean;
disabled: boolean;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 89e23aee7d..ac45a4cbbe 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -626,7 +626,7 @@
"remove-sensitive-column-tips": "Expose this column?",
"sensitive-column-list": "Sensitive Column List",
"global-masking-rule": "Global Masking Rule",
- "data-feature": "Data Feature",
+ "semantic-types": "Semantic Types",
"grant-access": "Grant Access",
"never-expires": "Never expires",
"global-rules": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index d37612574e..a39850e823 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -625,7 +625,7 @@
"remove-sensitive-column-tips": "¿Exponer esta columna?",
"sensitive-column-list": "Lista de columnas confidenciales",
"global-masking-rule": "Regla de enmascaramiento global",
- "data-feature": "Característica de datos",
+ "semantic-types": "Tipos semánticos",
"grant-access": "Autorizará el acceso",
"never-expires": "Nunca expira",
"global-rules": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index e0349119a3..04b2bfcb13 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -624,7 +624,7 @@
"remove-sensitive-column-tips": "不再对此列数据脱敏?",
"sensitive-column-list": "敏感数据列表",
"global-masking-rule": "全局脱敏规则",
- "data-feature": "数据特征",
+ "semantic-types": "语义类型",
"grant-access": "授权访问",
"never-expires": "无过期时间",
"global-rules": {
diff --git a/frontend/src/views/SettingWorkspaceSensitiveData.vue b/frontend/src/views/SettingWorkspaceSensitiveData.vue
index 0cb05509d4..e6fa7ce093 100644
--- a/frontend/src/views/SettingWorkspaceSensitiveData.vue
+++ b/frontend/src/views/SettingWorkspaceSensitiveData.vue
@@ -64,8 +64,8 @@ const tabItemList = computed((): BBTabItem[] => {
];
if (isDev()) {
tabList.push({
- title: t("settings.sensitive-data.data-feature"),
- id: "data-feature",
+ title: t("settings.sensitive-data.semantic-types"),
+ id: "semantic-types",
});
}
return tabList;