Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): consolidate data masking settings UI to naive-ui (#9469)
Liu Jia09f595f4a67
diff --git a/frontend/src/components/LearnMoreLink.vue b/frontend/src/components/LearnMoreLink.vueindex 3ebf6d8ff7..b4890c45a5 100644--- a/frontend/src/components/LearnMoreLink.vue+++ b/frontend/src/components/LearnMoreLink.vue@@ -6,11 +6,12 @@target="__BLANK">{{ $t("common.learn-more") }}- <heroicons-outline:external-link class="w-4 h-4 ml-1" />+ <ExternalLinkIcon class="w-4 h-4 ml-1" /></a></template><script lang="ts" setup>+import { ExternalLinkIcon } from "lucide-vue-next";import { PropType } from "vue";defineProps({diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vueindex f881fad4e3..f385a9626a 100644--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue@@ -5,17 +5,12 @@><div class="textinfolabel">{{ $t("settings.sensitive-data.global-rules.description") }}- <a- href="https://www.bytebase.com/docs/security/mask-data?source=console"- class="normal-link inline-flex flex-row items-center"- target="_blank"- >- {{ $t("common.learn-more") }}- <heroicons-outline:external-link class="w-4 h-4" />- </a>+ <LearnMoreLink+ url="https://www.bytebase.com/docs/security/mask-data?source=console"+ /></div><div>- <div v-if="state.reorderRules" class="flex items-center space-x-3">+ <div v-if="state.reorderRules" class="flex items-center gap-x-3"><NButton:disabled="state.processing"@click="@@ -35,7 +30,7 @@{{ $t("common.confirm") }}</NButton></div>- <div v-else class="flex items-center space-x-3">+ <div v-else class="flex items-center gap-x-3"><NButtonsecondarytype="primary"@@ -63,39 +58,36 @@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">- <img src="../../assets/illustration/no-data.webp" class="w-52" />- </div>+ <NoData /></div><divv-for="(item, index) in state.maskingRuleItemList":key="item.rule.id"- class="flex items-start space-x-5"+ class="flex items-start gap-x-5 pt-4"><divv-if="item.mode === 'NORMAL' && hasPermission && hasSensitiveDataFeature">- <div v-if="state.reorderRules" class="mt-6 flex flex-col">- <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 !== state.maskingRuleItemList.length - 1"- class="w-6 h-6"- />- </button>+ <div v-if="state.reorderRules" class="pt-2 flex flex-col">+ <MiniActionButton v-if="index > 0" @click="onReorder(item, -1)">+ <ChevronUpIcon class="w-4 h-4" />+ </MiniActionButton>+ <MiniActionButton+ v-if="index !== state.maskingRuleItemList.length - 1"+ @click="onReorder(item, 1)"+ >+ <ChevronDownIcon class="w-4 h-4" />+ </MiniActionButton>+ </div>+ <div v-else class="pt-2">+ <MiniActionButton @click="onEdit(index)">+ <PencilIcon class="w-4 h-4" />+ </MiniActionButton></div>- <button v-else class="mt-7" @click="onEdit(index)">- <heroicons-outline:pencil class="w-4 h-4" />- </button></div>- <div :class="['w-full', item.mode === 'NORMAL' ? '' : 'ml-8']">+ <div :class="['w-full', item.mode === 'NORMAL' ? '' : 'ml-[42px]']"><MaskingRuleConfig:key="`expr-${item.rule.id}`":index="index + 1"@@ -116,6 +108,9 @@</template><script lang="ts" setup>+import { PencilIcon } from "lucide-vue-next";+import { ChevronUpIcon } from "lucide-vue-next";+import { ChevronDownIcon } from "lucide-vue-next";import type { SelectOption } from "naive-ui";import { v4 as uuidv4 } from "uuid";import { computed, reactive, nextTick, onMounted } from "vue";@@ -135,6 +130,9 @@ import {MaskingRulePolicy_MaskingRule,} from "@/types/proto/v1/org_policy_service";import { arraySwap, hasWorkspacePermissionV1 } from "@/utils";+import NoData from "../misc/NoData.vue";+import { MiniActionButton } from "../v2";+import MaskingRuleConfig from "./components/MaskingRuleConfig.vue";import {getClassificationLevelOptions,getEnvironmentIdOptions,diff --git a/frontend/src/components/SensitiveData/GrantAccessDrawer.vue b/frontend/src/components/SensitiveData/GrantAccessDrawer.vueindex caaa783910..6fb67e72df 100644--- a/frontend/src/components/SensitiveData/GrantAccessDrawer.vue+++ b/frontend/src/components/SensitiveData/GrantAccessDrawer.vue@@ -12,20 +12,21 @@<div class="w-full"><p class="mb-2">{{ $t("settings.sensitive-data.action.self") }}</p>- <div class="flex space-x-5">- <BBCheckbox+ <div class="flex space-x-4">+ <NCheckboxv-for="action in ACTIONS":key="action"- :title="+ :checked="state.supportActions.has(action)"+ @update:checked="toggleAction(action, $event)"+ >+ {{$t(`settings.sensitive-data.action.${maskingExceptionPolicy_MaskingException_ActionToJSON(action).toLowerCase()}`)- "- :value="state.supportActions.has(action)"- @toggle="toggleAction(action, $event)"- />+ }}+ </NCheckbox></div></div>@@ -34,10 +35,9 @@{{ $t("settings.sensitive-data.masking-level.self") }}</p><MaskingLevelRadioGroup- :disabled="false"+ :level="state.maskingLevel":level-list="MASKING_LEVELS"- :selected="state.maskingLevel"- @update="state.maskingLevel = $event"+ @update:level="state.maskingLevel = $event"/></div>@@ -90,7 +90,7 @@<script lang="ts" setup>import { groupBy, uniq } from "lodash-es";-import { NButton, NDatePicker } from "naive-ui";+import { NButton, NCheckbox, NDatePicker } from "naive-ui";import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";import { Drawer, DrawerContent } from "@/components/v2";@@ -106,6 +106,8 @@ import {MaskingExceptionPolicy_MaskingException_Action,maskingExceptionPolicy_MaskingException_ActionToJSON,} from "@/types/proto/v1/org_policy_service";+import MaskingLevelRadioGroup from "./components/MaskingLevelRadioGroup.vue";+import SensitiveColumnTable from "./components/SensitiveColumnTable.vue";import { SensitiveColumn } from "./types";import { getExpressionsForSensitiveColumn } from "./utils";diff --git a/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue b/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vueindex b8fe583299..36c2862fa7 100644--- a/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue+++ b/frontend/src/components/SensitiveData/MaskingAlgorithmsView.vue@@ -13,7 +13,7 @@<MaskingAlgorithmsTable:readonly="!hasPermission || !hasSensitiveDataFeature":row-clickable="false"- @on-edit="onEdit"+ @edit="onEdit"/></div></div>@@ -30,17 +30,19 @@ import { NButton } from "naive-ui";import { v4 as uuidv4 } from "uuid";import { computed, reactive } from "vue";import { featureToRef, useCurrentUserV1 } from "@/store";-import { MaskingAlgorithmSetting_Algorithm } from "@/types/proto/v1/setting_service";+import { MaskingAlgorithmSetting_Algorithm as Algorithm } from "@/types/proto/v1/setting_service";import { hasWorkspacePermissionV1 } from "@/utils";+import MaskingAlgorithmsCreateDrawer from "./components/MaskingAlgorithmsCreateDrawer.vue";+import MaskingAlgorithmsTable from "./components/MaskingAlgorithmsTable.vue";interface LocalState {showCreateDrawer: boolean;- pendingEditData: MaskingAlgorithmSetting_Algorithm;+ pendingEditData: Algorithm;}const state = reactive<LocalState>({showCreateDrawer: false,- pendingEditData: MaskingAlgorithmSetting_Algorithm.fromPartial({+ pendingEditData: Algorithm.fromPartial({id: uuidv4(),}),});@@ -55,7 +57,7 @@ const hasPermission = computed(() => {const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");const onCreate = () => {- state.pendingEditData = MaskingAlgorithmSetting_Algorithm.fromPartial({+ state.pendingEditData = Algorithm.fromPartial({id: uuidv4(),});state.showCreateDrawer = true;@@ -65,7 +67,7 @@ const onDrawerDismiss = () => {state.showCreateDrawer = false;};-const onEdit = (data: MaskingAlgorithmSetting_Algorithm) => {+const onEdit = (data: Algorithm) => {state.pendingEditData = data;state.showCreateDrawer = true;};diff --git a/frontend/src/components/SensitiveData/SemanticTypesView.vue b/frontend/src/components/SensitiveData/SemanticTypesView.vueindex 09c3c7e0b8..d655864a8e 100644--- a/frontend/src/components/SensitiveData/SemanticTypesView.vue+++ b/frontend/src/components/SensitiveData/SemanticTypesView.vue@@ -27,9 +27,9 @@:readonly="!hasPermission || !hasSensitiveDataFeature":row-clickable="false":semantic-item-list="state.semanticItemList"- @on-cancel="onCancel"- @on-remove="onRemove"- @on-confirm="onConfirm"+ @cancel="onCancel"+ @remove="onRemove"+ @confirm="onConfirm"/></div></div>@@ -52,6 +52,7 @@ import {} from "@/store";import { SemanticTypeSetting_SemanticType } from "@/types/proto/v1/setting_service";import { hasWorkspacePermissionV1 } from "@/utils";+import SemanticTemplateDrawer from "./components/SemanticTemplateDrawer.vue";import SemanticTypesTable, {SemanticItem,} from "./components/SemanticTypesTable.vue";diff --git a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vueindex 66b9b55c41..9790f5c1e3 100644--- a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue+++ b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue@@ -14,11 +14,11 @@{{ $t("settings.sensitive-data.masking-level.self") }}</h1><MaskingLevelRadioGroup+ :level="state.maskingLevel":level-list="MASKING_LEVELS"- :selected="state.maskingLevel":disabled="!hasPermission || state.processing":effective-masking-level="columnMetadata?.effectiveMaskingLevel"- @update="onMaskingLevelUpdate($event)"+ @update:level="onMaskingLevelUpdate($event)"/></div><div class="w-full">@@ -57,74 +57,79 @@{{ $t("settings.sensitive-data.grant-access") }}</NButton></div>- <BBTable- ref="tableRef"- :column-list="tableHeaderList"+ <BBGrid+ :column-list="gridColumnList":data-source="accessUserList"- :show-header="true"- :left-bordered="true"- :right-bordered="true"- :top-bordered="true"- :bottom-bordered="true"- :compact-section="true":row-clickable="false"+ class="border compact">- <template- #body="{- rowData: item,- row,- }: {- rowData: AccessUser,- row: number,- }"- >- <BBTableCell class="bb-grid-cell">- <div class="flex items-center space-x-2">- <UserAvatar size="SMALL" :user="item.user" />- <div class="flex flex-col">- <router-link- :to="`/users/${item.user.email}`"- class="normal-link"- >- {{ item.user.title }}- </router-link>- <span class="textinfolabel">- {{ item.user.email }}- </span>- </div>+ <template #item="{ item, row }: AccessUserRow">+ <div class="bb-grid-cell gap-x-2">+ <UserAvatar size="SMALL" :user="item.user" />+ <div class="flex flex-col">+ <router-link+ :to="`/users/${item.user.email}`"+ class="normal-link"+ >+ {{ item.user.title }}+ </router-link>+ <span class="textinfolabel">+ {{ item.user.email }}+ </span></div>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <BBCheckbox- :value="+ </div>+ <div class="bb-grid-cell">+ <NCheckbox+ :checked="item.supportActions.has(MaskingExceptionPolicy_MaskingException_Action.EXPORT)":disabled="!hasPermission || state.processing"- @toggle="(checked: boolean) => onAccessControlUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.EXPORT, checked))"+ @update-checked="+ onAccessControlUpdate(row, (item) =>+ toggleAction(+ item,+ MaskingExceptionPolicy_MaskingException_Action.EXPORT,+ $event+ )+ )+ "/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <BBCheckbox- :value="+ </div>+ <div class="bb-grid-cell">+ <NCheckbox+ :checked="item.supportActions.has(MaskingExceptionPolicy_MaskingException_Action.QUERY)":disabled="!hasPermission || state.processing"- @toggle="(checked: boolean) => onAccessControlUpdate(row, (item) => toggleAction(item, MaskingExceptionPolicy_MaskingException_Action.QUERY, checked))"+ @update:checked="+ onAccessControlUpdate(row, (item) =>+ toggleAction(+ item,+ MaskingExceptionPolicy_MaskingException_Action.QUERY,+ $event+ )+ )+ "/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><MaskingLevelDropdown:disabled="!hasPermission || state.processing"- :selected="item.maskingLevel"+ :level="item.maskingLevel":level-list="[MaskingLevel.PARTIAL, MaskingLevel.NONE]"- @update="(level: MaskingLevel) => onAccessControlUpdate(row, (item) => item.maskingLevel = level)"+ @update:level="+ onAccessControlUpdate(+ row,+ (item) => (item.maskingLevel = $event)+ )+ "/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><NDatePicker:value="item.expirationTimestamp"style="width: 100%"@@ -134,17 +139,17 @@:disabled="!hasPermission || state.processing"@update:value="(val: number | undefined) => onAccessControlUpdate(row, (item) => item.expirationTimestamp = val)"/>- </BBTableCell>- <BBTableCell v-if="hasPermission" class="bb-grid-cell">+ </div>+ <div v-if="hasPermission" class="bb-grid-cell"><NPopconfirm @positive-click="onRemove(row)"><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"+ <MiniActionButton+ tag="div":disabled="!hasPermission || state.processing"@click.stop="">- <heroicons-outline:trash class="w-4 h-4" />- </button>+ <TrashIcon class="w-4 h-4" />+ </MiniActionButton></template><div class="whitespace-nowrap">@@ -155,9 +160,9 @@}}</div></NPopconfirm>- </BBTableCell>+ </div></template>- </BBTable>+ </BBGrid></div></div>@@ -173,7 +178,7 @@</DrawerContent><GrantAccessDrawer- v-if="state.showGrantAccessDrawer"+ :show="state.showGrantAccessDrawer":column-list="[props.column]"@dismiss="state.showGrantAccessDrawer = false"/>@@ -181,10 +186,12 @@</template><script lang="ts" setup>-import { NButton, NDatePicker, NPopconfirm } from "naive-ui";+import { TrashIcon } from "lucide-vue-next";+import { NButton, NCheckbox, NDatePicker, NPopconfirm } from "naive-ui";import { computed, reactive, watch, ref } from "vue";import { useI18n } from "vue-i18n";-import type { BBTableColumn } from "@/bbkit/types";+import { BBGrid } from "@/bbkit";+import type { BBGridColumn, BBGridRow } from "@/bbkit/types";import { Drawer, DrawerContent } from "@/components/v2";import {usePolicyV1Store,@@ -207,6 +214,10 @@ import {MaskingExceptionPolicy_MaskingException_Action,} from "@/types/proto/v1/org_policy_service";import { hasWorkspacePermissionV1 } from "@/utils";+import UserAvatar from "../User/UserAvatar.vue";+import GrantAccessDrawer from "./GrantAccessDrawer.vue";+import MaskingLevelDropdown from "./components/MaskingLevelDropdown.vue";+import MaskingLevelRadioGroup from "./components/MaskingLevelRadioGroup.vue";import { SensitiveColumn } from "./types";import { getMaskDataIdentifier, isCurrentColumnException } from "./utils";@@ -218,6 +229,8 @@ interface AccessUser {rawExpression: string;}+type AccessUserRow = BBGridRow<AccessUser>;+interface LocalState {dirty: boolean;processing: boolean;@@ -357,31 +370,37 @@ watch(});-const tableHeaderList = computed(() => {- const list: BBTableColumn[] = [+const gridColumnList = computed(() => {+ const columns: BBGridColumn[] = [{title: t("common.user"),+ width: "minmax(auto, 1fr)",},{title: t("settings.sensitive-data.action.export"),+ width: "auto",},{title: t("settings.sensitive-data.action.query"),+ width: "auto",},{title: t("settings.sensitive-data.masking-level.self"),+ width: "auto",},{title: t("common.expiration"),+ width: "minmax(auto, 1fr)",},];if (hasPermission.value) {// operation.- list.push({+ columns.push({title: "",+ width: "auto",});}- return list;+ return columns;});const onRemove = async (index: number) => {diff --git a/frontend/src/components/SensitiveData/SensitiveColumnView.vue b/frontend/src/components/SensitiveData/SensitiveColumnView.vueindex bb7a03189b..cfc5109805 100644--- a/frontend/src/components/SensitiveData/SensitiveColumnView.vue+++ b/frontend/src/components/SensitiveData/SensitiveColumnView.vue@@ -15,7 +15,7 @@/></div><div class="flex justify-between items-center">- <div class="flex items-center">+ <NInputGroup><ProjectSelect:project="state.selectedProjectUid":include-default-project="true"@@ -39,7 +39,7 @@:database="state.selectedDatabaseUid"@update:database="onDatabaseSelect($event)"/>- </div>+ </NInputGroup><NButtontype="primary":disabled="@@ -77,12 +77,11 @@/><template v-else>- <div class="w-full h-full flex flex-col items-center justify-center">- <img- src="../../assets/illustration/no-data.webp"- class="max-h-[30vh]"- />- </div>+ <NoData+ :img-attrs="{+ class: '!w-auto max-h-[30vh]',+ }"+ /></template></div>@@ -128,9 +127,11 @@<script lang="ts" setup>import { uniq } from "lodash-es";+import { NInputGroup } from "naive-ui";import { computed, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import NoData from "@/components/misc/NoData.vue";import {ProjectSelect,InstanceSelect,@@ -158,6 +159,10 @@ import {PolicyResourceType,} from "@/types/proto/v1/org_policy_service";import { databaseV1Slug, hasWorkspacePermissionV1 } from "@/utils";+import FeatureModal from "../FeatureGuard/FeatureModal.vue";+import GrantAccessDrawer from "./GrantAccessDrawer.vue";+import SensitiveColumnDrawer from "./SensitiveColumnDrawer.vue";+import SensitiveColumnTable from "./components/SensitiveColumnTable.vue";import { SensitiveColumn } from "./types";import { getMaskDataIdentifier, isCurrentColumnException } from "./utils";diff --git a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vueindex c404b2afc3..afb92dab10 100644--- a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue+++ b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsCreateDrawer.vue@@ -10,13 +10,9 @@{{ $t("settings.sensitive-data.algorithms.table.title") }}<span class="text-red-600 mr-2">*</span></label>- <input- v-model="state.title"- required- name="title"- type="text"+ <NInput+ v-model:value="state.title":placeholder="t('settings.sensitive-data.algorithms.table.title')"- class="textfield mt-1 w-full":disabled="state.processing || readonly"/></div>@@ -24,15 +20,11 @@<label for="description" class="textlabel">{{ $t("settings.sensitive-data.algorithms.table.description") }}</label>- <input- v-model="state.description"- required- name="title"- type="text"+ <NInput+ v-model:value="state.description":placeholder="t('settings.sensitive-data.algorithms.table.description')"- class="textfield mt-1 w-full":disabled="state.processing || readonly"/></div>@@ -72,15 +64,12 @@)}}</p>- <input- v-model="state.fullMask.substitution"- required- name="title"- type="text"+ <NInput+ v-model:value="state.fullMask.substitution":placeholder="t('settings.sensitive-data.algorithms.full-mask.substitution')"- class="textfield mt-2 w-full"+ class="mt-2":disabled="state.processing || readonly"/></div>@@ -94,7 +83,7 @@:key="i"class="flex space-x-2 items-center">- <div class="flex-none flex flex-col">+ <div class="flex-none flex flex-col gap-y-1"><label for="slice-start" class="textlabel flex">{{$t(@@ -103,23 +92,20 @@}}<span class="text-red-600 mr-2">*</span></label>- <input+ <NInputNumber:value="slice.start"- required- name="slice-start"- type="number"- min="0"+ :min="0":placeholder="t('settings.sensitive-data.algorithms.range-mask.slice-start')"- class="textfield mt-1 w-20":disabled="state.processing || readonly"- @input="(e: any) => onSliceStartChange(i, Number(e.target.value))"+ style="width: 5rem"+ @update:value="onSliceStartChange(i, $event)"/></div>- <div class="flex-none flex flex-col">+ <div class="flex-none flex flex-col gap-y-1"><label for="slice-end" class="textlabel">{{$t(@@ -128,21 +114,18 @@}}<span class="text-red-600 mr-2">*</span></label>- <input+ <NInputNumber:value="slice.end"- required- name="slice-end"- type="number"- min="1"+ :min="1":placeholder="t('settings.sensitive-data.algorithms.range-mask.slice-end')"- class="textfield mt-1 w-20":disabled="state.processing || readonly"- @input="(e: any) => onSliceEndChange(i, Number(e.target.value))"+ style="width: 5rem"+ @update:value="onSliceEndChange(i, $event)"/></div>- <div class="flex-1 flex flex-col">+ <div class="flex-1 flex flex-col gap-y-1"><label for="substitution" class="textlabel">{{$t(@@ -151,28 +134,23 @@}}<span class="text-red-600 mr-2">*</span></label>- <input- v-model="slice.substitution"- required- name="substitution"- type="text"+ <NInput+ v-model:value="slice.substitution":placeholder="t('settings.sensitive-data.algorithms.range-mask.substitution')"- class="textfield mt-1 w-full":disabled="state.processing || readonly"/></div>- <div class="mt-5">- <button- class="p-1 hover:bg-gray-300 rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"+ <div class="h-[34px] flex flex-row items-center self-end">+ <MiniActionButton:disabled="state.processing || readonly"@click.stop="removeSlice(i)">- <heroicons-outline:trash class="w-4 h-4" />- </button>+ <TrashIcon class="w-4 h-4" />+ </MiniActionButton></div></div><div v-if="rangeMaskErrorMessage" class="text-red-600">@@ -197,15 +175,12 @@$t("settings.sensitive-data.algorithms.md5-mask.salt-label")}}</p>- <input- v-model="state.md5Mask.salt"- required- name="title"- type="text"+ <NInput+ v-model:value="state.md5Mask.salt":placeholder="t('settings.sensitive-data.algorithms.md5-mask.salt')"- class="textfield mt-2 w-full"+ class="mt-2":disabled="state.processing || readonly"/></div>@@ -239,6 +214,8 @@</template><script setup lang="ts">import { cloneDeep } from "lodash-es";+import { TrashIcon } from "lucide-vue-next";+import { NInput, NInputNumber } from "naive-ui";import { computed, watch, reactive } from "vue";import { useI18n } from "vue-i18n";import {@@ -247,14 +224,15 @@ import {RadioGrid,RadioGridOption,RadioGridItem,+ MiniActionButton,} from "@/components/v2";import { pushNotification, useSettingV1Store } from "@/store";import {- MaskingAlgorithmSetting_Algorithm,- MaskingAlgorithmSetting_Algorithm_FullMask,- MaskingAlgorithmSetting_Algorithm_RangeMask,- MaskingAlgorithmSetting_Algorithm_MD5Mask,- MaskingAlgorithmSetting_Algorithm_RangeMask_Slice,+ MaskingAlgorithmSetting_Algorithm as Algorithm,+ MaskingAlgorithmSetting_Algorithm_FullMask as FullMask,+ MaskingAlgorithmSetting_Algorithm_RangeMask as RangeMask,+ MaskingAlgorithmSetting_Algorithm_MD5Mask as MD5Mask,+ MaskingAlgorithmSetting_Algorithm_RangeMask_Slice as RangeMask_Slice,} from "@/types/proto/v1/setting_service";import { MaskingType, getMaskingType } from "./utils";@@ -268,15 +246,15 @@ interface LocalState {maskingType: MaskingType;title: string;description: string;- fullMask: MaskingAlgorithmSetting_Algorithm_FullMask;- rangeMask: MaskingAlgorithmSetting_Algorithm_RangeMask;- md5Mask: MaskingAlgorithmSetting_Algorithm_MD5Mask;+ fullMask: FullMask;+ rangeMask: RangeMask;+ md5Mask: MD5Mask;}const props = defineProps<{show: boolean;readonly: boolean;- algorithm: MaskingAlgorithmSetting_Algorithm;+ algorithm: Algorithm;}>();const emit = defineEmits<{@@ -284,9 +262,9 @@ const emit = defineEmits<{}>();const defaultRangeMask = computed(() =>- MaskingAlgorithmSetting_Algorithm_RangeMask.fromPartial({+ RangeMask.fromPartial({slices: [- MaskingAlgorithmSetting_Algorithm_RangeMask_Slice.fromPartial({+ RangeMask_Slice.fromPartial({start: 0,end: 1,substitution: "*",@@ -300,9 +278,9 @@ const state = reactive<LocalState>({maskingType: "full-mask",title: "",description: "",- fullMask: MaskingAlgorithmSetting_Algorithm_FullMask.fromPartial({}),+ fullMask: FullMask.fromPartial({}),rangeMask: cloneDeep(defaultRangeMask.value),- md5Mask: MaskingAlgorithmSetting_Algorithm_MD5Mask.fromPartial({}),+ md5Mask: MD5Mask.fromPartial({}),});const { t } = useI18n();const settingStore = useSettingV1Store();@@ -322,7 +300,7 @@ const maskingTypeList = computed((): MaskingTypeOption[] => [},]);-const algorithmList = computed((): MaskingAlgorithmSetting_Algorithm[] => {+const algorithmList = computed((): Algorithm[] => {return (settingStore.getSettingByName("bb.workspace.masking-algorithm")?.value?.maskingAlgorithmSettingValue?.algorithms ?? []@@ -335,18 +313,14 @@ watch(state.title = algorithm.title;state.description = algorithm.description;state.maskingType = getMaskingType(algorithm) ?? "full-mask";- state.fullMask =- algorithm.fullMask ??- MaskingAlgorithmSetting_Algorithm_FullMask.fromPartial({});+ state.fullMask = algorithm.fullMask ?? FullMask.fromPartial({});state.rangeMask = algorithm.rangeMask ?? cloneDeep(defaultRangeMask.value);- state.md5Mask =- algorithm.md5Mask ??- MaskingAlgorithmSetting_Algorithm_MD5Mask.fromPartial({});+ state.md5Mask = algorithm.md5Mask ?? MD5Mask.fromPartial({});});-const maskingAlgorithm = computed((): MaskingAlgorithmSetting_Algorithm => {- const result = MaskingAlgorithmSetting_Algorithm.fromPartial({+const maskingAlgorithm = computed((): Algorithm => {+ const result = Algorithm.fromPartial({id: props.algorithm.id,title: state.title,description: state.description,@@ -487,15 +461,13 @@ const onMaskingTypeChange = (maskingType: MaskingType) => {}switch (maskingType) {case "full-mask":- state.fullMask = MaskingAlgorithmSetting_Algorithm_FullMask.fromPartial(- {}- );+ state.fullMask = FullMask.fromPartial({});break;case "range-mask":state.rangeMask = cloneDeep(defaultRangeMask.value);break;case "md5-mask":- state.md5Mask = MaskingAlgorithmSetting_Algorithm_MD5Mask.fromPartial({});+ state.md5Mask = MD5Mask.fromPartial({});break;}state.maskingType = maskingType;@@ -504,7 +476,7 @@ const onMaskingTypeChange = (maskingType: MaskingType) => {const addSlice = () => {const last = state.rangeMask.slices[state.rangeMask.slices.length - 1];state.rangeMask.slices.push(- MaskingAlgorithmSetting_Algorithm_RangeMask_Slice.fromPartial({+ RangeMask_Slice.fromPartial({start: (last?.start ?? -1) + 1,end: (last?.end ?? 0) + 1,substitution: "*",diff --git a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsTable.vue b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsTable.vueindex 2674d86804..2b05eda130 100644--- a/frontend/src/components/SensitiveData/components/MaskingAlgorithmsTable.vue+++ b/frontend/src/components/SensitiveData/components/MaskingAlgorithmsTable.vue@@ -1,89 +1,63 @@<template>- <BBTable- ref="tableRef"- :column-list="tableHeaderList"+ <BBGrid+ :column-list="columnList":data-source="algorithmList"- :show-header="true"- :custom-header="true"- :left-bordered="true"- :right-bordered="true"- :top-bordered="true"- :bottom-bordered="true"- :compact-section="true":row-clickable="rowClickable"- @click-row="(section: number, index: number, _) => $emit('on-select', algorithmList[index].id)"+ class="border compact"+ @click-row="(item: Algorithm) => $emit('select', item.id)">- <template #header>- <BBTableHeaderCell- v-for="header in tableHeaderList"- :key="header.title"- :title="header.title"- />- </template>- <template- #body="{ rowData }: { rowData: MaskingAlgorithmSetting_Algorithm }"- >- <BBTableCell class="bb-grid-cell">- <h3>- {{ rowData.title }}- </h3>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <h3>- {{ rowData.description }}- </h3>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <h3>- {{ getAlgorithmMaskingType(rowData) }}- </h3>- </BBTableCell>- <BBTableCell class="bb-grid-cell w-6">- <div v-if="rowData.id" class="flex justify-end items-center space-x-2">- <button- class="p-1 hover:bg-gray-300 rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"- @click.stop="$emit('on-edit', rowData)"- >- <heroicons-outline:pencil class="w-4 h-4" />- </button>-- <NPopconfirm v-if="!readonly" @positive-click="onRemove(rowData.id)">+ <template #item="{ item }: AlgorithmRow">+ <div class="bb-grid-cell">+ {{ item.title }}+ </div>+ <div class="bb-grid-cell">+ {{ item.description }}+ </div>+ <div class="bb-grid-cell">+ {{ getAlgorithmMaskingType(item) }}+ </div>+ <div class="bb-grid-cell justify-end">+ <template v-if="item.id">+ <MiniActionButton @click.stop="$emit('edit', item)">+ <PencilIcon class="w-4 h-4" />+ </MiniActionButton>+ <NPopconfirm v-if="!readonly" @positive-click="onRemove(item.id)"><template #trigger>- <button- class="p-1 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>+ <MiniActionButton tag="div" @click.stop="">+ <TrashIcon class="w-4 h-4" />+ </MiniActionButton></template>-<div class="whitespace-nowrap">{{ $t("settings.sensitive-data.algorithms.table.delete") }}</div></NPopconfirm>- </div>- </BBTableCell>+ </template>+ </div></template>- </BBTable>+ </BBGrid></template><script lang="ts" setup>+import { PencilIcon, TrashIcon } from "lucide-vue-next";import { NPopconfirm } from "naive-ui";import { computed, onMounted } from "vue";import { useI18n } from "vue-i18n";-import type { BBTableColumn } from "@/bbkit/types";+import type { BBGridColumn, BBGridRow } from "@/bbkit/types";+import { MiniActionButton } from "@/components/v2";import { useSettingV1Store, pushNotification } from "@/store";-import { MaskingAlgorithmSetting_Algorithm } from "@/types/proto/v1/setting_service";+import { MaskingAlgorithmSetting_Algorithm as Algorithm } from "@/types/proto/v1/setting_service";import { getMaskingType } from "./utils";+type AlgorithmRow = BBGridRow<Algorithm>;+defineProps<{readonly: boolean;rowClickable: boolean;}>();defineEmits<{- (event: "on-select", id: string): void;- (event: "on-edit", item: MaskingAlgorithmSetting_Algorithm): void;+ (event: "select", id: string): void;+ (event: "edit", item: Algorithm): void;}>();const { t } = useI18n();@@ -96,35 +70,39 @@ onMounted(async () => {);});-const tableHeaderList = computed(() => {- const list: BBTableColumn[] = [+const columnList = computed(() => {+ const columns: BBGridColumn[] = [{title: t("settings.sensitive-data.algorithms.table.title"),+ width: "1fr",},{title: t("settings.sensitive-data.algorithms.table.description"),+ width: "1fr",},{title: t("settings.sensitive-data.algorithms.table.masking-type"),+ width: "minmax(auto, 14rem)",},{// operationstitle: "",+ width: "auto",},];- return list;+ return columns;});-const rawAlgorithmList = computed((): MaskingAlgorithmSetting_Algorithm[] => {+const rawAlgorithmList = computed((): Algorithm[] => {return (settingStore.getSettingByName("bb.workspace.masking-algorithm")?.value?.maskingAlgorithmSettingValue?.algorithms ?? []);});-const algorithmList = computed((): MaskingAlgorithmSetting_Algorithm[] => {+const algorithmList = computed((): Algorithm[] => {return [- MaskingAlgorithmSetting_Algorithm.fromPartial({+ Algorithm.fromPartial({title: t("settings.sensitive-data.algorithms.default"),description: t("settings.sensitive-data.algorithms.default-desc"),category: "MASK",@@ -133,9 +111,7 @@ const algorithmList = computed((): MaskingAlgorithmSetting_Algorithm[] => {];});-const getAlgorithmMaskingType = (- algorithm: MaskingAlgorithmSetting_Algorithm-) => {+const getAlgorithmMaskingType = (algorithm: Algorithm) => {const maskingType = getMaskingType(algorithm);if (maskingType) {return t(`settings.sensitive-data.algorithms.${maskingType}.self`);diff --git a/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue b/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vueindex 1600c11851..27f556b447 100644--- a/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue+++ b/frontend/src/components/SensitiveData/components/MaskingLevelDropdown.vue@@ -1,53 +1,36 @@<template>- <NDropdown- trigger="click"+ <NSelect+ :value="level":options="options"- :disabled="disabled"- @select="$emit('update', $event)"- >- <div class="flex items-center">- {{- $t(- `settings.sensitive-data.masking-level.${maskingLevelToJSON(- selected- ).toLowerCase()}`- )- }}- <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"- >- <heroicons-solid:chevron-up-down class="w-4 h-auto text-gray-400" />- </button>- </div>- </NDropdown>+ @update:value="$emit('update:level', $event)"+ /></template><script lang="ts" setup>-import { type DropdownOption, NDropdown } from "naive-ui";+import { SelectOption, NSelect } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";const props = defineProps<{- disabled: boolean;- selected: MaskingLevel;+ level: MaskingLevel;levelList: MaskingLevel[];}>();defineEmits<{- (event: "update", level: MaskingLevel): void;+ (event: "update:level", level: MaskingLevel): void;}>();const { t } = useI18n();-const options = computed((): DropdownOption[] => {- return props.levelList.map((level) => ({+const options = computed(() => {+ return props.levelList.map<SelectOption>((level) => ({label: t(`settings.sensitive-data.masking-level.${maskingLevelToJSON(level).toLowerCase()}`),- key: level,+ value: level,}));});</script>diff --git a/frontend/src/components/SensitiveData/components/MaskingLevelRadioGroup.vue b/frontend/src/components/SensitiveData/components/MaskingLevelRadioGroup.vueindex 48bbb761ad..9b5b94940c 100644--- a/frontend/src/components/SensitiveData/components/MaskingLevelRadioGroup.vue+++ b/frontend/src/components/SensitiveData/components/MaskingLevelRadioGroup.vue@@ -1,24 +1,10 @@<template>- <div class="flex space-x-5">- <label- v-for="maskLevel in levelList"- :key="maskLevel"- class="radio space-x-2"- :class="disabled && 'cursor-not-allowed'"- >- <input- :disabled="disabled"- :checked="selected === maskLevel"- :name="maskingLevelToJSON(maskLevel)"- type="radio"- class="btn"- :value="maskLevel"- @input="- () => {- $emit('update', maskLevel);- }- "- />+ <NRadioGroup+ :value="level"+ class="space-x-3"+ @update:value="$emit('update:level', $event)"+ >+ <NRadio v-for="maskLevel in levelList" :key="maskLevel" :value="maskLevel"><span class="text-sm font-medium text-main whitespace-nowrap">{{$t(@@ -43,21 +29,21 @@)}})</span>- </label>- </div>+ </NRadio>+ </NRadioGroup></template><script lang="ts" setup>+import { NRadio, NRadioGroup } from "naive-ui";import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";defineProps<{- disabled: boolean;- selected: MaskingLevel;+ level: MaskingLevel;levelList: MaskingLevel[];effectiveMaskingLevel?: MaskingLevel;}>();defineEmits<{- (event: "update", level: MaskingLevel): void;+ (event: "update:level", level: MaskingLevel): void;}>();</script>diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vueindex 828bf64768..383dfc7d97 100644--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue@@ -1,20 +1,22 @@<template><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">- <NInput- v-if="!readonly"- v-model:value="state.title"- class="!w-64 ml-0.5"- :placeholder="defaultTitle"- type="text"- size="small"- :disabled="disabled"- @input="state.dirty = true"- />- <h3 v-else class="font-medium text-sm text-main py-2">- {{ state.title || defaultTitle }}- </h3>+ <div class="flex-1 space-y-2 overflow-x-hidden overflow-y-auto">+ <div class="flex items-center h-[36px]">+ <NInput+ v-if="!readonly"+ v-model:value="state.title"+ class="!w-64"+ :placeholder="defaultTitle"+ type="text"+ size="small"+ :disabled="disabled"+ @input="state.dirty = true"+ />+ <h3 v-else class="font-medium text-sm text-main">+ {{ state.title || defaultTitle }}+ </h3>+ </div><ExprEditor:expr="state.expr":allow-admin="!readonly"@@ -25,7 +27,7 @@@update="state.dirty = true"/></div>- <div class="space-y-2 py-4">+ <div><h3 class="font-medium text-sm text-main py-2">{{ $t("settings.sensitive-data.masking-level.self") }}</h3>@@ -43,20 +45,24 @@<div v-if="!readonly" class="flex justify-between items-center"><NPopconfirm v-if="allowDelete" @positive-click="$emit('delete')"><template #trigger>- <button- class="flex items-center space-x-1 py-1 px-2 hover:bg-gray-300 rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"+ <NButton+ tag="div"+ size="small"+ style="--n-padding: 0 6px; --n-icon-margin: 4px":disabled="disabled"@click.stop="">- <heroicons-outline:trash class="w-4 h-4" />- <span class="text-sm textlabel">{{ $t("common.delete") }}</span>- </button>+ <template #icon>+ <TrashIcon class="w-3.5 h-3.5" />+ </template>+ {{ $t("common.delete") }}+ </NButton></template><div class="whitespace-nowrap">{{ $t("settings.sensitive-data.global-rules.delete-rule-tip") }}</div></NPopconfirm>- <div class="flex justify-end gap-x-3 ml-auto">+ <div class="flex justify-end gap-x-2 ml-auto"><NButton :disabled="disabled" @click="onCancel">{{ $t("common.cancel") }}</NButton>@@ -73,6 +79,7 @@</template><script lang="ts" setup>+import { TrashIcon } from "lucide-vue-next";import { NSelect, SelectOption, NPopconfirm } from "naive-ui";import { computed, reactive, onMounted, nextTick } from "vue";import { useI18n } from "vue-i18n";diff --git a/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue b/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vueindex 3a07d1de7a..71e2737265 100644--- a/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue+++ b/frontend/src/components/SensitiveData/components/SemanticTemplateDrawer.vue@@ -3,12 +3,12 @@<DrawerContent:title="$t('settings.sensitive-data.semantic-types.add-from-template')">- <div class="w-[40rem]">+ <div class="w-[42rem]"><SemanticTypesTable:readonly="true":row-clickable="true":semantic-item-list="semanticTemplateList"- @on-select="onApply($event)"+ @select="onApply($event)"/></div><template #footer>diff --git a/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue b/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vueindex 9141c3e4c9..ae509f4ce4 100644--- a/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue+++ b/frontend/src/components/SensitiveData/components/SemanticTypesDrawer.vue@@ -6,7 +6,7 @@:readonly="true":row-clickable="true":semantic-item-list="semanticItemList"- @on-select="onApply($event)"+ @select="onApply($event)"/></div><template #footer>diff --git a/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue b/frontend/src/components/SensitiveData/components/SemanticTypesTable.vueindex ce57966e29..a04299132a 100644--- a/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue+++ b/frontend/src/components/SensitiveData/components/SemanticTypesTable.vue@@ -1,33 +1,21 @@<template>- <BBTable- ref="tableRef"- :column-list="tableHeaderList"+ <BBGrid+ :column-list="columnList":data-source="semanticItemList"- :show-header="true"- :custom-header="true"- :left-bordered="true"- :right-bordered="true"- :top-bordered="true"- :bottom-bordered="true"- :compact-section="true":row-clickable="rowClickable"- @click-row="(section: number, index: number, _) => $emit('on-select', semanticItemList[index].item.id)"+ class="border compact"+ @click-row="+ (item: SemanticItem) => $emit('select', item.item.id)+ ">- <template #header>- <BBTableHeaderCell- v-for="header in tableHeaderList"- :key="header.title"- :title="header.title"- />- </template>- <template #body="{ rowData, row }: { rowData: SemanticItem, row: number }">- <BBTableCell class="bb-grid-cell">- <h3 v-if="rowData.mode === 'NORMAL'">- {{ rowData.item.title }}+ <template #item="{ item, row }: SemanticItemRow">+ <div class="bb-grid-cell">+ <h3 v-if="item.mode === 'NORMAL'" class="break-normal">+ {{ item.item.title }}</h3><NInputv-else- :value="rowData.item.title"+ :value="item.item.title"size="small"type="text":placeholder="@@ -35,14 +23,14 @@"@input="(val: string) => onInput(row, (data) => data.item.title = val)"/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <h3 v-if="rowData.mode === 'NORMAL'">- {{ rowData.item.description }}+ </div>+ <div class="bb-grid-cell">+ <h3 v-if="item.mode === 'NORMAL'">+ {{ item.item.description }}</h3><NInputv-else- :value="rowData.item.description"+ :value="item.item.description"size="small"type="text":placeholder="@@ -50,103 +38,100 @@"@input="(val: string) => onInput(row, (data) => data.item.description = val)"/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <h3 v-if="rowData.mode === 'NORMAL'">+ </div>+ <div class="bb-grid-cell">+ <h3 v-if="item.mode === 'NORMAL'">{{- getAlgorithmById(rowData.item.fullMaskAlgorithmId)?.label ??+ getAlgorithmById(item.item.fullMaskAlgorithmId)?.label ??$t("settings.sensitive-data.algorithms.default")}}</h3><NSelectv-else- :value="rowData.item.fullMaskAlgorithmId"- clearable+ :value="item.item.fullMaskAlgorithmId":options="algorithmList":consistent-menu-width="false":placeholder="$t('settings.sensitive-data.algorithms.default')"- size="small":fallback-option="(_: string) => ({ label: $t('settings.sensitive-data.algorithms.default'), value: '' })"+ clearable+ size="small"style="min-width: 7rem; width: auto; overflow-x: hidden"- @update:value="(val: string) => onInput(row, (data) => data.item.fullMaskAlgorithmId = val)"+ @update:value="+ onInput(row, (data) => (data.item.fullMaskAlgorithmId = $event))+ "/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">- <h3 v-if="rowData.mode === 'NORMAL'">+ </div>+ <div class="bb-grid-cell">+ <h3 v-if="item.mode === 'NORMAL'">{{- getAlgorithmById(rowData.item.partialMaskAlgorithmId)?.label ??+ getAlgorithmById(item.item.partialMaskAlgorithmId)?.label ??$t("settings.sensitive-data.algorithms.default")}}</h3><NSelectv-else- :value="rowData.item.partialMaskAlgorithmId"- clearable+ :value="item.item.partialMaskAlgorithmId":options="algorithmList":consistent-menu-width="false":placeholder="$t('settings.sensitive-data.algorithms.default')":fallback-option="(_: string) => ({ label: $t('settings.sensitive-data.algorithms.default'), value: '' })"+ clearablesize="small"style="min-width: 7rem; width: auto; overflow-x: hidden"- @update:value="(val: string) => onInput(row, (data) => data.item.partialMaskAlgorithmId = val)"+ @update:value="+ onInput(row, (data) => (data.item.partialMaskAlgorithmId = $event))+ "/>- </BBTableCell>- <BBTableCell v-if="!props.readonly" class="bb-grid-cell w-6">- <div class="flex justify-end items-center space-x-2">- <NPopconfirm- v-if="rowData.mode === 'EDIT'"- @positive-click="$emit('on-remove', row)"- >- <template #trigger>- <button- class="p-1 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.semantic-types.table.delete") }}- </div>- </NPopconfirm>-- <NButton- v-if="rowData.mode !== 'NORMAL'"- size="small"- @click="$emit('on-cancel', row)"- >- {{ $t("common.cancel") }}- </NButton>- <NButton- v-if="rowData.mode !== 'NORMAL'"- type="primary"- :disabled="isConfirmDisabled(rowData)"- size="small"- @click.stop="$emit('on-confirm', row)"- >- {{ $t("common.confirm") }}- </NButton>-- <button- v-if="rowData.mode === 'NORMAL'"- class="p-1 hover:bg-gray-300 rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"- @click.stop="rowData.mode = 'EDIT'"- >- <heroicons-outline:pencil class="w-4 h-4" />- </button>- </div>- </BBTableCell>+ </div>+ <div v-if="!props.readonly" class="bb-grid-cell justify-end">+ <NPopconfirm+ v-if="item.mode === 'EDIT'"+ @positive-click="$emit('remove', row)"+ >+ <template #trigger>+ <MiniActionButton tag="div" @click.stop="">+ <TrashIcon class="w-4 h-4" />+ </MiniActionButton>+ </template>+ <div class="whitespace-nowrap">+ {{ $t("settings.sensitive-data.semantic-types.table.delete") }}+ </div>+ </NPopconfirm>++ <MiniActionButton+ v-if="item.mode !== 'NORMAL'"+ @click="$emit('cancel', row)"+ >+ <Undo2Icon class="w-4 h-4" />+ </MiniActionButton>+ <MiniActionButton+ v-if="item.mode !== 'NORMAL'"+ type="primary"+ :disabled="isConfirmDisabled(item)"+ @click.stop="$emit('confirm', row)"+ >+ <CheckIcon class="w-4 h-4" />+ </MiniActionButton>++ <MiniActionButton+ v-if="item.mode === 'NORMAL'"+ @click.stop="item.mode = 'EDIT'"+ >+ <PencilIcon class="w-4 h-4" />+ </MiniActionButton>+ </div></template>- </BBTable>+ </BBGrid></template><script lang="ts" setup>-import { NPopconfirm, NButton, NSelect, NInput } from "naive-ui";+import { CheckIcon, PencilIcon, TrashIcon, Undo2Icon } from "lucide-vue-next";+import { NPopconfirm, NSelect, NInput } from "naive-ui";import type { SelectOption } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";-import type { BBTableColumn } from "@/bbkit/types";+import type { BBGridColumn, BBGridRow } from "@/bbkit/types";+import { MiniActionButton } from "@/components/v2";import { useSettingV1Store } from "@/store";import { SemanticTypeSetting_SemanticType } from "@/types/proto/v1/setting_service";@@ -158,6 +143,8 @@ export interface SemanticItem {item: SemanticTypeSetting_SemanticType;}+type SemanticItemRow = BBGridRow<SemanticItem>;+const props = defineProps<{readonly: boolean;semanticItemList: SemanticItem[];@@ -165,41 +152,46 @@ const props = defineProps<{}>();defineEmits<{- (event: "on-select", id: string): void;- (event: "on-remove", index: number): void;- (event: "on-cancel", index: number): void;- (event: "on-confirm", index: number): void;+ (event: "select", id: string): void;+ (event: "remove", index: number): void;+ (event: "cancel", index: number): void;+ (event: "confirm", index: number): void;}>();const { t } = useI18n();const settingStore = useSettingV1Store();-const tableHeaderList = computed(() => {- const list: BBTableColumn[] = [+const columnList = computed(() => {+ const columns: BBGridColumn[] = [{title: t("settings.sensitive-data.semantic-types.table.semantic-type"),+ width: "1fr",},{title: t("settings.sensitive-data.semantic-types.table.description"),+ width: "1fr",},{title: t("settings.sensitive-data.semantic-types.table.full-masking-algorithm"),+ width: "minmax(auto, 12rem)",},{title: t("settings.sensitive-data.semantic-types.table.partial-masking-algorithm"),+ width: "minmax(auto, 12rem)",},];if (!props.readonly) {// operation.- list.push({+ columns.push({title: "",+ width: "minmax(auto, 5rem)",});}- return list;+ return columns;});const onInput = (index: number, callback: (item: SemanticItem) => void) => {diff --git a/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue b/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vueindex 02526709d8..0387a90b34 100644--- a/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue+++ b/frontend/src/components/SensitiveData/components/SensitiveColumnTable.vue@@ -1,133 +1,113 @@<template>- <BBTable- ref="tableRef"- :column-list="tableHeaderList"+ <BBGrid+ :column-list="gridColumnList":data-source="columnList"- :show-header="true"- :custom-header="true"- :left-bordered="true"- :right-bordered="true"- :top-bordered="true"- :bottom-bordered="true"- :compact-section="true":row-clickable="rowClickable"+ :custom-header="true"+ class="bordered"@click-row="clickTableRow"><template #header>- <th- v-for="(column, index) in tableHeaderList"- :key="index"- scope="col"- class="pl-2 py-2 text-left text-xs font-medium text-gray-500 tracking-wider capitalize"- :class="[column.center && 'text-center pr-2']"- >- <template v-if="index === 0 && rowSelectable">- <input- v-if="columnList.length > 0"- type="checkbox"- class="ml-2 h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"- :checked="allSelectionState.checked"- :indeterminate="allSelectionState.indeterminate"- :disabled="false"- @input="selectAll(($event.target as HTMLInputElement).checked)"- />- </template>- <template v-else>{{ $t(column.title) }}</template>- </th>+ <div role="table-row" class="bb-grid-row bb-grid-header-row group">+ <div+ v-for="(column, index) in gridColumnList"+ :key="index"+ role="table-cell"+ class="bb-grid-header-cell capitalize"+ :class="[column.class]"+ >+ <template v-if="index === 0 && rowSelectable">+ <NCheckbox+ v-if="columnList.length > 0"+ :checked="allSelectionState.checked"+ :indeterminate="allSelectionState.indeterminate"+ @update:checked="toggleSelectAll"+ />+ </template>+ <template v-else>{{ column.title }}</template>+ </div>+ </div></template>- <template- #body="{ rowData: item, row }: { rowData: SensitiveColumn, row: number }"- >- <BBTableCell v-if="rowSelectable" class="w-[1%]">- <!-- width: 1% means as narrow as possible -->- <input- type="checkbox"- class="ml-2 h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"+ <template #item="{ item, row }: SensitiveColumnRow">+ <div v-if="rowSelectable" class="bb-grid-cell" @click.stop.prevent>+ <NCheckbox:checked="checkedColumnIndex.has(row)"- @click.stop=""- @input="- toggleColumnChecked(- row,- ($event.target as HTMLInputElement).checked,- $event- )- "+ @update:checked="toggleColumnChecked(row, $event)"/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell">{{ getMaskingLevelText(item.maskData.maskingLevel) }}- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell">{{ item.maskData.column }}- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell">{{item.maskData.schema? `${item.maskData.schema}.${item.maskData.table}`: item.maskData.table}}- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><DatabaseV1Name :database="item.database" :link="false" />- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><InstanceV1Name:instance="item.database.instanceEntity":link="false"/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><EnvironmentV1Name:environment="item.database.effectiveEnvironmentEntity":link="false"/>- </BBTableCell>- <BBTableCell class="bb-grid-cell">+ </div>+ <div class="bb-grid-cell"><ProjectV1Name :project="item.database.projectEntity" :link="false" />- </BBTableCell>- <BBTableCell- v-if="showOperation"- class="bb-grid-cell justify-center !px-2 space-x-2"- >- <button- class="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="$emit('click', item, row, 'EDIT')"+ </div>+ <div v-if="showOperation" class="bb-grid-cell" @click.stop.prevent>+ <MiniActionButton+ @click.stop.prevent="$emit('click', item, row, 'EDIT')">- <heroicons-outline:pencil class="w-4 h-4" />- </button>+ <PencilIcon class="w-4 h-4" />+ </MiniActionButton><NPopconfirm @positive-click="$emit('click', item, row, 'DELETE')"><template #trigger>- <button- class="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>+ <MiniActionButton tag="div" @click.stop.prevent>+ <TrashIcon class="w-4 h-4" />+ </MiniActionButton></template><div class="whitespace-nowrap">{{ $t("settings.sensitive-data.remove-sensitive-column-tips") }}</div></NPopconfirm>- </BBTableCell>+ </div></template>- </BBTable>+ </BBGrid></template><script lang="ts" setup>-import { NPopconfirm } from "naive-ui";+import { PencilIcon } from "lucide-vue-next";+import { TrashIcon } from "lucide-vue-next";+import { NCheckbox, NPopconfirm } from "naive-ui";import { computed, ref, watch } from "vue";import { useI18n } from "vue-i18n";-import type { BBTableColumn } from "@/bbkit/types";+import { BBGrid } from "@/bbkit";+import type { BBGridColumn, BBGridRow } from "@/bbkit/types";import {DatabaseV1Name,EnvironmentV1Name,InstanceV1Name,+ MiniActionButton,ProjectV1Name,} from "@/components/v2";import { MaskingLevel, maskingLevelToJSON } from "@/types/proto/v1/common";import { SensitiveColumn } from "../types";+type SensitiveColumnRow = BBGridRow<SensitiveColumn>;+const props = defineProps<{showOperation: boolean;rowClickable: boolean;@@ -167,10 +147,7 @@ const getMaskingLevelText = (maskingLevel: MaskingLevel) => {return t(`settings.sensitive-data.masking-level.${level.toLowerCase()}`);};-const toggleColumnChecked = (index: number, on: boolean, e: Event) => {- e.preventDefault();- e.stopPropagation();-+const toggleColumnChecked = (index: number, on: boolean) => {if (on) {checkedColumnIndex.value.add(index);} else {@@ -180,41 +157,51 @@ const toggleColumnChecked = (index: number, on: boolean, e: Event) => {emit("checked:update", [...checkedColumnIndex.value]);};-const tableHeaderList = computed(() => {- const list: BBTableColumn[] = [+const gridColumnList = computed(() => {+ const columns: BBGridColumn[] = [{title: t("settings.sensitive-data.masking-level.self"),+ width: "minmax(auto, 8rem)",},{title: t("database.column"),+ width: "minmax(auto, 1fr)",},{title: t("common.table"),+ width: "minmax(auto, 1fr)",},{title: t("common.database"),+ width: "minmax(auto, 1fr)",},{title: t("common.instance"),+ width: "minmax(auto, 1fr)",},{title: t("common.environment"),+ width: "minmax(auto, 1fr)",},{title: t("common.project"),+ width: "minmax(auto, 1fr)",},];if (props.showOperation) {- list.push({+ columns.push({title: t("common.operation"),+ width: "auto",});}if (props.rowSelectable) {- list.unshift({+ columns.unshift({title: "",+ width: "auto",});}- return list;++ return columns;});const allSelectionState = computed(() => {@@ -231,7 +218,7 @@ const allSelectionState = computed(() => {};});-const selectAll = (check: boolean): void => {+const toggleSelectAll = (check: boolean): void => {if (!check) {checkedColumnIndex.value = new Set([]);} else {@@ -240,7 +227,7 @@ const selectAll = (check: boolean): void => {emit("checked:update", [...checkedColumnIndex.value]);};-const clickTableRow = function (_: number, row: number) {- emit("click", props.columnList[row], row, "VIEW");+const clickTableRow = function (item: SensitiveColumn, _: number, row: number) {+ emit("click", item, row, "VIEW");};</script>