Skip to content

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

chore: replace database table components (#11691)

boojacka1a4f8cc9f95
diff --git a/frontend/src/components/AlterSchemaPrepForm/SelectDatabaseGroupTable.vue b/frontend/src/components/AlterSchemaPrepForm/SelectDatabaseGroupTable.vue
index f6f329565c..679d193534 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SelectDatabaseGroupTable.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SelectDatabaseGroupTable.vue
@@ -25,7 +25,7 @@
{{ dbGroup.databasePlaceholder }}
</div>
<div class="bb-grid-cell">
- <ProjectCol :project="dbGroup.projectEntity" :show-tenant-icon="true" />
+ <ProjectNameCell :project="dbGroup.projectEntity" />
</div>
</template>
</BBGrid>
@@ -36,6 +36,7 @@ import { NRadio } from "naive-ui";
import { reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import type { BBGridColumn } from "@/bbkit";
+import ProjectNameCell from "@/components/DatabaseDataTable/cells/ProjectNameCell.vue";
import type { ComposedDatabaseGroup } from "@/types";
interface LocalState {
diff --git a/frontend/src/components/ColumnDataTable/LabelsCell.vue b/frontend/src/components/ColumnDataTable/LabelsCell.vue
index d0440a65ba..33657d2690 100644
--- a/frontend/src/components/ColumnDataTable/LabelsCell.vue
+++ b/frontend/src/components/ColumnDataTable/LabelsCell.vue
@@ -1,6 +1,6 @@
<template>
<div class="flex items-center space-x-1">
- <LabelsColumn :labels="labels" :show-count="2" />
+ <DatabaseLabelsCell :labels="labels" :show-count="2" />
<button
v-if="!readonly"
class="w-5 h-5 p-0.5 hover:bg-gray-300 rounded cursor-pointer"
@@ -26,6 +26,7 @@ import { cloneDeep } from "lodash-es";
import { computed } from "vue";
import { reactive } from "vue";
import { useI18n } from "vue-i18n";
+import DatabaseLabelsCell from "@/components/DatabaseDataTable/cells/DatabaseLabelsCell.vue";
import { pushNotification, useDBSchemaV1Store } from "@/store";
import type { ComposedDatabase } from "@/types";
import type {
diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/LabelsCell.vue b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/LabelsCell.vue
index d7003243cb..e7c1851106 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/LabelsCell.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/TableColumnEditor/components/LabelsCell.vue
@@ -1,6 +1,6 @@
<template>
<div class="flex justify-start items-center">
- <LabelsColumn :labels="columnConfig?.labels ?? {}" :show-count="1" />
+ <DatabaseLabelsCell :labels="columnConfig?.labels ?? {}" :show-count="1" />
<MiniActionButton v-if="!readonly && !disabled" @click="$emit('edit')">
<PencilIcon class="w-3 h-3" />
</MiniActionButton>
@@ -10,9 +10,9 @@
<script lang="ts" setup>
import { PencilIcon } from "lucide-vue-next";
import { computed } from "vue";
+import DatabaseLabelsCell from "@/components/DatabaseDataTable/cells/DatabaseLabelsCell.vue";
import { useSchemaEditorContext } from "@/components/SchemaEditorLite/context";
import { MiniActionButton } from "@/components/v2";
-import LabelsColumn from "@/components/v2/Model/DatabaseV1Table/LabelsColumn.vue";
import type { ComposedDatabase } from "@/types";
import type {
ColumnMetadata,
diff --git a/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor/components/LabelsCell.vue b/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor/components/LabelsCell.vue
index 4cd48bc7e8..49693a6d66 100644
--- a/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor/components/LabelsCell.vue
+++ b/frontend/src/components/SchemaEditorV1/Panels/TableColumnEditor/components/LabelsCell.vue
@@ -1,6 +1,6 @@
<template>
<div class="flex justify-start items-center">
- <LabelsColumn :labels="column.config.labels" :show-count="1" />
+ <DatabaseLabelsCell :labels="column.config.labels" :show-count="1" />
<MiniActionButton v-if="!readonly && !disabled" @click="$emit('edit')">
<PencilIcon class="w-3 h-3" />
</MiniActionButton>
@@ -9,8 +9,8 @@
<script lang="ts" setup>
import { PencilIcon } from "lucide-vue-next";
+import DatabaseLabelsCell from "@/components/DatabaseDataTable/cells/DatabaseLabelsCell.vue";
import { MiniActionButton } from "@/components/v2";
-import LabelsColumn from "@/components/v2/Model/DatabaseV1Table/LabelsColumn.vue";
import type { Column } from "@/types/v1/schemaEditor";
defineProps<{
diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
index 41cf619b70..1444511662 100644
--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
@@ -33,7 +33,10 @@
{{ item.column?.userComment }}
</div>
<div class="bb-grid-cell">
- <LabelsColumn :labels="item.config?.labels ?? {}" :show-count="2" />
+ <DatabaseLabelsCell
+ :labels="item.config?.labels ?? {}"
+ :show-count="2"
+ />
</div>
<div class="bb-grid-cell flex items-center justify-start gap-x-2">
<MiniActionButton @click.stop="$emit('view', item)">
@@ -63,6 +66,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import type { BBGridColumn } from "@/bbkit";
import { BBGrid } from "@/bbkit";
+import DatabaseLabelsCell from "@/components/DatabaseDataTable/cells/DatabaseLabelsCell.vue";
import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorV1/utils/columnDefaultValue";
import { MiniActionButton } from "@/components/v2";
import { useSettingV1Store } from "@/store";
diff --git a/frontend/src/components/TransferDatabaseForm/MultipleDatabaseSelector.vue b/frontend/src/components/TransferDatabaseForm/MultipleDatabaseSelector.vue
index 923b827835..3e61e7d77c 100644
--- a/frontend/src/components/TransferDatabaseForm/MultipleDatabaseSelector.vue
+++ b/frontend/src/components/TransferDatabaseForm/MultipleDatabaseSelector.vue
@@ -84,10 +84,7 @@
</span>
</div>
<div v-if="showProjectColumn" class="bb-grid-cell">
- <ProjectCol
- :project="database.projectEntity"
- :show-tenant-icon="true"
- />
+ <ProjectNameCell :project="database.projectEntity" />
</div>
<div class="bb-grid-cell gap-x-1 textinfolabel justify-end">
<InstanceV1Name
@@ -106,6 +103,7 @@
import { NCollapse, NCollapseItem, NCheckbox } from "naive-ui";
import { computed, reactive, watch } from "vue";
import { type BBGridColumn, BBGrid } from "@/bbkit";
+import ProjectNameCell from "@/components/DatabaseDataTable/cells/ProjectNameCell.vue";
import { useEnvironmentV1List } from "@/store";
import type { ComposedDatabase } from "@/types";
import { State } from "@/types/proto/v1/common";
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/LabelsColumn.vue b/frontend/src/components/v2/Model/DatabaseV1Table/LabelsColumn.vue
deleted file mode 100644
index e58f51eed6..0000000000
--- a/frontend/src/components/v2/Model/DatabaseV1Table/LabelsColumn.vue
+++ /dev/null
@@ -1,45 +0,0 @@
-<template>
- <NTooltip :disabled="Object.keys(labels).length <= minimumShowCount">
- <template #trigger>
- <div
- v-if="Object.entries(labels).length > 0"
- class="flex items-center space-x-1"
- >
- <div
- v-for="[key, label] in Object.entries(labels).slice(
- 0,
- minimumShowCount
- )"
- :key="key"
- class="rounded-lg bg-gray-100 group-hover:bg-gray-200 py-0.5 px-2 text-sm"
- >
- {{ `${key}:${label}` }}
- </div>
- <span v-if="Object.keys(labels).length > minimumShowCount">...</span>
- </div>
- <div v-else>{{ placeholder }}</div>
- </template>
- <div class="text-sm flex flex-col space-y-1">
- <div v-for="[key, label] in Object.entries(labels)" :key="key">
- {{ `${key}:${label}` }}
- </div>
- </div>
- </NTooltip>
-</template>
-
-<script setup lang="ts">
-const props = withDefaults(
- defineProps<{
- labels: {
- [key: string]: string;
- };
- showCount: number;
- placeholder?: string;
- }>(),
- {
- placeholder: "",
- }
-);
-
-const minimumShowCount = Math.max(1, props.showCount);
-</script>
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue b/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue
deleted file mode 100644
index c934df1ce5..0000000000
--- a/frontend/src/components/v2/Model/DatabaseV1Table/ProjectCol.vue
+++ /dev/null
@@ -1,58 +0,0 @@
-<template>
- <div class="flex flex-row space-x-2 items-center">
- <ProjectV1Name :project="project" :link="false" tag="div" />
-
- <NTooltip
- v-if="
- showTenantIcon && project.tenantMode === TenantMode.TENANT_MODE_ENABLED
- "
- >
- <template #trigger>
- <TenantIcon class="text-control" />
- </template>
- <span class="whitespace-nowrap">
- {{ $t("project.mode.batch") }}
- </span>
- </NTooltip>
-
- <NTooltip v-if="project.workflow === Workflow.VCS">
- <template #trigger>
- <GitIcon class="w-4 h-4 text-control" />
- </template>
- <span v-if="mode === 'ALL_SHORT'" class="w-40">
- {{ $t("alter-schema.vcs-info") }}
- </span>
- <span v-else class="tooltip whitespace-nowrap">
- {{ $t("database.gitops-enabled") }}
- </span>
- </NTooltip>
-
- <NTooltip v-if="project.state === State.DELETED">
- <template #trigger>
- <heroicons-outline:archive class="w-4 h-4 text-control" />
- </template>
- <span class="whitespace-nowrap">
- {{ $t("common.archived") }}
- </span>
- </NTooltip>
- </div>
-</template>
-
-<script setup lang="ts">
-import { NTooltip } from "naive-ui";
-import type { Mode } from "@/components/DatabaseDataTable/DatabaseDataTable.vue";
-import { State } from "@/types/proto/v1/common";
-import type { Project } from "@/types/proto/v1/project_service";
-import { TenantMode, Workflow } from "@/types/proto/v1/project_service";
-
-withDefaults(
- defineProps<{
- project: Project;
- mode?: Mode;
- showTenantIcon: boolean;
- }>(),
- {
- mode: "ALL",
- }
-);
-</script>
diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vue
index c3f0151658..f0b4c7b500 100644
--- a/frontend/src/components/v2/Model/ProjectV1Table.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue
@@ -19,11 +19,7 @@
</span>
</div>
<div class="bb-grid-cell truncate">
- <ProjectCol
- mode="ALL_SHORT"
- :project="project"
- :show-tenant-icon="true"
- />
+ <ProjectNameCell mode="ALL_SHORT" :project="project" />
</div>
</template>
</BBGrid>
@@ -36,6 +32,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import type { BBGridColumn, BBGridRow } from "@/bbkit";
import { BBGrid } from "@/bbkit";
+import ProjectNameCell from "@/components/DatabaseDataTable/cells/ProjectNameCell.vue";
import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
import { PROJECT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import { getProjectName } from "@/store/modules/v1/common";
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 93b45c5302..95d20aada8 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -9,11 +9,10 @@
@click="state.showProjectModal = true"
>
<div class="min-w-[8rem] text-left">
- <ProjectCol
+ <ProjectNameCell
v-if="project.uid !== `${UNKNOWN_ID}`"
mode="ALL_SHORT"
:project="project"
- :show-tenant-icon="true"
/>
<span v-else class="text-control-placeholder text-sm">
{{ $t("project.select") }}
@@ -100,6 +99,7 @@ import { storeToRefs } from "pinia";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import ProjectNameCell from "@/components/DatabaseDataTable/cells/ProjectNameCell.vue";
import { useCurrentProject } from "@/components/Project/useCurrentProject";
import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";
import {
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index c4c673d7c4..c4783723ef 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -21,19 +21,14 @@
<DatabaseDataTable
mode="ALL"
+ :loading="state.loading"
+ :bordered="false"
:database-list="filteredDatabaseList"
:custom-click="true"
@row-click="handleDatabaseClick"
@update:selected-databases="handleDatabasesSelectionChanged"
/>
</div>
-
- <div
- v-if="state.loading"
- class="absolute inset-0 bg-white/50 flex justify-center items-center"
- >
- <BBSpin />
- </div>
</div>
</template>
diff --git a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
index d363065d54..a938e1aaa1 100644
--- a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
@@ -99,8 +99,8 @@ import { NPopover, NDivider, NDataTable, NTag, NButton } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
import { h } from "vue";
import { useI18n } from "vue-i18n";
+import DatabaseLabelsCell from "@/components/DatabaseDataTable/cells/DatabaseLabelsCell.vue";
import { InstanceV1EngineIcon } from "@/components/v2";
-import LabelsColumn from "@/components/v2/Model/DatabaseV1Table/LabelsColumn.vue";
import {
hasFeature,
useConnectionOfCurrentSQLEditorTab,
@@ -210,7 +210,7 @@ const dataTableColumns = computed((): DataTableColumn<ComposedDatabase>[] => {
resizable: true,
width: 100,
render(row: ComposedDatabase) {
- return h(LabelsColumn, {
+ return h(DatabaseLabelsCell, {
labels: row.labels,
showCount: 1,
placeholder: "",