mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(backup): hide unsupported database backup entries
This commit is contained in:
@@ -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({
|
||||
|
||||
+11
@@ -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/);
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user