From c2b8a1795a94364ccdfb628cfe25253c16295617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Tue, 14 Jul 2026 19:03:27 +0800 Subject: [PATCH] feat(sidebar): show connection group paths --- .../src/components/layout/EditorToolbar.vue | 13 +++- .../ui/searchable-select/SearchableSelect.vue | 44 ++++++++++++- 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__/sidebar/sidebarLayout.spec.ts | 37 +++++++++++ .../__tests__/tabs/tabPresentation.spec.ts | 66 ++++++++++++++++++- apps/desktop/src/lib/sidebar/sidebarLayout.ts | 47 +++++++++++++ apps/desktop/src/lib/tabs/tabPresentation.ts | 14 ++-- packages/app-tests/sidebarLayout.test.ts | 26 ++++++++ 14 files changed, 251 insertions(+), 10 deletions(-) create mode 100644 apps/desktop/src/lib/__tests__/sidebar/sidebarLayout.spec.ts diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue index 3e29b2c24..ff5799655 100644 --- a/apps/desktop/src/components/layout/EditorToolbar.vue +++ b/apps/desktop/src/components/layout/EditorToolbar.vue @@ -14,6 +14,7 @@ import { useSchemaOptions } from "@/composables/useSchemaOptions"; import { connectionIconType } from "@/lib/connection/connectionPresentation"; import { formatDatabaseLabel, isDefaultDatabase } from "@/lib/database/defaultDatabase"; import { connectionDisplayName } from "@/lib/tabs/tabPresentation"; +import { buildConnectionGroupPathMap } from "@/lib/sidebar/sidebarLayout"; import { isSingleDatabase, supportsSqlInListPaste, supportsTransaction as supportsTransactionFeature } from "@/lib/database/databaseCapabilities"; import { hexToRgba } from "@/lib/common/color"; import { productionContextForDatabase } from "@/lib/database/productionSafety"; @@ -66,6 +67,7 @@ const activeDatabaseOptions = computed(() => { }); const connectionOptionIds = computed(() => connectionStore.connections.map((connection) => connection.id)); +const connectionGroupPaths = computed(() => buildConnectionGroupPathMap(connectionStore.sidebarLayout)); const activeDatabaseValue = computed(() => props.activeTab.database || ""); const activeProductionContext = computed(() => productionContextForDatabase(props.activeConnection, props.activeTab.database)); const showConnectionProductionBadge = computed(() => activeProductionContext.value.reason === "connection"); @@ -154,6 +156,10 @@ function connectionById(connectionId: string): ConnectionConfig | undefined { return connectionStore.getConfig(connectionId); } +function connectionGroupLabel(connectionId: string): string { + return connectionGroupPaths.value.get(connectionId)?.join(" / ") || t("connectionGroup.ungroupedLabel"); +} + function databaseOptionIsProduction(database: string): boolean { if (!database || props.activeConnection?.is_production) return false; return productionContextForDatabase(props.activeConnection, database).reason === "database"; @@ -326,6 +332,8 @@ function databaseOptionIsProduction(database: string): boolean { :loading-text="t('common.loading')" trigger-class="font-medium text-foreground" :display-name="connectionDisplayName" + list-class="w-96 max-w-[calc(100vw-2rem)]" + item-class="h-9" @update:model-value="(connectionId) => emit('changeConnection', connectionId)" >