diff --git a/src-tauri/src/models/connection.rs b/src-tauri/src/models/connection.rs index db7c3017d7..00de06c8d7 100644 --- a/src-tauri/src/models/connection.rs +++ b/src-tauri/src/models/connection.rs @@ -12,6 +12,8 @@ pub struct ConnectionConfig { pub password: String, pub database: Option, #[serde(default)] + pub color: Option, + #[serde(default)] pub ssh_enabled: bool, #[serde(default)] pub ssh_host: String, @@ -125,6 +127,7 @@ mod tests { username: username.to_string(), password: password.to_string(), database: database.map(str::to_string), + color: None, ssh_enabled: false, ssh_host: String::new(), ssh_port: 22, diff --git a/src/App.vue b/src/App.vue index d36e1a7f08..0ebf24af95 100644 --- a/src/App.vue +++ b/src/App.vue @@ -110,12 +110,33 @@ function connectionDisplayName(connectionId: string): string { return connectionStore.getConfig(connectionId)?.name || connectionId; } +function connectionColor(connectionId: string): string { + return connectionStore.getConfig(connectionId)?.color || ""; +} + function databaseDisplayName(database: string): string { const connection = activeConnection.value; if (connection?.db_type === "redis" && database !== "") return `db${database}`; return database || t("editor.noDatabase"); } +function tabDisplayTitle(tab: typeof queryStore.tabs[number]): string { + const database = databaseDisplayNameForTab(tab.connectionId, tab.database); + if (tab.mode === "data" && tab.tableMeta?.tableName) { + return `${database} | ${tab.tableMeta.tableName}`; + } + if (tab.mode === "query") { + return `${connectionDisplayName(tab.connectionId)} | ${database}`; + } + return tab.title; +} + +function databaseDisplayNameForTab(connectionId: string, database: string): string { + const connection = connectionStore.getConfig(connectionId); + if (connection?.db_type === "redis" && database !== "") return `db${database}`; + return database || t("editor.noDatabase"); +} + async function loadDatabaseOptions(connectionId: string) { const connection = connectionStore.getConfig(connectionId); if (!connection || loadingDatabaseOptions.value[connectionId]) return; @@ -526,7 +547,8 @@ async function setupFileDrop() { :class="{ 'bg-background font-medium': tab.id === queryStore.activeTabId }" @click="queryStore.activeTabId = tab.id" > - {{ tab.title }} + + {{ tabDisplayTitle(tab) }}