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: use NDataTable instead of BBTable (#16271)
boojack514aa133250c
diff --git a/CLAUDE.md b/CLAUDE.mdindex 32ca4f74c3..4e148d5dbe 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -14,6 +14,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co- Frontend install: `pnpm --dir frontend i`- Frontend dev: `pnpm --dir frontend dev`- Frontend lint: `pnpm --dir frontend lint`+- Frontend lint fix: `pnpm --dir frontend lint --fix` - Please run this before committing to ensure code quality if changes are made in the frontend code.- Frontend type check: `pnpm --dir frontend type-check`- Frontend test: `pnpm --dir frontend test`- Proto lint: `cd proto && buf lint`diff --git a/frontend/src/bbkit/BBTable/BBTable.vue b/frontend/src/bbkit/BBTable/BBTable.vuedeleted file mode 100644index 6b93c03eb0..0000000000--- a/frontend/src/bbkit/BBTable/BBTable.vue+++ /dev/null@@ -1,181 +0,0 @@-<template>- <table- class="min-w-full divide-y divide-block-border"- :class="borderVisibility"- >- <thead v-if="showHeader && !sectionDataSource" class="bg-gray-50">- <template v-if="customHeader">- <!-- different implements for legacy compatibility -->- <slot name="header" />- </template>- <tr v-else>- <th- v-for="(column, index) in columnList"- :key="index"- scope="col"- class="py-2 text-left text-xs font-medium text-gray-500 tracking-wider"- :class="[- headerClass,- index == 0 ? 'pl-4' : 'pl-2',- column.center && 'text-center pr-2',- column.nowrap && 'whitespace-nowrap',- ]"- >- {{ column.title }}- </th>- </tr>- </thead>-- <template v-if="sectionDataSource">- <template v-for="(section, i) in sectionDataSource" :key="i">- <tbody class="bg-normal divide-y divide-block-border">- <th- v-if="!compactSection || sectionDataSource.length > 1"- :colspan="columnList.length"- class="text-left pl-4 pt-4 pb-2 py-text-base leading-6 font-medium text-gray-900"- >- <slot name="sectionHeader" :section="section">- <template v-if="section.link">- <router-link :to="section.link" class="normal-link">- {{ section.title }}- </router-link>- </template>- <template v-else>- {{ section.title }}- </template>- </slot>- </th>- <template v-if="section.list.length > 0">- <tr v-if="showHeader" class="bg-gray-50">- <slot name="header" />- </tr>- <tr- v-for="(item, j) in section.list"- :key="j"- :class="rowClickable ? 'cursor-pointer hover:bg-gray-200' : ''"- @click.stop="- (e) => {- if (rowClickable) {- $emit('click-row', i, j, e);- }- }- "- >- <slot name="body" :row-data="item" :section="i" :row="j" />- </tr>- </template>- <template v-else>- <tr v-if="showPlaceholder">- <td- :colspan="columnList.length"- class="text-center text-gray-400"- >- <slot name="placeholder">- <p class="py-8">{{ $t("common.no-data") }}</p>- </slot>- </td>- </tr>- </template>- </tbody>- </template>- </template>- <template v-else>- <tbody class="bg-normal divide-y divide-block-border">- <template v-if="dataSource.length > 0">- <tr- v-for="(item, index) in dataSource"- :key="index"- :class="rowClickable ? 'cursor-pointer hover:bg-gray-200' : ''"- @click.stop="- (e) => {- if (rowClickable) {- $emit('click-row', 0, index, e);- }- }- "- >- <slot name="body" :row-data="item" :row="index" />- </tr>- </template>- <template v-else>- <tr v-if="showPlaceholder">- <td :colspan="columnList.length" class="text-center text-gray-400">- <slot name="placeholder">- <p class="py-8">{{ $t("common.no-data") }}</p>- </slot>- </td>- </tr>- </template>- </tbody>- </template>- <slot name="footer" />- </table>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import type { VueClass } from "@/utils";-import type { BBTableColumn, BBTableSectionDataSource } from "../types";--type DataType = any; // vue does not support generic typed components yet--const props = withDefaults(- defineProps<{- columnList?: BBTableColumn[];- dataSource?: DataType[];- sectionDataSource?: BBTableSectionDataSource<DataType>[] | undefined;- // Only applicable to sectionDataSource. If true, when there is only one- // section, it won't render the extra section header. In another words, it will- // just look like a non-section list.- compactSection?: boolean;- showHeader?: boolean;- customHeader?: boolean;- headerClass?: VueClass;- rowClickable?: boolean;- leftBordered?: boolean;- rightBordered?: boolean;- topBordered?: boolean;- bottomBordered?: boolean;- showPlaceholder?: boolean;- }>(),- {- columnList: () => [],- dataSource: () => [],- sectionDataSource: undefined,- compactSection: false,- showHeader: true,- customHeader: false,- headerClass: undefined,- rowClickable: true,- leftBordered: true,- rightBordered: true,- topBordered: true,- bottomBordered: true,- showPlaceholder: true,- }-);--defineEmits<{- (event: "click-row", section: number, row: number, e: MouseEvent): void;-}>();--const borderVisibility = computed(() => {- const style = [];- if (props.leftBordered) {- style.push("border-l");- }-- if (props.rightBordered) {- style.push("border-r");- }-- if (props.topBordered) {- style.push("border-t");- }-- if (props.bottomBordered) {- style.push("border-b");- }- return style.join(" ");-});-</script>diff --git a/frontend/src/bbkit/BBTable/BBTableCell.vue b/frontend/src/bbkit/BBTable/BBTableCell.vuedeleted file mode 100644index 694009f28d..0000000000--- a/frontend/src/bbkit/BBTable/BBTableCell.vue+++ /dev/null@@ -1,32 +0,0 @@-<template>- <td class="table-cell text-sm leading-5 max-w-prose" :class="classNames">- <slot />- </td>-</template>--<script lang="ts" setup>-import { computed } from "vue";--const props = withDefaults(- defineProps<{- leftPadding?: number;- rightPadding?: number;- compact?: boolean;- }>(),- {- leftPadding: 2,- rightPadding: 2,- compact: false,- }-);--const classNames = computed((): string[] => {- const classNames: string[] = [];- if (!props.compact) {- classNames.push(`pl-${props.leftPadding}`);- classNames.push(`pr-${props.rightPadding}`);- classNames.push("py-2");- }- return classNames;-});-</script>diff --git a/frontend/src/bbkit/BBTable/BBTableHeaderCell.vue b/frontend/src/bbkit/BBTable/BBTableHeaderCell.vuedeleted file mode 100644index d1d0347296..0000000000--- a/frontend/src/bbkit/BBTable/BBTableHeaderCell.vue+++ /dev/null@@ -1,35 +0,0 @@-<template>- <th- scope="col"- class="table-cell text-left text-xs font-medium text-gray-500 tracking-wider"- :class="classNames"- >- <slot>{{ title }}</slot>- </th>-</template>--<script lang="ts" setup>-import { computed } from "vue";--const props = withDefaults(- defineProps<{- title?: string;- leftPadding?: number;- compact?: boolean;- }>(),- {- title: "",- leftPadding: 2,- compact: false,- }-);--const classNames = computed((): string[] => {- const classNames: string[] = [];- if (!props.compact) {- classNames.push(`pl-${props.leftPadding}`);- classNames.push("py-2");- }- return classNames;-});-</script>diff --git a/frontend/src/bbkit/BBTable/index.ts b/frontend/src/bbkit/BBTable/index.tsdeleted file mode 100644index 6cfdf2d3eb..0000000000--- a/frontend/src/bbkit/BBTable/index.ts+++ /dev/null@@ -1,5 +0,0 @@-import BBTable from "./BBTable.vue";-import BBTableCell from "./BBTableCell.vue";-import BBTableHeaderCell from "./BBTableHeaderCell.vue";--export { BBTable, BBTableCell, BBTableHeaderCell };diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.tsindex 309de6d04c..8c61a97b11 100644--- a/frontend/src/bbkit/index.ts+++ b/frontend/src/bbkit/index.ts@@ -7,7 +7,6 @@ import BBButtonConfirm from "./BBButtonConfirm.vue";import { BBGrid } from "./BBGrid";import BBModal from "./BBModal.vue";import BBSpin from "./BBSpin.vue";-import { BBTable, BBTableCell, BBTableHeaderCell } from "./BBTable";import BBTextField from "./BBTextField.vue";export * from "./types";@@ -19,9 +18,6 @@ export {BBButtonConfirm,BBModal,BBSpin,- BBTable,- BBTableCell,- BBTableHeaderCell,BBGrid,BBTextField,BBBadge,diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.tsindex 59fb44d2dc..e381aa357f 100644--- a/frontend/src/bbkit/types.ts+++ b/frontend/src/bbkit/types.ts@@ -10,12 +10,6 @@ export type BBButtonType =export type BBButtonConfirmType = "NORMAL" | "DELETE" | "ARCHIVE" | "RESTORE";-export type BBTableColumn = {- title: string;- center?: boolean;- nowrap?: boolean;-};-export type BBGridColumn = {title?: string;width: ColumnWidth;@@ -27,12 +21,6 @@ export type BBGridRow<T = any> = {row: number;};-export type BBTableSectionDataSource<T> = {- title: string;- link?: string;- list: T[];-};-export type BBTabItem<T = any> = {title: string;// Used as the anchordiff --git a/frontend/src/components/IndexTable.vue b/frontend/src/components/IndexTable.vueindex 325800be4f..b1d8ed29bd 100644--- a/frontend/src/components/IndexTable.vue+++ b/frontend/src/components/IndexTable.vue@@ -1,59 +1,24 @@<template>- <BBTable- :column-list="columnList"- :section-data-source="sectionList"- :show-header="true"- :compact-section="false"- >- <template #header>- <BBTableHeaderCell- :left-padding="4"- class="w-16"- :title="columnList[0].title"- />- <BBTableHeaderCell- v-if="showPositionColumn"- class="w-4"- :title="columnList[1].title"- />- <BBTableHeaderCell class="w-4" :title="columnList[2].title" />- <BBTableHeaderCell- v-if="showVisibleColumn"- class="w-4"- :title="columnList[3].title"- />- <BBTableHeaderCell- v-if="showCommentColumn"- class="w-16"- :title="columnList[4].title"- />- </template>- <template #body="{ rowData: index }">- <BBTableCell :left-padding="4">- {{ index.expressions.join(",") }}- </BBTableCell>- <BBTableCell v-if="showPositionColumn">- {{ index.position }}- </BBTableCell>- <BBTableCell>- {{ index.unique }}- </BBTableCell>- <BBTableCell v-if="showVisibleColumn">- {{ index.visible }}- </BBTableCell>- <BBTableCell v-if="showCommentColumn">- {{ index.comment }}- </BBTableCell>- </template>- </BBTable>+ <div v-for="(section, sectionIndex) in sectionList" :key="sectionIndex">+ <h3 class="text-left pl-4 pt-4 pb-2 text-base font-medium text-gray-900">+ {{ section.title }}+ </h3>+ <NDataTable+ size="small"+ :columns="columns"+ :data="section.list"+ :striped="true"+ :bordered="true"+ />+ </div></template><script lang="ts" setup>+import type { DataTableColumn } from "naive-ui";+import { NDataTable } from "naive-ui";import type { PropType } from "vue";import { computed } from "vue";import { useI18n } from "vue-i18n";-import { BBTable, BBTableCell, BBTableHeaderCell } from "@/bbkit";-import type { BBTableSectionDataSource } from "@/bbkit/types";import type { ComposedDatabase } from "@/types";import { Engine } from "@/types/proto/v1/common";import type { IndexMetadata } from "@/types/proto/v1/database_service";@@ -76,44 +41,58 @@ const showVisibleColumn = computed(() => {props.database.instanceResource.engine !== Engine.MONGODB);});-const showPositionColumn = computed(() => {- return props.database.instanceResource.engine !== Engine.MONGODB;-});const showCommentColumn = computed(() => {return props.database.instanceResource.engine !== Engine.MONGODB;});-const columnList = computed(() => [- {- title: t("database.expression"),- },- {- title: t("database.position"),- },- {+const columns = computed((): DataTableColumn<IndexMetadata>[] => {+ const cols: DataTableColumn<IndexMetadata>[] = [+ {+ title: t("database.expression"),+ key: "expressions",+ render: (row) => row.expressions.join(","),+ },+ ];++ cols.push({title: t("database.unique"),- },- {- title: t("database.visible"),- },- {- title: t("database.comment"),- },-]);+ key: "unique",+ render: (row) => String(row.unique),+ });++ if (showVisibleColumn.value) {+ cols.push({+ title: t("database.visible"),+ key: "visible",+ render: (row) => String(row.visible),+ });+ }++ if (showCommentColumn.value) {+ cols.push({+ title: t("database.comment"),+ key: "comment",+ render: (row) => row.comment || "-",+ });+ }++ return cols;+});+const sectionList = computed(() => {- const sectionList: BBTableSectionDataSource<IndexMetadata>[] = [];+ const sections: { title: string; list: IndexMetadata[] }[] = [];for (const index of props.indexList) {- const item = sectionList.find((item) => item.title == index.name);+ const item = sections.find((item) => item.title == index.name);if (item) {item.list.push(index);} else {- sectionList.push({+ sections.push({title: index.name,list: [index],});}}- return sectionList;+ return sections;});</script>diff --git a/frontend/src/components/StreamTable.vue b/frontend/src/components/StreamTable.vueindex c5ece2c72b..f5596bbdb5 100644--- a/frontend/src/components/StreamTable.vue+++ b/frontend/src/components/StreamTable.vue@@ -1,41 +1,19 @@<template>- <BBTable- :column-list="columnList"- :data-source="streamList"- :show-header="true"- :left-bordered="true"- :right-bordered="true"- :row-clickable="true"- :custom-footer="true"- >- <template #body="{ rowData: stream }: { rowData: StreamMetadata }">- <BBTableCell :left-padding="4" class="w-24">- {{ schemaName }}- </BBTableCell>- <BBTableCell>- {{ stream.name }}- </BBTableCell>- <BBTableCell>- {{ stream.tableName }}- </BBTableCell>- <BBTableCell>- {{ stringifyStreamType(stream.type) }}- </BBTableCell>- <BBTableCell>- {{ stringifyStreamMode(stream.mode) }}- </BBTableCell>- <BBTableCell>- <DefinitionView :definition="stream.definition" />- </BBTableCell>- </template>- </BBTable>+ <NDataTable+ size="small"+ :columns="columns"+ :data="streamList"+ :striped="true"+ :bordered="true"+ /></template><script lang="ts" setup>+import type { DataTableColumn } from "naive-ui";+import { NDataTable } from "naive-ui";import type { PropType } from "vue";-import { computed } from "vue";+import { computed, h } from "vue";import { useI18n } from "vue-i18n";-import { BBTable, BBTableCell } from "@/bbkit";import DefinitionView from "@/components/DefinitionView.vue";import type { ComposedDatabase } from "@/types";import type { StreamMetadata } from "@/types/proto/v1/database_service";@@ -44,7 +22,7 @@ import {StreamMetadata_Type,} from "@/types/proto/v1/database_service";-defineProps({+const props = defineProps({database: {required: true,type: Object as PropType<ComposedDatabase>,@@ -61,44 +39,56 @@ defineProps({const { t } = useI18n();-const columnList = computed(() => {+const stringifyStreamType = (t: StreamMetadata_Type): string => {+ if (t === StreamMetadata_Type.TYPE_DELTA) {+ return "Delta";+ }+ return "-";+};++const stringifyStreamMode = (mode: StreamMetadata_Mode): string => {+ if (mode === StreamMetadata_Mode.MODE_APPEND_ONLY) {+ return "Append only";+ } else if (mode === StreamMetadata_Mode.MODE_INSERT_ONLY) {+ return "Insert only";+ } else if (mode === StreamMetadata_Mode.MODE_DEFAULT) {+ return "default";+ }+ return "-";+};++const columns = computed((): DataTableColumn<StreamMetadata>[] => {return [{title: t("common.schema"),+ key: "schema",+ render: () => props.schemaName,},{title: t("common.name"),+ key: "name",+ render: (row) => row.name || "-",},{title: t("common.table"),+ key: "tableName",+ render: (row) => row.tableName || "-",},{title: t("common.type"),+ key: "type",+ render: (row) => stringifyStreamType(row.type),},{title: t("common.mode"),+ key: "mode",+ render: (row) => stringifyStreamMode(row.mode),},{title: t("common.definition"),+ key: "definition",+ render: (row) => h(DefinitionView, { definition: row.definition }),},];});--const stringifyStreamType = (t: StreamMetadata_Type): string => {- if (t === StreamMetadata_Type.TYPE_DELTA) {- return "Delta";- }- return "-";-};--const stringifyStreamMode = (mode: StreamMetadata_Mode): string => {- if (mode === StreamMetadata_Mode.MODE_APPEND_ONLY) {- return "Append only";- } else if (mode === StreamMetadata_Mode.MODE_INSERT_ONLY) {- return "Insert only";- } else if (mode === StreamMetadata_Mode.MODE_DEFAULT) {- return "default";- }- return "-";-};</script>diff --git a/frontend/src/components/TaskTable.vue b/frontend/src/components/TaskTable.vueindex ba0a42e6c0..77607dfe21 100644--- a/frontend/src/components/TaskTable.vue+++ b/frontend/src/components/TaskTable.vue@@ -1,50 +1,25 @@<template>- <BBTable- :column-list="columnList"- :data-source="taskList"- :show-header="true"- :left-bordered="true"- :right-bordered="true"- :row-clickable="true"- :custom-footer="true"- >- <template #body="{ rowData: task }: { rowData: TaskMetadata }">- <BBTableCell :left-padding="4" class="w-16">- {{ schemaName }}- </BBTableCell>- <BBTableCell>- {{ task.name }}- </BBTableCell>- <BBTableCell>- {{ task.warehouse }}- </BBTableCell>- <BBTableCell>- {{ task.schedule || "-" }}- </BBTableCell>- <BBTableCell>- {{ stringifyTaskState(task.state) }}- </BBTableCell>- <BBTableCell>- {{ task.condition || "-" }}- </BBTableCell>- <BBTableCell>- <DefinitionView :definition="task.definition" />- </BBTableCell>- </template>- </BBTable>+ <NDataTable+ size="small"+ :columns="columns"+ :data="taskList"+ :striped="true"+ :bordered="true"+ /></template><script lang="ts" setup>+import type { DataTableColumn } from "naive-ui";+import { NDataTable } from "naive-ui";import type { PropType } from "vue";-import { computed } from "vue";+import { computed, h } from "vue";import { useI18n } from "vue-i18n";-import { BBTable, BBTableCell } from "@/bbkit";import DefinitionView from "@/components/DefinitionView.vue";import type { ComposedDatabase } from "@/types";import type { TaskMetadata } from "@/types/proto/v1/database_service";import { TaskMetadata_State } from "@/types/proto/v1/database_service";-defineProps({+const props = defineProps({database: {required: true,type: Object as PropType<ComposedDatabase>,@@ -61,38 +36,52 @@ defineProps({const { t } = useI18n();-const columnList = computed(() => {+const stringifyTaskState = (state: TaskMetadata_State): string => {+ if (state === TaskMetadata_State.STATE_STARTED) {+ return "Started";+ } else if (state === TaskMetadata_State.STATE_SUSPENDED) {+ return "Suspended";+ }+ return "-";+};++const columns = computed((): DataTableColumn<TaskMetadata>[] => {return [{title: t("common.schema"),+ key: "schema",+ render: () => props.schemaName,},{title: t("common.name"),+ key: "name",+ render: (row) => row.name || "-",},{title: t("common.warehouse"),+ key: "warehouse",+ render: (row) => row.warehouse || "-",},{title: t("common.schedule"),+ key: "schedule",+ render: (row) => row.schedule || "-",},{title: t("common.state"),+ key: "state",+ render: (row) => stringifyTaskState(row.state),},{title: t("common.condition"),+ key: "condition",+ render: (row) => row.condition || "-",},{title: t("common.definition"),+ key: "definition",+ render: (row) => h(DefinitionView, { definition: row.definition }),},];});--const stringifyTaskState = (state: TaskMetadata_State): string => {- if (state === TaskMetadata_State.STATE_STARTED) {- return "Started";- } else if (state === TaskMetadata_State.STATE_SUSPENDED) {- return "Suspended";- }- return "-";-};</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 09c75961d0..77afc7a986 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1380,7 +1380,6 @@"successfully-transferred-databases": "Successfully transferred databases","nullable": "Nullable","expression": "Expression",- "position": "Position","unique": "Unique","visible": "Visible","comment": "Comment",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex b1e4a201c6..22a305c5c7 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1380,7 +1380,6 @@"successfully-transferred-databases": "Bases de datos transferidas exitosamente","nullable": "Anulable","expression": "Expresión",- "position": "Posición","unique": "Único","visible": "Visible","comment": "Comentario",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 073cb277e8..3a054b9637 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1380,7 +1380,6 @@"successfully-transferred-databases": "データベースの移行が完了しました","nullable": "null も可能","expression": "表現",- "position": "位置","unique": "個性的","visible": "見える","comment": "コメント",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 021953d1ff..1e764996ce 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1380,7 +1380,6 @@"successfully-transferred-databases": "Đã chuyển thành công cơ sở dữ liệu","nullable": "Có thể null","expression": "Biểu thức",- "position": "Vị trí","unique": "Duy nhất","visible": "Hiển thị","comment": "Bình luận",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 92348e2970..bf1bf4d059 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1380,7 +1380,6 @@"successfully-transferred-databases": "数据库转移完成","nullable": "可为空","expression": "表达式",- "position": "位置","unique": "Unique","visible": "Visible","comment": "注释",