Skip to content

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

feat(frontend): BYT-1079 database table improvement part.2 (#2189)

Liu Jibb1e6a9c6a70
diff --git a/frontend/src/bbkit/BBTable/BBTable.vue b/frontend/src/bbkit/BBTable/BBTable.vue
index 1cbbfc5cb6..629a1a3394 100644
--- a/frontend/src/bbkit/BBTable/BBTable.vue
+++ b/frontend/src/bbkit/BBTable/BBTable.vue
@@ -15,6 +15,7 @@
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',
]"
@@ -97,6 +98,7 @@
<script lang="ts" setup>
import { computed, withDefaults } from "vue";
import { BBTableColumn, BBTableSectionDataSource } from "../types";
+import type { VueClass } from "@/utils";
type DataType = any; // vue does not support generic typed components yet
@@ -111,6 +113,7 @@ const props = withDefaults(
compactSection?: boolean;
showHeader?: boolean;
customHeader?: boolean;
+ headerClass?: VueClass;
rowClickable?: boolean;
leftBordered?: boolean;
rightBordered?: boolean;
@@ -124,6 +127,7 @@ const props = withDefaults(
compactSection: false,
showHeader: true,
customHeader: false,
+ headerClass: undefined,
rowClickable: true,
leftBordered: true,
rightBordered: true,
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index edd03f681b..60ae89c635 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -7,6 +7,7 @@
:right-bordered="bordered"
:top-bordered="bordered"
:bottom-bordered="bordered"
+ header-class="capitalize"
data-label="bb-database-table"
@click-row="clickDatabase"
>
@@ -43,6 +44,17 @@
}}
</div>
</NTooltip>
+
+ <button
+ v-if="showSQLEditorLink"
+ class="btn-icon tooltip-wrapper"
+ @click.stop="gotoSQLEditor(database)"
+ >
+ <heroicons-outline:terminal class="w-4 h-4" />
+ <div class="tooltip whitespace-nowrap">
+ {{ $t("sql-editor.self") }}
+ </div>
+ </button>
</div>
</BBTableCell>
<BBTableCell class="w-[10%]">
@@ -52,10 +64,7 @@
<div class="flex flex-row space-x-2 items-center">
<div>{{ projectName(database.project) }}</div>
<div
- v-if="
- ['ALL', 'ALL_SHORT', 'INSTANCE'].includes(mode) &&
- database.project.tenantMode === 'TENANT'
- "
+ v-if="showTenantIcon && database.project.tenantMode === 'TENANT'"
class="tooltip-wrapper"
>
<span class="tooltip whitespace-nowrap">
@@ -99,9 +108,9 @@
</div>
</BBTableCell>
<BBTableCell v-if="showMiscColumn" class="w-[8%]">
- <NTooltip>
- <template #trigger>
- <div class="w-full flex justify-center">
+ <div class="w-full flex justify-center">
+ <NTooltip placement="left">
+ <template #trigger>
<div
class="flex items-center justify-center rounded-full select-none w-5 h-5 overflow-hidden text-white font-medium text-base"
:class="
@@ -119,28 +128,25 @@
>
</template>
</div>
- </div>
- </template>
-
- <span>
- <template v-if="database.syncStatus === 'OK'">
- {{
- $t("database.sync-at", {
- time: humanizeTs(database.lastSuccessfulSyncTs),
- })
- }}
- </template>
- <template v-else>
- {{ $t("database.not-found") }}
</template>
- </span>
- </NTooltip>
- </BBTableCell>
- <BBTableCell v-if="showSQLEditorLink" class="w-[8%]">
- <div class="w-full flex justify-center">
- <button class="btn-icon" @click.stop="gotoSQLEditor(database)">
- <heroicons-outline:terminal class="w-4 h-4" />
- </button>
+
+ <span>
+ <template v-if="database.syncStatus === 'OK'">
+ {{
+ $t("database.synced-at", {
+ time: humanizeTs(database.lastSuccessfulSyncTs),
+ })
+ }}
+ </template>
+ <template v-else>
+ {{
+ $t("database.not-found-last-successful-sync-was", {
+ time: humanizeTs(database.lastSuccessfulSyncTs),
+ })
+ }}
+ </template>
+ </span>
+ </NTooltip>
</div>
</BBTableCell>
</template>
@@ -195,13 +201,12 @@
import { computed, PropType, reactive } from "vue";
import { useRouter } from "vue-router";
import { NTooltip } from "naive-ui";
+import { useI18n } from "vue-i18n";
import { connectionSlug, databaseSlug, isPITRDatabase } from "../utils";
import type { Database } from "../types";
import { DEFAULT_PROJECT_ID, UNKNOWN_ID } from "../types";
import { BBTableColumn } from "../bbkit/types";
import InstanceEngineIcon from "./InstanceEngineIcon.vue";
-import { cloneDeep } from "lodash-es";
-import { useI18n } from "vue-i18n";
import TenantIcon from "./TenantIcon.vue";
type Mode = "ALL" | "ALL_SHORT" | "INSTANCE" | "PROJECT" | "PROJECT_SHORT";
@@ -306,7 +311,7 @@ const columnListMap = computed(() => {
title: t("common.instance"),
},
{
- title: t("database.last-sync-status"),
+ title: t("database.sync-status"),
center: true,
},
],
@@ -344,7 +349,7 @@ const columnListMap = computed(() => {
title: t("common.project"),
},
{
- title: t("database.last-sync-status"),
+ title: t("database.sync-status"),
center: true,
},
],
@@ -365,7 +370,7 @@ const columnListMap = computed(() => {
title: t("common.instance"),
},
{
- title: t("database.last-sync-status"),
+ title: t("database.sync-status"),
center: true,
},
],
@@ -408,12 +413,6 @@ const showMiscColumn = computed(() => {
const columnList = computed(() => {
var list: BBTableColumn[] = columnListMap.value.get(props.mode)!;
- if (showSQLEditorLink.value) {
- // Use cloneDeep, otherwise it will alter the one in columnListMap
- list = cloneDeep(list);
- list.push({ title: t("sql-editor.self"), center: true });
- }
-
if (props.showSelectionColumn) {
list.unshift({ title: "" });
}
@@ -427,6 +426,10 @@ const showSQLEditorLink = computed(() => {
return true;
});
+const showTenantIcon = computed(() => {
+ return ["ALL", "ALL_SHORT", "INSTANCE"].includes(props.mode);
+});
+
const gotoSQLEditor = (database: Database) => {
// SQL editors can only query databases in the projects available to the user.
if (
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 7caf6711a0..1dc70cc230 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -856,8 +856,8 @@
}
},
"backup-policy-violation": "Backup policy violation",
- "sync-at": "Sync at {time}",
- "not-found": "Not found"
+ "synced-at": "Synced at {time}",
+ "not-found-last-successful-sync-was": "Not found, last successful sync was {time}"
},
"repository": {
"branch-observe-file-change": "The branch where Bytebase observes the file change.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 2179335b0f..72c1c29c9a 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -857,8 +857,8 @@
}
},
"backup-policy-violation": "违反了备份策略",
- "sync-at": "同步于 {time}",
- "not-found": "未找到"
+ "synced-at": "同步于 {time}",
+ "not-found-last-successful-sync-was": "未找到,上次成功同步于 {time}"
},
"repository": {
"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",
diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts
index 38e6f7f63e..2e64af127d 100644
--- a/frontend/src/utils/index.ts
+++ b/frontend/src/utils/index.ts
@@ -9,6 +9,7 @@ export * from "./project";
export * from "./role";
export * from "./slug";
export * from "./table";
+export * from "./types";
export * from "./util";
export * from "./label";
export * from "./deployment";
diff --git a/frontend/src/utils/types.ts b/frontend/src/utils/types.ts
new file mode 100644
index 0000000000..2b0cc23b0c
--- /dev/null
+++ b/frontend/src/utils/types.ts
@@ -0,0 +1 @@
+export type VueClass = string | Record<string, unknown> | Array<VueClass>;