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): hide production protection for plugin connections

t8y284ae93aaa804
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index cfc1c26b03..46fb68a8a8 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -4110,8 +4110,9 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
config.keepalive_interval_secs = form.value.keepalive_interval_secs;
config.read_only = form.value.read_only;
config.save_password = form.value.save_password;
- config.is_production = form.value.is_production;
- config.production_databases = form.value.production_databases;
+ // 生产保护只拦截 SQL/数据编辑路径,插件连接走不到;表单已隐藏该区块,提交时清掉历史残留标志。
+ config.is_production = false;
+ config.production_databases = [];
} else {
config = { ...formValueForSubmit(), id } as LegacyConnectionConfig;
}
@@ -9027,7 +9028,7 @@ function openExternalUrl(url: string) {
</p>
</div>
</div>
- <div class="grid grid-cols-4 items-start gap-4 rounded-[6px] border border-red-500/25 bg-red-500/[0.035] px-3 py-2.5">
+ <div v-if="!isPluginConnection" class="grid grid-cols-4 items-start gap-4 rounded-[6px] border border-red-500/25 bg-red-500/[0.035] px-3 py-2.5">
<Label :class="[connectionLabelSmallClass, 'pt-0.5 text-red-700 dark:text-red-300']">
<span class="inline-flex items-center justify-end gap-1"><ShieldAlert class="h-3.5 w-3.5" />PROD</span>
</Label>
diff --git a/apps/desktop/src/lib/__tests__/connection/connectionDialogProductionSection.spec.ts b/apps/desktop/src/lib/__tests__/connection/connectionDialogProductionSection.spec.ts
new file mode 100644
index 0000000000..052f115782
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/connection/connectionDialogProductionSection.spec.ts
@@ -0,0 +1,18 @@
+import { readFileSync } from "node:fs";
+import { describe, expect, it } from "vitest";
+
+const dialogSource = readFileSync(new URL("../../../components/connection/ConnectionDialog.vue", import.meta.url), "utf8");
+
+describe("ConnectionDialog production protection section", () => {
+ it("hides the production protection section for plugin connections", () => {
+ expect(dialogSource).toContain('<div v-if="!isPluginConnection" class="grid grid-cols-4 items-start gap-4 rounded-[6px] border border-red-500/25 bg-red-500/[0.035] px-3 py-2.5">');
+ });
+
+ it("clears stale production flags when submitting plugin connections", () => {
+ const submitFn = dialogSource.slice(dialogSource.indexOf("function connectionConfigForSubmit"));
+ const pluginBranch = submitFn.slice(0, submitFn.indexOf("} else {"));
+ expect(pluginBranch).toContain("config.is_production = false;");
+ expect(pluginBranch).toContain("config.production_databases = [];");
+ expect(pluginBranch).not.toContain("config.is_production = form.value.is_production;");
+ });
+});