Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(connection): open edit dialog with saved profile

t8y238f9fce779cc
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index b74150c1a2..855b95a53f 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -241,6 +241,7 @@ const driverProfiles: Record<
function profileForConfig(config: ConnectionConfig) {
if (config.driver_profile && driverProfiles[config.driver_profile]) return config.driver_profile;
+ if (config.db_type === "dameng") return "dm";
return config.db_type;
}
@@ -336,6 +337,7 @@ watch(
}
resetTestState();
},
+ { immediate: true },
);
const isEditing = ref(false);
diff --git a/apps/desktop/src/components/layout/AppDialogs.vue b/apps/desktop/src/components/layout/AppDialogs.vue
index c1c0d0c71e..adfa2ff8a5 100644
--- a/apps/desktop/src/components/layout/AppDialogs.vue
+++ b/apps/desktop/src/components/layout/AppDialogs.vue
@@ -70,6 +70,7 @@ const editConfig = computed(() => {
if (!id) return undefined;
return connectionStore.getConfig(id);
});
+const shouldShowConnectionDialog = computed(() => props.showConnectionDialog || !!editConfig.value);
watch(editConfig, (v) => {
if (v) emit("update:showConnectionDialog", true);
@@ -95,8 +96,8 @@ watch(
<template>
<ConnectionDialog
- v-if="showConnectionDialog || editConfig"
- :open="showConnectionDialog"
+ v-if="shouldShowConnectionDialog"
+ :open="shouldShowConnectionDialog"
:edit-config="editConfig"
@update:open="emit('update:showConnectionDialog', $event)"
@connect-started="emit('connectStarted', $event)"
diff --git a/packages/app-tests/connectionDialogEditOpen.test.ts b/packages/app-tests/connectionDialogEditOpen.test.ts
new file mode 100644
index 0000000000..3da2909bf5
--- /dev/null
+++ b/packages/app-tests/connectionDialogEditOpen.test.ts
@@ -0,0 +1,30 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+
+const appDialogsSource = readFileSync(
+ new URL("../../apps/desktop/src/components/layout/AppDialogs.vue", import.meta.url),
+ "utf8",
+);
+
+test("connection dialog opens when editing connection config is available", () => {
+ assert.match(
+ appDialogsSource,
+ /const shouldShowConnectionDialog = computed\(\(\) => props\.showConnectionDialog \|\| !!editConfig\.value\)/,
+ );
+ assert.match(appDialogsSource, /:open="shouldShowConnectionDialog"/);
+ assert.match(appDialogsSource, /v-if="shouldShowConnectionDialog"/);
+});
+
+const connectionDialogSource = readFileSync(
+ new URL("../../apps/desktop/src/components/connection/ConnectionDialog.vue", import.meta.url),
+ "utf8",
+);
+
+test("connection dialog initializes edit form on first mount", () => {
+ assert.match(connectionDialogSource, /watch\(\s*\(\) => props\.editConfig,[\s\S]*?\{\s*immediate: true\s*\},\s*\)/);
+});
+
+test("connection dialog maps legacy Dameng configs to the DM profile", () => {
+ assert.match(connectionDialogSource, /if \(config\.db_type === "dameng"\) return "dm";/);
+});
diff --git a/packages/app-tests/startupChunkBoundaries.test.ts b/packages/app-tests/startupChunkBoundaries.test.ts
index 69a033a132..cbdc8b8269 100644
--- a/packages/app-tests/startupChunkBoundaries.test.ts
+++ b/packages/app-tests/startupChunkBoundaries.test.ts
@@ -24,7 +24,11 @@ test("app dialogs keep non-primary dialogs out of the startup chunk", () => {
});
test("app dialogs only render async dialogs when their open state needs them", () => {
- assert.match(appDialogsSource, /<ConnectionDialog\s+v-if="showConnectionDialog \|\| editConfig"/);
+ assert.match(
+ appDialogsSource,
+ /const shouldShowConnectionDialog = computed\(\(\) => props\.showConnectionDialog \|\| !!editConfig\.value\)/,
+ );
+ assert.match(appDialogsSource, /<ConnectionDialog\s+v-if="shouldShowConnectionDialog"/);
assert.match(appDialogsSource, /<EditorSettingsDialog\s+v-if="showSettingsDialog"/);
assert.match(appDialogsSource, /<DangerConfirmDialog\s+v-if="showDangerDialog"/);
assert.match(appDialogsSource, /<DataTransferDialog\s+v-if="dialogs\.showTransferDialog\.value"/);