From 74c603ee9d07ff0528063a928245da4eacee825e Mon Sep 17 00:00:00 2001 From: zipg Date: Mon, 27 Jul 2026 17:01:23 +0800 Subject: [PATCH] feat(connection): add editable connection notes --- .../connection/ConnectionDialog.vue | 37 ++++++++++++++++++- apps/desktop/src/i18n/locales/en.ts | 2 + apps/desktop/src/i18n/locales/es.ts | 2 + apps/desktop/src/i18n/locales/it.ts | 2 + apps/desktop/src/i18n/locales/ja.ts | 2 + apps/desktop/src/i18n/locales/pt-BR.ts | 2 + apps/desktop/src/i18n/locales/zh-CN.ts | 2 + apps/desktop/src/i18n/locales/zh-TW.ts | 2 + .../__tests__/connectionDatabaseInfo.spec.ts | 1 + .../lib/connection/connectionDatabaseInfo.ts | 2 +- .../connectionStore.databaseInfo.spec.ts | 25 +++++++++++++ apps/desktop/src/stores/connectionStore.ts | 2 + apps/desktop/src/types/database.ts | 1 + crates/dbx-core/src/agent_connection.rs | 1 + crates/dbx-core/src/cloud_sync.rs | 3 ++ crates/dbx-core/src/connection.rs | 1 + crates/dbx-core/src/connection_secrets.rs | 1 + crates/dbx-core/src/db/redis_driver.rs | 1 + crates/dbx-core/src/models/connection.rs | 20 ++++++++++ crates/dbx-core/src/mq/config.rs | 1 + crates/dbx-core/src/mq/service.rs | 1 + crates/dbx-core/src/nacos/config.rs | 1 + crates/dbx-core/src/nacos/service.rs | 2 + crates/dbx-core/src/production_safety.rs | 1 + crates/dbx-core/src/query.rs | 2 + crates/dbx-core/src/schema.rs | 1 + crates/dbx-core/src/storage.rs | 2 + crates/dbx-core/src/transfer.rs | 1 + .../tests/database_export_prefetch.rs | 1 + .../live_postgres_query_result_export.rs | 1 + .../dbx-core/tests/live_postgres_transfer.rs | 1 + .../tests/live_sqlserver_completion.rs | 1 + .../live_sqlserver_query_result_export.rs | 1 + crates/dbx-web/src/routes/connection.rs | 1 + src-tauri/src/commands/connection.rs | 1 + 35 files changed, 126 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue index 53bcb489d..23231b3ca 100644 --- a/apps/desktop/src/components/connection/ConnectionDialog.vue +++ b/apps/desktop/src/components/connection/ConnectionDialog.vue @@ -213,6 +213,7 @@ function initialConfigTab(): ConfigTab { const defaultForm = (): ConnectionForm => ({ name: "", + note: "", db_type: "mysql", driver_profile: "mysql", driver_label: "MySQL", @@ -444,6 +445,23 @@ function sshLayersForConfig(config: LegacyConnectionConfig): SshTunnelConfig[] { } const form = ref(defaultForm()); +const noteTextareaRef = ref(null); + +function resizeNoteTextarea() { + const textarea = noteTextareaRef.value; + if (!textarea) return; + + const style = window.getComputedStyle(textarea); + const lineHeight = Number.parseFloat(style.lineHeight) || 20; + const paddingHeight = (Number.parseFloat(style.paddingTop) || 0) + (Number.parseFloat(style.paddingBottom) || 0); + const borderHeight = (Number.parseFloat(style.borderTopWidth) || 0) + (Number.parseFloat(style.borderBottomWidth) || 0); + const maxContentHeight = lineHeight * 3 + paddingHeight; + + textarea.style.height = "auto"; + textarea.style.height = `${Math.min(textarea.scrollHeight, maxContentHeight) + borderHeight}px`; + textarea.style.overflowY = textarea.scrollHeight > maxContentHeight ? "auto" : "hidden"; +} + const showJdbcDependencyDriverManagerAction = computed(() => form.value.db_type === "jdbc" && isJdbcMissingRuntimeDependencyError(connectionErrorDetail.value)); function externalConfigRecord(value: unknown): Record { @@ -517,6 +535,9 @@ const dbPickerView = ref(loadConnectionPickerView()); const dbSearchQuery = ref(""); const selectedDbCategory = ref("sql"); const configTab = ref("connection"); +watch([() => form.value.note, configTab, dialogStep, open], () => { + void nextTick(resizeNoteTextarea); +}); const MQ_KAFKA_SECURITY_PROTOCOL_AUTO = "__auto"; const mqAdminUrl = ref("http://127.0.0.1:8080"); const mqSystemKind = ref("pulsar"); @@ -1922,6 +1943,7 @@ watch( const profileConfig = driverProfiles[profile]; form.value = { name: config.name, + note: config.note || "", db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type, driver_profile: oceanbasePatch?.driver_profile || profile, driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type, @@ -3035,6 +3057,7 @@ function generateConnectionName(): string { function connectionConfigForSubmit(id: string, generatedName = ""): ConnectionConfig { const config = { ...formValueForSubmit(), id } as LegacyConnectionConfig; config.database_info = undefined; + config.note = config.note?.trim() || undefined; if (selectedType.value === "oceanbase" && (config.driver_profile === "oceanbase" || config.driver_profile === "oceanbase-oracle")) { Object.assign(config, oceanbaseModeConnectionPatch(oceanbaseSubMode.value)); } @@ -4744,7 +4767,7 @@ function openExternalUrl(url: string) { -
+
@@ -6148,6 +6171,18 @@ function openExternalUrl(url: string) {
+ +
+ +