Skip to content

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

chore: support classification in table template (#8668)

ecmadaobf530f4f631e
diff --git a/frontend/src/components/Branch/utils.ts b/frontend/src/components/Branch/utils.ts
index 5763de7144..932b6d06f6 100644
--- a/frontend/src/components/Branch/utils.ts
+++ b/frontend/src/components/Branch/utils.ts
@@ -271,6 +271,7 @@ export const transformTableEditToMetadata = (
columns: [],
indexes: [],
foreignKeys: [],
+ classification: tableEdit.classification,
});
for (const column of tableEdit.columnList) {
diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
index e87f30216c..c287a030d9 100644
--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
@@ -8,7 +8,7 @@
>
<template #item="{ item }: { item: SchemaTemplateSetting_FieldTemplate }">
<div class="bb-grid-cell">
- {{ item.category }}
+ {{ item.category || "-" }}
</div>
<div class="bb-grid-cell flex justify-start items-center">
<EngineIcon :engine="item.engine" custom-class="ml-0 mr-1" />
diff --git a/frontend/src/components/SchemaTemplate/SelectClassificationDrawer.vue b/frontend/src/components/SchemaTemplate/SelectClassificationDrawer.vue
index 86c50c29ce..c2a4ba44ac 100644
--- a/frontend/src/components/SchemaTemplate/SelectClassificationDrawer.vue
+++ b/frontend/src/components/SchemaTemplate/SelectClassificationDrawer.vue
@@ -22,6 +22,7 @@
:render-label="renderLabel"
:node-props="nodeProps"
:virtual-scroll="true"
+ :theme-overrides="{ nodeHeight: '21px' }"
/>
</div>
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
index aa086b9ba8..3dc9e09864 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
@@ -72,6 +72,33 @@
</template>
</div>
</div>
+
+ <div v-if="classificationConfig" class="sm:col-span-2 sm:col-start-1">
+ <label for="column-name" class="textlabel">
+ {{ $t("schema-template.classification.self") }}
+ </label>
+ <div class="flex items-center gap-x-2 mt-1">
+ <ClassificationLevelBadge
+ :classification="state.table?.classification"
+ :classification-config="classificationConfig"
+ />
+ <div v-if="allowEdit" class="flex">
+ <button
+ v-if="state.table?.classification"
+ class="w-6 h-6 p-1 hover:bg-control-bg-hover rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"
+ @click.prevent="state.table!.classification = ''"
+ >
+ <heroicons-outline:x class="w-4 h-4" />
+ </button>
+ <button
+ class="w-6 h-6 p-1 hover:bg-control-bg-hover rounded cursor-pointer disabled:cursor-not-allowed disabled:hover:bg-white disabled:text-gray-400"
+ @click.prevent="state.showClassificationDrawer = true"
+ >
+ <heroicons-outline:pencil class="w-4 h-4" />
+ </button>
+ </div>
+ </div>
+ </div>
</div>
<div class="space-y-6 pt-6">
<div class="grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">
@@ -171,6 +198,14 @@
</div>
</DrawerContent>
</Drawer>
+
+ <SelectClassificationDrawer
+ v-if="classificationConfig"
+ :show="state.showClassificationDrawer"
+ :classification-config="classificationConfig"
+ @dismiss="state.showClassificationDrawer = false"
+ @select="onClassificationSelect"
+ />
</template>
<script lang="ts" setup>
@@ -343,4 +378,12 @@ const handleApplyColumnTemplate = (
state.table.columnList.push(column);
state.showFieldTemplateDrawer = false;
};
+
+const onClassificationSelect = (id: string) => {
+ if (!state.table) {
+ return;
+ }
+ state.table.classification = id;
+ state.showClassificationDrawer = false;
+};
</script>
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
index 99ac197b23..80375790e1 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
@@ -8,12 +8,18 @@
>
<template #item="{ item }: { item: SchemaTemplateSetting_TableTemplate }">
<div class="bb-grid-cell">
- {{ item.category }}
+ {{ item.category || "-" }}
</div>
<div class="bb-grid-cell flex justify-start items-center">
<EngineIcon :engine="item.engine" custom-class="ml-0 mr-1" />
{{ item.table?.name }}
</div>
+ <div v-if="classificationConfig" class="bb-grid-cell flex gap-x-1">
+ <ClassificationLevelBadge
+ :classification="item.table?.classification"
+ :classification-config="classificationConfig"
+ />
+ </div>
<div class="bb-grid-cell">
{{ item.table?.comment }}
</div>
@@ -55,6 +61,7 @@ import {
SchemaTemplateSetting,
SchemaTemplateSetting_TableTemplate,
} from "@/types/proto/v1/setting_service";
+import { classificationConfig } from "./utils";
const props = defineProps<{
engine?: Engine;
@@ -71,7 +78,7 @@ const { t } = useI18n();
const settingStore = useSettingV1Store();
const columnList = computed((): BBGridColumn[] => {
- return [
+ const list = [
{
title: t("schema-template.form.category"),
width: "15rem",
@@ -93,6 +100,14 @@ const columnList = computed((): BBGridColumn[] => {
class: "capitalize",
},
];
+ if (classificationConfig.value) {
+ list.splice(2, 0, {
+ title: t("schema-template.classification.self"),
+ width: "auto",
+ class: "capitalize",
+ });
+ }
+ return list;
});
const clickRow = (template: SchemaTemplateSetting_TableTemplate) => {
diff --git a/frontend/src/types/v1/schemaEditor/atomType.ts b/frontend/src/types/v1/schemaEditor/atomType.ts
index 068b27d376..38243915e9 100644
--- a/frontend/src/types/v1/schemaEditor/atomType.ts
+++ b/frontend/src/types/v1/schemaEditor/atomType.ts
@@ -47,6 +47,7 @@ export interface Table {
primaryKey: PrimaryKey;
foreignKeyList: ForeignKey[];
status: Status;
+ classification?: string;
}
export interface Schema {
@@ -95,6 +96,7 @@ export const convertTableMetadataToTable = (
},
foreignKeyList: [],
status,
+ classification: tableMetadata.classification,
};
for (const indexMetadata of tableMetadata.indexes) {