fix(backup): hide unsupported database backup entries

This commit is contained in:
zipg
2026-08-24 21:29:21 +08:00
committed by GitHub
parent 6baf17f609
commit 992ac00aff
3 changed files with 23 additions and 3 deletions
@@ -174,6 +174,7 @@ import { runBatchTableTruncate } from "@/lib/table/batchTableTruncate";
import { runBatchTableDrop } from "@/lib/table/batchTableDrop";
import { buildSidebarDdlTemplateSql, sidebarDdlTargetsForExecutionContext } from "@/lib/sidebar/sidebarDdlTemplate";
import { sidebarStructureExportTargets } from "@/lib/sidebar/sidebarExportRuntime";
import { supportsScheduledDatabaseBackup } from "@/lib/backup/scheduledDatabaseBackup";
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import { copyToClipboard } from "@/lib/common/clipboard";
import { rankSavedSqlHistory, type SavedSqlHistoryScope } from "@/lib/savedSql/savedSqlHistory";
@@ -4076,6 +4077,13 @@ const canExportAllDatabases = computed(() => {
return !["redis", "mongodb", "dynamodb", "elasticsearch", "easysearch", "meilisearch", "qdrant", "milvus", "weaviate", "chromadb", "etcd", "zookeeper", "consul", "mq", "nacos"].includes(dbType || "");
});
const canOpenScheduledBackups = computed(() => {
// Match the backup page/engine, which filter and key off the raw db_type
// (effectiveDatabaseTypeForConnection maps gbase/mysql-dialect jdbc to "mysql",
// which would show an entry the backup dialog then can't list).
return isTauriRuntime() && supportsScheduledDatabaseBackup(rawDatabaseType());
});
const canOpenDiagram = computed(() => {
return !!activeNode.value.database && supportsSchemaDiagram(currentDatabaseType());
});
@@ -4872,9 +4880,9 @@ function buildConnectionSidebarMenu(context: SidebarMenuFactoryContext): boolean
}
if (canExportAllDatabases.value) {
items.push({ label: t("contextMenu.exportAllDatabases"), action: openAllDatabasesExport, icon: Upload });
if (isTauriRuntime()) {
items.push({ label: t("databaseBackup.title"), action: openScheduledBackups, icon: CalendarClock });
}
}
if (canOpenScheduledBackups.value) {
items.push({ label: t("databaseBackup.title"), action: openScheduledBackups, icon: CalendarClock });
}
if (canCreateDatabase.value) {
items.push({
@@ -0,0 +1,11 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const source = readFileSync(new URL("../SidebarTreeRuntimeHost.vue", import.meta.url), "utf8");
describe("SidebarTreeRuntimeHost database backup menu", () => {
it("uses the database backup support matrix independently from full-database export", () => {
expect(source).toMatch(/const canOpenScheduledBackups = computed\(\(\) => \{[\s\S]*supportsScheduledDatabaseBackup\(rawDatabaseType\(\)\)/);
expect(source).toMatch(/if \(canOpenScheduledBackups\.value\) \{[\s\S]*action: openScheduledBackups/);
});
});
+1
View File
@@ -268,6 +268,7 @@ test("explicit backup databases fail when any configured target is missing", ()
test("scheduled backups are limited to databases with consistent snapshot support", () => {
assert.equal(supportsScheduledDatabaseBackup("postgres"), true);
assert.equal(supportsScheduledDatabaseBackup("mysql"), true);
assert.equal(supportsScheduledDatabaseBackup("dameng"), false);
assert.equal(supportsScheduledDatabaseBackup("sqlite"), false);
assert.equal(supportsScheduledDatabaseBackup("sqlserver"), false);
});