Skip to content

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

chore: use DataTable in database overview page (#9939)

boojack258e9cab0079
diff --git a/frontend/src/components/DBExtensionDataTable.vue b/frontend/src/components/DBExtensionDataTable.vue
new file mode 100644
index 0000000000..bfa25d10db
--- /dev/null
+++ b/frontend/src/components/DBExtensionDataTable.vue
@@ -0,0 +1,59 @@
+<template>
+ <NDataTable
+ :columns="columns"
+ :data="dbExtensionList"
+ :max-height="640"
+ :virtual-scroll="true"
+ :striped="true"
+ :bordered="true"
+ />
+</template>
+
+<script lang="ts" setup>
+import { DataTableColumn, NDataTable } from "naive-ui";
+import { computed, PropType } from "vue";
+import { useI18n } from "vue-i18n";
+import { ExtensionMetadata } from "@/types/proto/v1/database_service";
+
+defineProps({
+ dbExtensionList: {
+ required: true,
+ type: Object as PropType<ExtensionMetadata[]>,
+ },
+});
+
+const { t } = useI18n();
+
+const columns = computed(() => {
+ return [
+ {
+ key: "name",
+ title: t("common.name"),
+ render: (row) => {
+ return row.name;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.version"),
+ render: (row) => {
+ return row.version;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.schema"),
+ render: (row) => {
+ return row.schema;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.description"),
+ render: (row) => {
+ return row.description;
+ },
+ },
+ ] as DataTableColumn<ExtensionMetadata>[];
+});
+</script>
diff --git a/frontend/src/components/DBExtensionTable.vue b/frontend/src/components/DBExtensionTable.vue
deleted file mode 100644
index 5e5e2acbd5..0000000000
--- a/frontend/src/components/DBExtensionTable.vue
+++ /dev/null
@@ -1,62 +0,0 @@
-<template>
- <BBTable
- :column-list="columnList"
- :data-source="dbExtensionList"
- :show-header="true"
- :left-bordered="true"
- :right-bordered="true"
- :row-clickable="false"
- >
- <template #body="{ rowData: dbExtension }">
- <BBTableCell :left-padding="4" class="w-16">
- {{ dbExtension.name }}
- </BBTableCell>
- <BBTableCell class="w-8">
- {{ dbExtension.version }}
- </BBTableCell>
- <BBTableCell class="w-8">
- {{ dbExtension.schema }}
- </BBTableCell>
- <BBTableCell class="w-64">
- {{ dbExtension.description }}
- </BBTableCell>
- </template>
- </BBTable>
-</template>
-
-<script lang="ts">
-import { computed, PropType } from "vue";
-import { useI18n } from "vue-i18n";
-import { ExtensionMetadata } from "@/types/proto/v1/database_service";
-
-export default {
- name: "DbExtensionTable",
- components: {},
- props: {
- dbExtensionList: {
- required: true,
- type: Object as PropType<ExtensionMetadata[]>,
- },
- },
- setup() {
- const { t } = useI18n();
- const columnList = computed(() => [
- {
- title: t("common.name"),
- },
- {
- title: t("common.version"),
- },
- {
- title: t("common.schema"),
- },
- {
- title: t("common.description"),
- },
- ]);
- return {
- columnList,
- };
- },
-};
-</script>
diff --git a/frontend/src/components/DBExternalDataTable.vue b/frontend/src/components/DBExternalDataTable.vue
new file mode 100644
index 0000000000..353aa8ae6d
--- /dev/null
+++ b/frontend/src/components/DBExternalDataTable.vue
@@ -0,0 +1,53 @@
+<template>
+ <NDataTable
+ :columns="columns"
+ :data="dbExternalTableList"
+ :max-height="640"
+ :virtual-scroll="true"
+ :striped="true"
+ :bordered="true"
+ />
+</template>
+
+<script lang="ts" setup>
+import { DataTableColumn, NDataTable } from "naive-ui";
+import { computed, PropType } from "vue";
+import { useI18n } from "vue-i18n";
+import { ExternalTableMetadata } from "@/types/proto/v1/database_service";
+
+defineProps({
+ dbExternalTableList: {
+ required: true,
+ type: Object as PropType<ExternalTableMetadata[]>,
+ schemaName: "",
+ },
+});
+
+const { t } = useI18n();
+
+const columns = computed(() => {
+ return [
+ {
+ key: "name",
+ title: t("common.name"),
+ render: (row) => {
+ return row.name;
+ },
+ },
+ {
+ key: "name",
+ title: t("database.external-server-name"),
+ render: (row) => {
+ return row.externalServerName;
+ },
+ },
+ {
+ key: "name",
+ title: t("database.external-database-name"),
+ render: (row) => {
+ return row.externalDatabaseName;
+ },
+ },
+ ] as DataTableColumn<ExternalTableMetadata>[];
+});
+</script>
diff --git a/frontend/src/components/DBExternalTable.vue b/frontend/src/components/DBExternalTable.vue
deleted file mode 100644
index 242ed8951c..0000000000
--- a/frontend/src/components/DBExternalTable.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-<template>
- <BBTable
- :column-list="columnList"
- :data-source="dbExternalTableList"
- :show-header="true"
- :left-bordered="true"
- :right-bordered="true"
- :row-clickable="false"
- >
- <template #body="{ rowData: dbExternalTable }">
- <BBTableCell :left-padding="4" class="w-16">
- {{ dbExternalTable.name }}
- </BBTableCell>
- <BBTableCell class="w-8">
- {{ dbExternalTable.externalServerName }}
- </BBTableCell>
- <BBTableCell class="w-8">
- {{ dbExternalTable.externalDatabaseName }}
- </BBTableCell>
- </template>
- </BBTable>
-</template>
-
-<script lang="ts">
-import { computed, PropType } from "vue";
-import { useI18n } from "vue-i18n";
-import { ExternalTableMetadata } from "@/types/proto/v1/database_service";
-
-export default {
- name: "DbExtensionTable",
- components: {},
- props: {
- dbExternalTableList: {
- required: true,
- type: Object as PropType<ExternalTableMetadata[]>,
- schemaName: "",
- },
- },
- setup() {
- const { t } = useI18n();
- const columnList = computed(() => [
- {
- title: t("common.name"),
- },
- {
- title: t("common.external-server-name"),
- },
- {
- title: t("common.external-database-name"),
- },
- ]);
- return {
- columnList,
- };
- },
-};
-</script>
diff --git a/frontend/src/components/DatabaseOverviewPanel.vue b/frontend/src/components/DatabaseOverviewPanel.vue
index a773ea66b9..447070fa34 100644
--- a/frontend/src/components/DatabaseOverviewPanel.vue
+++ b/frontend/src/components/DatabaseOverviewPanel.vue
@@ -122,7 +122,7 @@
<div class="mt-6 text-lg leading-6 font-medium text-main mb-4">
{{ $t("db.views") }}
</div>
- <ViewTable
+ <ViewDataTable
:database="database"
:schema-name="state.selectedSchemaName"
:view-list="viewList"
@@ -132,21 +132,21 @@
<div class="mt-6 text-lg leading-6 font-medium text-main mb-4">
{{ $t("db.foreign-tables") }}
</div>
- <DBExternalTable :db-external-table-list="dbExternalTableList" />
+ <DBExternalDataTable :db-external-table-list="dbExternalTableList" />
</template>
<template v-if="databaseEngine === Engine.POSTGRES">
<div class="mt-6 text-lg leading-6 font-medium text-main mb-4">
{{ $t("db.extensions") }}
</div>
- <DBExtensionTable :db-extension-list="dbExtensionList" />
+ <DBExtensionDataTable :db-extension-list="dbExtensionList" />
</template>
<template v-if="databaseEngine === Engine.POSTGRES">
<div class="mt-6 text-lg leading-6 font-medium text-main mb-4">
{{ $t("db.functions") }}
</div>
- <FunctionTable
+ <FunctionDataTable
:database="database"
:schema-name="state.selectedSchemaName"
:function-list="functionList"
@@ -181,15 +181,17 @@
import { head } from "lodash-es";
import { computed, reactive, watch, PropType } from "vue";
import { useRoute } from "vue-router";
+import DBExtensionDataTable from "@/components/DBExtensionDataTable.vue";
+import DBExternalDataTable from "@/components/DBExternalDataTable.vue";
+import FunctionDataTable from "@/components/FunctionDataTable.vue";
+import TableDataTable from "@/components/TableDataTable.vue";
+import ViewDataTable from "@/components/ViewDataTable.vue";
import { useDBSchemaV1Store } from "@/store";
import { Anomaly } from "@/types/proto/v1/anomaly_service";
import { Engine, State } from "@/types/proto/v1/common";
import { DatabaseMetadataView } from "@/types/proto/v1/database_service";
import { BBTableSectionDataSource } from "../bbkit/types";
import AnomalyTable from "../components/AnomalyCenter/AnomalyTable.vue";
-import FunctionTable from "../components/FunctionTable.vue";
-import TableDataTable from "../components/TableDataTable.vue";
-import ViewTable from "../components/ViewTable.vue";
import { ComposedDatabase, DataSource } from "../types";
import StreamTable from "./StreamTable.vue";
import TaskTable from "./TaskTable.vue";
diff --git a/frontend/src/components/FunctionDataTable.vue b/frontend/src/components/FunctionDataTable.vue
new file mode 100644
index 0000000000..65dda7b643
--- /dev/null
+++ b/frontend/src/components/FunctionDataTable.vue
@@ -0,0 +1,89 @@
+<template>
+ <NDataTable
+ :columns="columns"
+ :data="functionList"
+ :max-height="640"
+ :virtual-scroll="true"
+ :striped="true"
+ :bordered="true"
+ />
+</template>
+
+<script lang="ts" setup>
+import { DataTableColumn, NDataTable } from "naive-ui";
+import { computed, PropType } from "vue";
+import { useI18n } from "vue-i18n";
+import { ComposedDatabase } from "@/types";
+import { Engine } from "@/types/proto/v1/common";
+import { FunctionMetadata } from "@/types/proto/v1/database_service";
+
+const props = defineProps({
+ database: {
+ required: true,
+ type: Object as PropType<ComposedDatabase>,
+ },
+ schemaName: {
+ type: String,
+ default: "",
+ },
+ functionList: {
+ required: true,
+ type: Object as PropType<FunctionMetadata[]>,
+ },
+});
+
+const { t } = useI18n();
+
+const engine = computed(() => props.database.instanceEntity.engine);
+
+const isPostgres = computed(() => engine.value === Engine.POSTGRES);
+
+const hasSchemaProperty = computed(() => {
+ return (
+ isPostgres.value ||
+ engine.value === Engine.SNOWFLAKE ||
+ engine.value === Engine.ORACLE ||
+ engine.value === Engine.DM ||
+ engine.value === Engine.MSSQL ||
+ engine.value === Engine.RISINGWAVE
+ );
+});
+
+const columns = computed(() => {
+ const columns: (DataTableColumn<FunctionMetadata> & { hide?: boolean })[] = [
+ {
+ key: "name",
+ title: t("common.schema"),
+ hide: !hasSchemaProperty.value,
+ ellipsis: {
+ tooltip: true,
+ },
+ render: () => {
+ return props.schemaName;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.name"),
+ ellipsis: {
+ tooltip: true,
+ },
+ render: (row) => {
+ return row.name;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.definition"),
+ ellipsis: {
+ tooltip: true,
+ },
+ render: (row) => {
+ return row.definition;
+ },
+ },
+ ];
+
+ return columns;
+});
+</script>
diff --git a/frontend/src/components/FunctionTable.vue b/frontend/src/components/FunctionTable.vue
deleted file mode 100644
index dad8764116..0000000000
--- a/frontend/src/components/FunctionTable.vue
+++ /dev/null
@@ -1,92 +0,0 @@
-<template>
- <BBTable
- :column-list="columnList"
- :data-source="functionList"
- :show-header="true"
- :left-bordered="true"
- :right-bordered="true"
- :row-clickable="true"
- :custom-footer="true"
- >
- <template #body="{ rowData: functionItem }">
- <BBTableCell v-if="hasSchemaProperty" :left-padding="4" class="w-[10%]">
- {{ schemaName }}
- </BBTableCell>
- <BBTableCell :left-padding="hasSchemaProperty ? 2 : 4">
- <div class="flex items-center space-x-2">
- <EllipsisText>{{ functionItem.name }}</EllipsisText>
- </div>
- </BBTableCell>
- <BBTableCell>
- <DefinitionView :definition="functionItem.definition" />
- </BBTableCell>
- </template>
- </BBTable>
-</template>
-
-<script lang="ts" setup>
-import { computed, PropType } from "vue";
-import { useI18n } from "vue-i18n";
-import DefinitionView from "@/components/DefinitionView.vue";
-import EllipsisText from "@/components/EllipsisText.vue";
-import { ComposedDatabase } from "@/types";
-import { Engine } from "@/types/proto/v1/common";
-import { FunctionMetadata } from "@/types/proto/v1/database_service";
-
-const props = defineProps({
- database: {
- required: true,
- type: Object as PropType<ComposedDatabase>,
- },
- schemaName: {
- type: String,
- default: "",
- },
- functionList: {
- required: true,
- type: Object as PropType<FunctionMetadata[]>,
- },
-});
-
-const { t } = useI18n();
-
-const engine = computed(() => props.database.instanceEntity.engine);
-
-const isPostgres = computed(() => engine.value === Engine.POSTGRES);
-
-const hasSchemaProperty = computed(() => {
- return (
- isPostgres.value ||
- engine.value === Engine.SNOWFLAKE ||
- engine.value === Engine.ORACLE ||
- engine.value === Engine.DM ||
- engine.value === Engine.MSSQL ||
- engine.value === Engine.RISINGWAVE
- );
-});
-
-const columnList = computed(() => {
- if (hasSchemaProperty.value) {
- return [
- {
- title: t("common.schema"),
- },
- {
- title: t("common.name"),
- },
- {
- title: t("common.definition"),
- },
- ];
- } else {
- return [
- {
- title: t("common.name"),
- },
- {
- title: t("common.definition"),
- },
- ];
- }
-});
-</script>
diff --git a/frontend/src/components/TableDataTable.vue b/frontend/src/components/TableDataTable.vue
index f6dc3f324e..f46b647be6 100644
--- a/frontend/src/components/TableDataTable.vue
+++ b/frontend/src/components/TableDataTable.vue
@@ -113,6 +113,9 @@ const columns = computed(() => {
key: "schema",
title: t("common.schema"),
hide: !hasSchemaProperty.value,
+ ellipsis: {
+ tooltip: true,
+ },
render: () => {
return props.schemaName;
},
@@ -120,6 +123,9 @@ const columns = computed(() => {
{
key: "name",
title: t("common.name"),
+ ellipsis: {
+ tooltip: true,
+ },
render: (row) => {
return row.name;
},
diff --git a/frontend/src/components/ViewTable.vue b/frontend/src/components/ViewDataTable.vue
similarity index 55%
rename from frontend/src/components/ViewTable.vue
rename to frontend/src/components/ViewDataTable.vue
index a40868d3cd..ab51514dc4 100644
--- a/frontend/src/components/ViewTable.vue
+++ b/frontend/src/components/ViewDataTable.vue
@@ -1,29 +1,18 @@
<template>
- <BBGrid
- :column-list="columnList"
- :data-source="viewList"
- :show-header="true"
- :row-clickable="false"
- class="border"
- >
- <template #item="{ item: view }: BBGridRow<ViewMetadata>">
- <div class="bb-grid-cell">
- {{ getViewName(view.name) }}
- </div>
- <div class="bb-grid-cell break-all">
- {{ view.definition }}
- </div>
- <div class="bb-grid-cell">
- {{ view.comment }}
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ :columns="columns"
+ :data="viewList"
+ :max-height="640"
+ :virtual-scroll="true"
+ :striped="true"
+ :bordered="true"
+ />
</template>
<script lang="ts" setup>
+import { DataTableColumn, NDataTable } from "naive-ui";
import { computed, PropType } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, BBGridColumn, BBGridRow } from "@/bbkit";
import { ComposedDatabase } from "@/types";
import { Engine } from "@/types/proto/v1/common";
import { ViewMetadata } from "@/types/proto/v1/database_service";
@@ -55,20 +44,33 @@ const hasSchemaProperty = computed(() => {
);
});
-const columnList = computed((): BBGridColumn[] => [
- {
- title: t("common.name"),
- width: "minmax(auto, 1fr)",
- },
- {
- title: t("common.definition"),
- width: "3fr",
- },
- {
- title: t("database.comment"),
- width: "minmax(auto, 12rem)",
- },
-]);
+const columns = computed(() => {
+ const columns: (DataTableColumn<ViewMetadata> & { hide?: boolean })[] = [
+ {
+ key: "name",
+ title: t("common.name"),
+ render: (row) => {
+ return getViewName(row.name);
+ },
+ },
+ {
+ key: "name",
+ title: t("common.definition"),
+ render: (row) => {
+ return row.definition;
+ },
+ },
+ {
+ key: "name",
+ title: t("common.comment"),
+ render: (row) => {
+ return row.comment;
+ },
+ },
+ ];
+
+ return columns.filter((column) => !column.hide);
+});
const getViewName = (viewName: string) => {
if (hasSchemaProperty.value) {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 9aa2359212..faf1d83206 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -95,8 +95,6 @@
"creator": "Creator",
"updater": "Updater",
"version": "Version",
- "external-server-name": "External Server Name",
- "external-database-name": "External Database Name",
"issue": "Issue",
"issues": "Issues",
"duration": "Duration",
@@ -1724,7 +1722,9 @@
},
"recent": "Recent",
"partitioned": "Partitioned",
- "partition-tables": "Partition tables"
+ "partition-tables": "Partition tables",
+ "external-server-name": "External Server Name",
+ "external-database-name": "External Database Name"
},
"repository": {
"our-webhook-link": "The webhook created by Bytebase can be found at {webhookLink}.",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 9780c166ae..cbd7f589a2 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -278,9 +278,7 @@
"show-all": "Mostrar todo",
"view-details": "Ver detalles",
"force-verb": "forzar {verbo}",
- "nothing-changed": "nada ha cambiado",
- "external-database-name": "Nombre de la base de datos externa",
- "external-server-name": "Nombre del servidor externo"
+ "nothing-changed": "nada ha cambiado"
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -1723,7 +1721,9 @@
},
"recent": "Reciente",
"partitioned": "Particionado",
- "partition-tabled": "Tabla particionada"
+ "partition-tabled": "Tabla particionada",
+ "external-database-name": "Nombre de la base de datos externa",
+ "external-server-name": "Nombre del servidor externo"
},
"repository": {
"branch-observe-file-change": "La rama donde Bytebase observa el cambio de archivo.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f212b6ed53..ae5a0d35fe 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -276,9 +276,7 @@
"show-all": "显示全部",
"view-details": "查看详情",
"force-verb": "强制{verb}",
- "nothing-changed": "没有改变",
- "external-database-name": "外部数据库名称",
- "external-server-name": "外部服务器名称"
+ "nothing-changed": "没有改变"
},
"error-page": {
"go-back-home": "回到主页"
@@ -1719,7 +1717,9 @@
},
"recent": "最近访问",
"partitioned": "分区",
- "partition-tabled": "分区表"
+ "partition-tabled": "分区表",
+ "external-server-name": "外部服务器名称",
+ "external-database-name": "外部数据库名称"
},
"repository": {
"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",