Skip to content

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

chore: update UI for semantic algorithm (#14889)

ecmadao3ebde6b1041c
diff --git a/frontend/src/components/GeneralSetting/AccountSetting.vue b/frontend/src/components/GeneralSetting/AccountSetting.vue
index b6ebca4f98..eca728073b 100644
--- a/frontend/src/components/GeneralSetting/AccountSetting.vue
+++ b/frontend/src/components/GeneralSetting/AccountSetting.vue
@@ -20,9 +20,10 @@
:disabled="!allowEdit || !hasDisallowSignupFeature"
@update:value="handleDisallowSignupToggle"
/>
- <span class="textlabel">
+ <div class="textlabel flex items-center gap-x-2">
{{ $t("settings.general.workspace.disallow-signup.enable") }}
- </span>
+ <FeatureBadge feature="bb.feature.disallow-signup" />
+ </div>
</div>
<div class="mt-1 mb-3 text-sm text-gray-400">
{{ $t("settings.general.workspace.disallow-signup.description") }}
@@ -43,7 +44,7 @@
:disabled="!allowEdit || !has2FAFeature"
@update:value="handleRequire2FAToggle"
/>
- <div class="textlabel flex items-center space-x-2">
+ <div class="textlabel flex items-center gap-x-2">
{{ $t("settings.general.workspace.require-2fa.enable") }}
<FeatureBadge feature="bb.feature.2fa" />
</div>
@@ -60,7 +61,7 @@
:disabled="!allowEdit || !hasDisallowPasswordSigninFeature"
@update:value="handleDisallowPasswordSigninToggle"
/>
- <div class="textlabel flex items-center space-x-2">
+ <div class="textlabel flex items-center gap-x-2">
{{
$t("settings.general.workspace.disallow-password-signin.enable")
}}
diff --git a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
index a39add27fd..84d015c53e 100644
--- a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
+++ b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue
@@ -1,9 +1,9 @@
<template>
<div class="mb-7 mt-4 lg:mt-0">
- <p class="font-medium flex flex-row justify-start items-center mb-2">
- <span class="mr-2">
- {{ $t("settings.general.workspace.password-restriction.self") }}
- </span>
+ <p
+ class="font-medium flex flex-row justify-start items-center mb-2 gap-x-2"
+ >
+ {{ $t("settings.general.workspace.password-restriction.self") }}
<FeatureBadge feature="bb.feature.password-restriction" />
</p>
<div class="w-full flex flex-col space-y-3">
diff --git a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
index e6f21dd093..3a5770b117 100644
--- a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue
@@ -1,34 +1,16 @@
<template>
<Drawer :show="show" @close="$emit('dismiss')">
<DrawerContent
+ :title="
+ algorithm
+ ? $t('settings.sensitive-data.algorithms.edit')
+ : $t('settings.sensitive-data.algorithms.add')
+ "
>
<div
class="w-[40rem] max-w-[calc(100vw-5rem)] space-y-6 divide-y divide-block-border"
>
<div class="space-y-6">
- <div class="sm:col-span-2 sm:col-start-1">
- <label for="title" class="textlabel">
- {{ $t("settings.sensitive-data.algorithms.table.title") }}
- <span class="text-red-600 mr-2">*</span>
- </label>
- <NInput
- v-model:value="state.title"
- :placeholder="t('settings.sensitive-data.algorithms.table.title')"
- :disabled="state.processing || readonly"
- />
- </div>
- <div class="sm:col-span-2 sm:col-start-1">
- <label for="description" class="textlabel">
- {{ $t("settings.sensitive-data.algorithms.table.description") }}
- </label>
- <NInput
- v-model:value="state.description"
- :placeholder="
- t('settings.sensitive-data.algorithms.table.description')
- "
- :disabled="state.processing || readonly"
- />
- </div>
<div class="w-full mb-6 space-y-1">
<label for="masking-type" class="textlabel">
{{ $t("settings.sensitive-data.algorithms.table.masking-type") }}
@@ -353,8 +335,6 @@ interface MaskingTypeOption extends RadioGridOption<MaskingType> {
interface LocalState {
processing: boolean;
maskingType: MaskingType;
- title: string;
- description: string;
fullMask: FullMask;
rangeMask: RangeMask;
md5Mask: MD5Mask;
@@ -364,7 +344,7 @@ interface LocalState {
const props = defineProps<{
show: boolean;
readonly: boolean;
- algorithm: Algorithm;
+ algorithm?: Algorithm;
}>();
defineEmits<{
@@ -396,8 +376,6 @@ const defaultInnerOuterMask = computed(() =>
const state = reactive<LocalState>({
processing: false,
maskingType: "full-mask",
- title: "",
- description: "",
fullMask: FullMask.fromPartial({}),
rangeMask: cloneDeep(defaultRangeMask.value),
md5Mask: MD5Mask.fromPartial({}),
@@ -429,17 +407,16 @@ watch(
() => props.algorithm,
(algorithm) => {
state.maskingType = getMaskingType(algorithm) ?? "full-mask";
- state.fullMask = algorithm.fullMask ?? FullMask.fromPartial({});
- state.rangeMask = algorithm.rangeMask ?? cloneDeep(defaultRangeMask.value);
- state.md5Mask = algorithm.md5Mask ?? MD5Mask.fromPartial({});
+ state.fullMask = algorithm?.fullMask ?? FullMask.fromPartial({});
+ state.rangeMask = algorithm?.rangeMask ?? cloneDeep(defaultRangeMask.value);
+ state.md5Mask = algorithm?.md5Mask ?? MD5Mask.fromPartial({});
state.innerOuterMask =
- algorithm.innerOuterMask ?? cloneDeep(defaultInnerOuterMask.value);
+ algorithm?.innerOuterMask ?? cloneDeep(defaultInnerOuterMask.value);
}
);
const maskingAlgorithm = computed((): Algorithm => {
- const result = Algorithm.fromPartial({
- });
+ const result = Algorithm.fromPartial({});
switch (state.maskingType) {
case "full-mask":
@@ -489,10 +466,6 @@ const rangeMaskErrorMessage = computed(() => {
});
const errorMessage = computed(() => {
- if (!state.title) {
- return t("settings.sensitive-data.algorithms.error.title-required");
- }
-
switch (state.maskingType) {
case "full-mask":
if (!state.fullMask.substitution) {
@@ -534,10 +507,6 @@ const isSubmitDisabled = computed(() => {
return true;
}
- if (!state.title) {
- return true;
- }
-
return !!errorMessage.value;
});
diff --git a/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue b/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue
index 9a460d0a8a..6fb05ad2e9 100644
--- a/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue
+++ b/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue
@@ -1,10 +1,11 @@
<template>
<Drawer :show="show" @close="$emit('dismiss')">
<DrawerContent :title="$t('settings.sensitive-data.semantic-types.self')">
- <div class="divide-block-border space-y-8 w-[40rem] h-full">
+ <div class="divide-block-border space-y-8 w-[50rem] h-full">
<SemanticTypesTable
:readonly="true"
:row-clickable="true"
+ :size="'small'"
:semantic-item-list="semanticItemList"
@select="onApply($event)"
/>
@@ -23,12 +24,12 @@
</template>
<script lang="ts" setup>
+import { NButton } from "naive-ui";
import { computed } from "vue";
import { Drawer, DrawerContent } from "@/components/v2";
import type { SemanticTypeSetting_SemanticType } from "@/types/proto/v1/setting_service";
import type { SemanticItem } from "./SemanticTypesTable.vue";
import SemanticTypesTable from "./SemanticTypesTable.vue";
-import { NButton } from "naive-ui";
const props = defineProps<{
show: boolean;
diff --git a/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue b/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue
index c3742427f4..6a94d78f15 100644
--- a/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue
+++ b/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue
@@ -1,5 +1,6 @@
<template>
<NDataTable
+ :size="size"
:data="semanticItemList"
:columns="columnList"
:striped="true"
@@ -29,6 +30,7 @@ import {
type SemanticTypeSetting_SemanticType,
} from "@/types/proto/v1/setting_service";
import MaskingAlgorithmsCreateDrawer from "./MaskingAlgorithmsCreateDrawer.vue";
+import { getMaskingType } from "./utils";
type SemanticItemMode = "NORMAL" | "CREATE" | "EDIT";
@@ -40,16 +42,20 @@ export interface SemanticItem {
interface LocalState {
showAlgorithmDrawer: boolean;
- pendingEditAlgorithm: Algorithm;
+ pendingEditAlgorithm?: Algorithm;
pendingEditSemanticIndex?: number;
processing: boolean;
}
-const props = defineProps<{
- readonly: boolean;
- semanticItemList: SemanticItem[];
- rowClickable: boolean;
-}>();
+const props = withDefaults(
+ defineProps<{
+ size?: "small" | "medium" | "large";
+ readonly: boolean;
+ semanticItemList: SemanticItem[];
+ rowClickable: boolean;
+ }>(),
+ { size: "medium" }
+);
const emit = defineEmits<{
(event: "select", id: string): void;
@@ -60,7 +66,6 @@ const emit = defineEmits<{
const state = reactive<LocalState>({
showAlgorithmDrawer: false,
- pendingEditAlgorithm: Algorithm.fromPartial({}),
processing: false,
});
@@ -92,7 +97,7 @@ const columnList = computed(() => {
{
key: "title",
title: t("settings.sensitive-data.semantic-types.table.semantic-type"),
- width: 300,
+ width: "minmax(min-content, auto)",
render: (item, row) => {
if (item.mode === "NORMAL") {
return <h3 class="break-normal">{item.item.title}</h3>;
@@ -146,12 +151,19 @@ const columnList = computed(() => {
render: (item, row) => {
return (
<div class="flex items-center space-x-1">
+ <h3>
+ {getMaskingType(item.item.algorithm)
+ ? t(
+ `settings.sensitive-data.algorithms.${getMaskingType(item.item.algorithm)?.toLowerCase()}.self`
+ )
+ : t("settings.sensitive-data.algorithms.default")}
+ </h3>
{!props.readonly && (
<MiniActionButton
onClick={() => {
- state.pendingEditAlgorithm =
- item.item.algorithm ??
- Algorithm.fromPartial({});
+ state.pendingEditAlgorithm = getMaskingType(item.item.algorithm)
+ ? item.item.algorithm
+ : undefined;
state.pendingEditSemanticIndex = row;
state.showAlgorithmDrawer = true;
}}
diff --git a/frontend/src/components/SensitiveData/components/utils.ts b/frontend/src/components/SensitiveData/components/utils.ts
index 381b14ed3b..0f893c6296 100644
--- a/frontend/src/components/SensitiveData/components/utils.ts
+++ b/frontend/src/components/SensitiveData/components/utils.ts
@@ -88,8 +88,11 @@ export type MaskingType =
| "inner-outer-mask";
export const getMaskingType = (
- algorithm: Algorithm
+ algorithm: Algorithm | undefined
): MaskingType | undefined => {
+ if (!algorithm) {
+ return;
+ }
if (algorithm.fullMask) {
return "full-mask";
} else if (algorithm.rangeMask) {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index cb0b52d81c..3cad7aec93 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -890,6 +890,8 @@
},
"algorithms": {
"self": "Masking Algorithm",
+ "add": "Add algorithm",
+ "edit": "Edit algorithm",
"upload": "Upload algorithm",
"upload-label": "You can upload algorithm file with JSON format.",
"override-title": "Algorithm data override",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 25f83cc65d..76fccfb759 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -890,6 +890,8 @@
},
"algorithms": {
"self": "Algoritmo De Enmascaramiento",
+ "add": "Agregar algoritmo",
+ "edit": "Editar algoritmo",
"upload": "Subir algoritmo",
"upload-label": "Puede cargar un archivo de algoritmo con formato JSON.",
"override-title": "Anulación de datos de algoritmo",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 65ae7e7acb..c1cf801bb2 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -890,6 +890,8 @@
},
"algorithms": {
"self": "アルゴリズム",
+ "add": "アルゴリズムを追加",
+ "edit": "アルゴリズムを編集",
"upload": "アルゴリズムをアップロード",
"upload-label": "アルゴリズム ファイルを JSON 形式でアップロードできます。",
"override-title": "カバーアルゴリズムデータ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 24a5fdfb0e..38661a9e51 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -890,6 +890,8 @@
},
"algorithms": {
"self": "脱敏算法",
+ "add": "添加算法",
+ "edit": "编辑算法",
"upload": "导入算法",
"upload-label": "您可以上传 JSON 格式的算法文件。",
"override-title": "覆盖算法数据",
@@ -3902,4 +3904,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
+}
\ No newline at end of file