Skip to content

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

chore: show table classification in table detail page (#8672)

ecmadao41a50cc722ed
diff --git a/frontend/src/components/ColumnTable.vue b/frontend/src/components/ColumnTable.vue
index bf253b799a..93d9324031 100644
--- a/frontend/src/components/ColumnTable.vue
+++ b/frontend/src/components/ColumnTable.vue
@@ -52,7 +52,7 @@
</button>
</div>
</BBTableCell>
- <BBTableCell v-if="showSensitiveColumn && isDev()" class="bb-grid-cell">
+ <BBTableCell v-if="showSemanticTypeColumn" class="bb-grid-cell">
<div class="flex items-center">
{{ getColumnSemanticType(column.name)?.title }}
<button
@@ -74,12 +74,10 @@
</div>
</BBTableCell>
<BBTableCell v-if="showClassificationColumn" class="bb-grid-cell">
- <div class="flex items-center">
- <ClassificationLevelBadge
- :classification="column.classification"
- :classification-config="classificationConfig"
- />
- </div>
+ <ClassificationLevelBadge
+ :classification="column.classification"
+ :classification-config="classificationConfig"
+ />
</BBTableCell>
<BBTableCell class="bb-grid-cell">
{{ column.type }}
@@ -410,10 +408,14 @@ const showSensitiveColumn = computed(() => {
);
});
+const showSemanticTypeColumn = computed(() => {
+ return showSensitiveColumn.value && isDev();
+});
+
const showClassificationColumn = computed(() => {
return (
- engine.value === Engine.MYSQL ||
- (engine.value === Engine.POSTGRES && props.classificationConfig)
+ (engine.value === Engine.MYSQL || engine.value === Engine.POSTGRES) &&
+ props.classificationConfig
);
});
@@ -476,18 +478,18 @@ const NORMAL_COLUMN_LIST = computed(() => {
title: t("common.labels"),
},
];
+ if (showSemanticTypeColumn.value) {
+ columnList.splice(1, 0, {
+ title: t("settings.sensitive-data.semantic-types.self"),
+ });
+ }
if (showSensitiveColumn.value) {
- if (isDev()) {
- columnList.splice(1, 0, {
- title: t("settings.sensitive-data.semantic-types.self"),
- });
- }
columnList.splice(1, 0, {
title: t("settings.sensitive-data.masking-level.self"),
});
}
if (showClassificationColumn.value) {
- columnList.splice(showSensitiveColumn.value ? 2 : 1, 0, {
+ columnList.splice(showSemanticTypeColumn.value ? 3 : 2, 0, {
title: t("database.classification.self"),
});
}
@@ -517,18 +519,18 @@ const POSTGRES_COLUMN_LIST = computed(() => {
title: t("common.labels"),
},
];
+ if (showSemanticTypeColumn.value) {
+ columnList.splice(1, 0, {
+ title: t("settings.sensitive-data.semantic-types.self"),
+ });
+ }
if (showSensitiveColumn.value) {
- if (isDev()) {
- columnList.splice(1, 0, {
- title: t("settings.sensitive-data.semantic-types.self"),
- });
- }
columnList.splice(1, 0, {
title: t("settings.sensitive-data.masking-level.self"),
});
}
if (showClassificationColumn.value) {
- columnList.splice(showSensitiveColumn.value ? 2 : 1, 0, {
+ columnList.splice(showSemanticTypeColumn.value ? 3 : 2, 0, {
title: t("database.classification.self"),
});
}
diff --git a/frontend/src/components/LabelEditorDrawer.vue b/frontend/src/components/LabelEditorDrawer.vue
index 2cd894e3e2..f4e6ec2433 100644
--- a/frontend/src/components/LabelEditorDrawer.vue
+++ b/frontend/src/components/LabelEditorDrawer.vue
@@ -2,6 +2,7 @@
<Drawer :show="show" @close="$emit('dismiss')">
<DrawerContent :title="title">
<BBAttention
+ v-if="showWarning"
class="mb-5"
:style="'WARN'"
:title="$t('database.mixed-label-values-warning')"
@@ -151,6 +152,10 @@ const allowSave = computed(() => {
return errors.length === 0;
});
+const showWarning = computed(() => {
+ return state.kvList.some((kv) => !!kv.message);
+});
+
watch(
() => props.labels,
() => {
diff --git a/frontend/src/components/SchemaTemplate/ClassificationLevelBadge.vue b/frontend/src/components/SchemaTemplate/ClassificationLevelBadge.vue
index fc4bd2e019..6db12aef00 100644
--- a/frontend/src/components/SchemaTemplate/ClassificationLevelBadge.vue
+++ b/frontend/src/components/SchemaTemplate/ClassificationLevelBadge.vue
@@ -1,5 +1,5 @@
<template>
- {{ columnClassification?.title }}
+ {{ columnClassification?.title ?? placeholder }}
<span v-if="level" :class="['px-1 py-0.5 rounded text-xs', levelColor]">
{{ level.title }}
</span>
@@ -12,6 +12,7 @@ import { DataClassificationSetting_DataClassificationConfig } from "@/types/prot
const props = defineProps<{
classification?: string;
classificationConfig?: DataClassificationSetting_DataClassificationConfig;
+ placeholder?: string;
}>();
const bgColorList = [
diff --git a/frontend/src/components/TableDetailDrawer.vue b/frontend/src/components/TableDetailDrawer.vue
index 19e27e9718..774ca2569a 100644
--- a/frontend/src/components/TableDetailDrawer.vue
+++ b/frontend/src/components/TableDetailDrawer.vue
@@ -95,12 +95,16 @@
</dd>
</div>
- <div v-if="tableClassification" class="col-span-1">
+ <div v-if="classificationConfig" class="col-span-1">
<dt class="text-sm text-control-light">
{{ $t("database.classification.self") }}
</dt>
<dd class="mt-1 text-lg sm:text-xl font-semibold">
- {{ tableClassification.title }}
+ <ClassificationLevelBadge
+ :classification="table.classification"
+ :classification-config="classificationConfig"
+ placeholder="-"
+ />
</dd>
</div>
@@ -198,13 +202,13 @@ import {
useCurrentUserV1,
useDatabaseV1Store,
useDBSchemaV1Store,
- useSettingV1Store,
} from "@/store";
import { usePolicyByParentAndType } from "@/store/modules/v1/policy";
import { DEFAULT_PROJECT_V1_NAME, EMPTY_PROJECT_NAME } from "@/types";
import { Engine } from "@/types/proto/v1/common";
import { TableMetadata } from "@/types/proto/v1/database_service";
import { PolicyType, MaskData } from "@/types/proto/v1/org_policy_service";
+import { DataClassificationSetting_DataClassificationConfig } from "@/types/proto/v1/setting_service";
import {
bytesToString,
hasWorkspacePermissionV1,
@@ -221,6 +225,7 @@ const props = defineProps<{
databaseName: string;
schemaName: string;
tableName: string;
+ classificationConfig?: DataClassificationSetting_DataClassificationConfig;
}>();
defineEmits(["dismiss"]);
@@ -229,7 +234,6 @@ const router = useRouter();
const databaseV1Store = useDatabaseV1Store();
const dbSchemaStore = useDBSchemaV1Store();
const currentUserV1 = useCurrentUserV1();
-const settingStore = useSettingV1Store();
const table = ref<TableMetadata>();
const database = computed(() => {
@@ -239,19 +243,6 @@ const instanceEngine = computed(() => {
return database.value.instanceEntity.engine;
});
-const classificationConfig = computed(() => {
- return settingStore.getProjectClassification(
- database.value.projectEntity.dataClassificationConfigId
- );
-});
-
-const tableClassification = computed(() => {
- if (!table.value?.classification) {
- return;
- }
- return classificationConfig.value?.classification[table.value.classification];
-});
-
const allowQuery = computed(() => {
if (
database.value.project === EMPTY_PROJECT_NAME ||
diff --git a/frontend/src/components/TableTable.vue b/frontend/src/components/TableTable.vue
index 736a40077f..16fea5be3e 100644
--- a/frontend/src/components/TableTable.vue
+++ b/frontend/src/components/TableTable.vue
@@ -27,6 +27,12 @@
<BBTableCell v-if="hasEngineProperty" class="w-8">
{{ table.engine }}
</BBTableCell>
+ <BBTableCell v-if="hasClassificationProperty" class="w-8">
+ <ClassificationLevelBadge
+ :classification="table.classification"
+ :classification-config="classificationConfig"
+ />
+ </BBTableCell>
<BBTableCell class="w-8">
{{ table.rowCount }}
</BBTableCell>
@@ -62,6 +68,7 @@
:database-name="database.name"
:schema-name="schemaName"
:table-name="state.selectedTableName ?? ''"
+ :classification-config="classificationConfig"
@dismiss="state.selectedTableName = undefined"
/>
</template>
@@ -72,9 +79,10 @@ import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { BBTableColumn } from "@/bbkit";
import EllipsisText from "@/components/EllipsisText.vue";
+import { useSettingV1Store } from "@/store/modules";
import { ComposedDatabase } from "@/types";
-import { TableMetadata } from "@/types/proto/store/database";
import { Engine } from "@/types/proto/v1/common";
+import { TableMetadata } from "@/types/proto/v1/database_service";
import { bytesToString, isGhostTable } from "@/utils";
import TableDetailDrawer from "./TableDetailDrawer.vue";
@@ -103,6 +111,7 @@ const route = useRoute();
const state = reactive<LocalState>({
showReservedTableList: false,
});
+const settingStore = useSettingV1Store();
onMounted(() => {
const table = route.query.table as string;
@@ -111,6 +120,12 @@ onMounted(() => {
}
});
+const classificationConfig = computed(() => {
+ return settingStore.getProjectClassification(
+ props.database.projectEntity.dataClassificationConfigId
+ );
+});
+
const engine = computed(() => props.database.instanceEntity.engine);
const isPostgres = computed(
@@ -127,6 +142,13 @@ const hasSchemaProperty = computed(() => {
);
});
+const hasClassificationProperty = computed(() => {
+ return (
+ (engine.value === Engine.MYSQL || engine.value === Engine.POSTGRES) &&
+ classificationConfig.value
+ );
+});
+
const hasEngineProperty = computed(() => {
return !isPostgres.value;
});
@@ -141,6 +163,9 @@ const columnList = computed(() => {
const ENGINE: BBTableColumn = {
title: t("database.engine"),
};
+ const CLASSIFICATION: BBTableColumn = {
+ title: t("database.classification.self"),
+ };
const ROW_COUNT_EST: BBTableColumn = {
title: t("database.row-count-est"),
};
@@ -161,6 +186,9 @@ const columnList = computed(() => {
if (hasEngineProperty.value) {
columns.push(ENGINE);
}
+ if (hasClassificationProperty.value) {
+ columns.push(CLASSIFICATION);
+ }
columns.push(ROW_COUNT_EST, DATA_SIZE, INDEX_SIZE, COMMENT);
return columns;