diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue index 3c13e5116..bec99ccaf 100644 --- a/apps/desktop/src/components/sidebar/TreeItem.vue +++ b/apps/desktop/src/components/sidebar/TreeItem.vue @@ -54,6 +54,7 @@ import { clearActiveTableReferencePayload, createTableReferencePayload, createTa import { formatSidebarObjectStorage } from "@/lib/sidebar/sidebarDatabaseStorage"; import { dataTabOpenModeFromTreeClick } from "@/lib/sidebar/dataTabOpenPolicy"; import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect"; +import { connectionDisplayUrlScheme } from "@/lib/connection/connectionPresentation"; import { hexToRgba } from "@/lib/common/color"; import { sidebarDisplayTableName } from "@/lib/sidebar/sidebarTableNameDisplay"; import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebar/sidebarLabelTooltip"; @@ -374,36 +375,6 @@ function redactedConnectionString(value: string): string { return value.replace(/(:\/\/[^/\s:@?#;]+):([^@\s/?#;]+)@/g, "$1:***@").replace(/([?&;](?:password|pwd|pass|token|secret|key)=)[^&;]*/gi, "$1***"); } -function connectionTooltipScheme(config: Pick): string { - switch (config.db_type) { - case "postgres": - case "gaussdb": - case "kwdb": - case "yashandb": - case "redshift": - case "questdb": - return "postgresql"; - case "sqlserver": - return "mssql"; - case "elasticsearch": - case "easysearch": - case "qdrant": - case "milvus": - case "weaviate": - case "chromadb": - case "rqlite": - case "turso": - case "mq": - return config.ssl ? "https" : "http"; - case "cloudflare-d1": - return "https"; - case "dameng": - return "dm"; - default: - return config.db_type; - } -} - function hostForDisplay(host: string): string { if (!host.includes(":") || host.startsWith("[") || host.includes("://")) return host; return `[${host}]`; @@ -422,7 +393,7 @@ function connectionTooltipUrl(config: ConnectionConfig): string { return `${config.db_type}://${host}`; } - const scheme = connectionTooltipScheme(config); + const scheme = connectionDisplayUrlScheme(config); const port = Number(config.port) > 0 ? `:${config.port}` : ""; const user = cleanTooltipValue(config.username); const userInfo = user ? `${encodeURIComponent(user)}@` : ""; diff --git a/apps/desktop/src/lib/connection/connectionPresentation.ts b/apps/desktop/src/lib/connection/connectionPresentation.ts index 8590d60d3..f5a241109 100644 --- a/apps/desktop/src/lib/connection/connectionPresentation.ts +++ b/apps/desktop/src/lib/connection/connectionPresentation.ts @@ -1,4 +1,5 @@ import type { ConnectionConfig, DatabaseType } from "@/types/database"; +import { GAUSSDB_M_JDBC_DRIVER_PROFILE } from "@/lib/database/jdbcDialect"; type ConnectionPresentationConfig = Pick; type ConnectionNamePresentationConfig = ConnectionPresentationConfig & Pick; @@ -79,6 +80,37 @@ export function connectionRedactedNameLabel(connection?: ConnectionNamePresentat return hostNames.has(name) ? connectionRedactedEndpointLabel(connection) : name; } +export function connectionDisplayUrlScheme(connection: Pick & Partial>): string { + switch (connection.db_type) { + case "postgres": + case "kwdb": + case "yashandb": + case "redshift": + case "questdb": + return "postgresql"; + case "gaussdb": + return connection.driver_profile?.toLowerCase() === GAUSSDB_M_JDBC_DRIVER_PROFILE ? "jdbc:gaussdb" : "postgresql"; + case "sqlserver": + return "mssql"; + case "elasticsearch": + case "easysearch": + case "qdrant": + case "milvus": + case "weaviate": + case "chromadb": + case "rqlite": + case "turso": + case "mq": + return connection.ssl ? "https" : "http"; + case "cloudflare-d1": + return "https"; + case "dameng": + return "dm"; + default: + return connection.db_type; + } +} + export function connectionUrlPlaceholder(dbType: DatabaseType): string { switch (dbType) { case "mysql": diff --git a/packages/app-tests/connectionPresentation.test.ts b/packages/app-tests/connectionPresentation.test.ts index 70106d30c..a79082a32 100644 --- a/packages/app-tests/connectionPresentation.test.ts +++ b/packages/app-tests/connectionPresentation.test.ts @@ -1,7 +1,7 @@ import { test } from "vitest"; import assert from "node:assert/strict"; import type { ConnectionConfig } from "../../apps/desktop/src/types/database.ts"; -import { connectionDriverLabel, connectionEndpointLabel, connectionIconType, connectionOptionSubtitle, connectionRedactedEndpointLabel, connectionRedactedNameLabel, connectionRedactedOptionSubtitle } from "../../apps/desktop/src/lib/connection/connectionPresentation.ts"; +import { connectionDisplayUrlScheme, connectionDriverLabel, connectionEndpointLabel, connectionIconType, connectionOptionSubtitle, connectionRedactedEndpointLabel, connectionRedactedNameLabel, connectionRedactedOptionSubtitle } from "../../apps/desktop/src/lib/connection/connectionPresentation.ts"; const baseConnection: ConnectionConfig = { id: "conn-1", @@ -20,6 +20,11 @@ test("uses driver profile for connection option icon identity", () => { assert.equal(connectionIconType(baseConnection), "tidb"); }); +test("displays the configured GaussDB protocol in connection URLs", () => { + assert.equal(connectionDisplayUrlScheme({ db_type: "gaussdb", driver_profile: "gaussdb" }), "postgresql"); + assert.equal(connectionDisplayUrlScheme({ db_type: "gaussdb", driver_profile: "gaussdb-m" }), "jdbc:gaussdb"); +}); + test("builds a compact subtitle for duplicate connection names", () => { assert.equal(connectionDriverLabel(baseConnection), "TiDB"); assert.equal(connectionEndpointLabel(baseConnection), "127.0.0.1:4000");