Skip to content

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

feat(frontend): display a tag for pitr databases (#1661)

Liu Jif3edfab26ad0
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index 5285e372f4..512840abc1 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -1,7 +1,7 @@
<template>
<BBTable
:column-list="columnList"
- :data-source="sortedDatabaseList"
+ :data-source="mixedDatabaseList"
:show-header="true"
:left-bordered="bordered"
:right-bordered="bordered"
@@ -11,9 +11,15 @@
@click-row="clickDatabase"
>
<template #body="{ rowData: database }: { rowData: Database }">
- <BBTableCell :left-padding="4" class="w-16">
- <div class="flex flex-row items-center space-x-1 tooltip-wrapper">
+ <BBTableCell :left-padding="4">
+ <div class="flex items-center space-x-2 tooltip-wrapper">
<span>{{ database.name }}</span>
+ <BBBadge
+ v-if="isPITRDatabase(database)"
+ text="PITR"
+ :can-remove="false"
+ class="text-xs"
+ />
<div v-if="!showMiscColumn && database.syncStatus != 'OK'">
<span class="tooltip">
{{
@@ -27,7 +33,7 @@
</div>
</div>
</BBTableCell>
- <BBTableCell v-if="showProjectColumn" class="w-16">
+ <BBTableCell v-if="showProjectColumn" class="w-[20%]">
<div class="flex flex-row space-x-2 items-center">
<div>{{ projectName(database.project) }}</div>
<div class="tooltip-wrapper">
@@ -50,16 +56,16 @@
</div>
</div>
</BBTableCell>
- <BBTableCell v-if="showEnvironmentColumn" class="w-16">
+ <BBTableCell v-if="showEnvironmentColumn" class="w-[10%]">
{{ environmentName(database.instance.environment) }}
</BBTableCell>
- <BBTableCell v-if="showInstanceColumn" class="w-32">
+ <BBTableCell v-if="showInstanceColumn" class="w-[20%]">
<div class="flex flex-row items-center space-x-1">
<InstanceEngineIcon :instance="database.instance" />
<span>{{ instanceName(database.instance) }}</span>
</div>
</BBTableCell>
- <BBTableCell v-if="showMiscColumn" class="w-4">
+ <BBTableCell v-if="showMiscColumn" class="w-[8%]">
<span
:class="{
'text-error': database.syncStatus === 'NOT_FOUND',
@@ -68,16 +74,35 @@
{{ database.syncStatus }}
</span>
</BBTableCell>
- <BBTableCell v-if="showMiscColumn" class="w-16">
+ <BBTableCell v-if="showMiscColumn" class="w-[14%]">
{{ humanizeTs(database.lastSuccessfulSyncTs) }}
</BBTableCell>
- <BBTableCell v-if="showSQLEditorLink" class="w-16">
+ <BBTableCell v-if="showSQLEditorLink" class="w-[8%]">
<button class="btn-icon" @click.stop="gotoSQLEditor(database)">
<heroicons-outline:terminal class="w-4 h-4" />
</button>
</BBTableCell>
</template>
+
+ <template
+ v-if="hasReservedDatabases && !state.showReservedDatabaseList"
+ #footer
+ >
+ <tfoot>
+ <tr>
+ <td :colspan="columnList.length" class="p-0">
+ <div
+ class="flex items-center justify-center cursor-pointer hover:bg-gray-200 py-2 text-gray-400 text-sm"
+ @click="state.showReservedDatabaseList = true"
+ >
+ {{ $t("database.show-reserved-databases") }}
+ </div>
+ </td>
+ </tr>
+ </tfoot>
+ </template>
</BBTable>
+
<BBModal
v-if="state.showIncorrectProjectModal"
:title="$t('common.warning')"
@@ -121,6 +146,7 @@ type Mode = "ALL" | "ALL_SHORT" | "INSTANCE" | "PROJECT" | "PROJECT_SHORT";
interface State {
showIncorrectProjectModal: boolean;
warningDatabase?: Database;
+ showReservedDatabaseList: boolean;
}
const props = defineProps({
@@ -156,6 +182,7 @@ const router = useRouter();
const { t } = useI18n();
const state = reactive<State>({
showIncorrectProjectModal: false,
+ showReservedDatabaseList: false,
});
const sortedDatabaseList = computed(() => {
@@ -172,6 +199,25 @@ const sortedDatabaseList = computed(() => {
return list;
});
+const regularDatabaseList = computed(() =>
+ sortedDatabaseList.value.filter((db) => !isPITRDatabase(db))
+);
+const reservedDatabaseList = computed(() =>
+ sortedDatabaseList.value.filter((db) => isPITRDatabase(db))
+);
+const hasReservedDatabases = computed(
+ () => reservedDatabaseList.value.length > 0
+);
+
+const mixedDatabaseList = computed(() => {
+ const tableList = [...regularDatabaseList.value];
+ if (state.showReservedDatabaseList) {
+ tableList.push(...reservedDatabaseList.value);
+ }
+
+ return tableList;
+});
+
const columnListMap = computed(() => {
return new Map([
[
@@ -345,4 +391,10 @@ const clickDatabase = (section: number, row: number, e: MouseEvent) => {
}
}
};
+
+function isPITRDatabase(db: Database): boolean {
+ const { name } = db;
+ // A pitr database's name is xxx_pitr_1234567890 or xxx_pitr_1234567890_old
+ return !!name.match(/^(.+?)_pitr_(\d+)(_old)?$/);
+}
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 71d6a8b0dc..3129c620fc 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -817,7 +817,8 @@
"no-earlier-than": "Restore point-in-time cannot be earlier than [{earliest}] (the earliest available backup).",
"no-later-than-now": "Restore point-in-time cannot be later than now."
},
- "show-reserved-tables": "Show bytebase reserved tables"
+ "show-reserved-tables": "Show Bytebase reserved tables",
+ "show-reserved-databases": "Show Bytebase reserved databases"
},
"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 d40149b0c8..9ea0301a26 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -817,7 +817,8 @@
"no-earlier-than": "恢复的时间点不能早于 [{earliest}] (最早可用的备份)。",
"no-later-than-now": "恢复的时间点不能晚于当前时间。"
},
- "show-reserved-tables": "显示 bytebase 保留的表"
+ "show-reserved-tables": "显示 Bytebase 保留的表",
+ "show-reserved-databases": "显示 Bytebase 保留的数据库"
},
"repository": {
"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",