fix(gaussdb): display M mode JDBC connection URLs
This commit is contained in:
parent
b096e008e8
commit
165ad02375
|
|
@ -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<ConnectionConfig, "db_type" | "ssl">): 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)}@` : "";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { ConnectionConfig, DatabaseType } from "@/types/database";
|
||||
import { GAUSSDB_M_JDBC_DRIVER_PROFILE } from "@/lib/database/jdbcDialect";
|
||||
|
||||
type ConnectionPresentationConfig = Pick<ConnectionConfig, "db_type" | "driver_profile" | "driver_label" | "host" | "port" | "database">;
|
||||
type ConnectionNamePresentationConfig = ConnectionPresentationConfig & Pick<ConnectionConfig, "name">;
|
||||
|
|
@ -79,6 +80,37 @@ export function connectionRedactedNameLabel(connection?: ConnectionNamePresentat
|
|||
return hostNames.has(name) ? connectionRedactedEndpointLabel(connection) : name;
|
||||
}
|
||||
|
||||
export function connectionDisplayUrlScheme(connection: Pick<ConnectionConfig, "db_type"> & Partial<Pick<ConnectionConfig, "driver_profile" | "ssl">>): 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":
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue