feat(tabs): add connection database table hierarchy
This commit is contained in:
21 files changed
+637
-39
No files matched your search
@@ -7497,6 +7497,7 @@ onUnmounted(() => {
|
||||
<SelectItem value="database-type">{{ t("settings.tabGroupDatabaseType") }}</SelectItem>
|
||||
<SelectItem value="database">{{ t("settings.tabGroupDatabase") }}</SelectItem>
|
||||
<SelectItem value="connection">{{ t("settings.tabGroupConnection") }}</SelectItem>
|
||||
<SelectItem value="sidebar">{{ t("settings.tabGroupSidebar") }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -70,6 +70,7 @@ import { Input } from "@/components/ui/input";
|
||||
import { appTabActiveBackground, appTabActiveIndicator } from "@/lib/tabs/tabPresentation";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ConnectionIcon from "@/components/icons/ConnectionIcon.vue";
|
||||
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
|
||||
import TabExecutionStatus from "@/components/layout/TabExecutionStatus.vue";
|
||||
import TabModeIcon from "@/components/layout/TabModeIcon.vue";
|
||||
@@ -82,12 +83,15 @@ import { useTabScroll } from "@/composables/useTabScroll";
|
||||
import { useToast } from "@/composables/useToast";
|
||||
import { hexToRgba } from "@/lib/common/color";
|
||||
import { copyToClipboard } from "@/lib/common/clipboard";
|
||||
import { redisDatabaseLabel } from "@/lib/redis/redisDatabaseAlias";
|
||||
import { parseTabDragPayload, serializeTabDragPayload } from "@/lib/tabs/tabDrag";
|
||||
import { createCloseAllTabMenuItem, createCloseLeftTabMenuItem, createCloseOtherTabMenuItem, createCloseRightTabMenuItem, createCloseTabMenuItem, createLocateTabMenuItem, createPinTabMenuItem, createRenameDuplicateTabItems } from "@/lib/tabs/tabMenu";
|
||||
import { tabConnectionColor, dirtyTabTitleStyle, tabColorStyle as sharedTabColorStyle, tabDatabaseIconType, tabDisplayTitle, tabDisplayTitles, tabIconClass, tabTooltipLines } from "@/lib/tabs/tabPresentation";
|
||||
import { activeTabSidebarTarget } from "@/lib/sidebar/sidebarActiveTabTarget";
|
||||
import "./appTabBar.css";
|
||||
import type { QueryTab } from "@/types/database";
|
||||
import { buildConnectionDatabaseTabGroupStripEntries, type TabGroupTreeGuide } from "@/lib/tabs/tabGroupTree";
|
||||
import TabGroupTreeGuides from "./TabGroupTreeGuides.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
groupId: string;
|
||||
@@ -176,6 +180,7 @@ const isWrapLayout = computed(() => !isVerticalLayout.value && settingsStore.edi
|
||||
// The icon-only collapse only exists in the vertical toolbar; horizontal
|
||||
// placements must ignore the persisted collapse state entirely.
|
||||
const isTabBarCollapsed = computed(() => isVerticalLayout.value && !!props.tabBarCollapsed);
|
||||
const showTabTreeGuides = computed(() => isVerticalLayout.value && !isTabBarCollapsed.value && settingsStore.editorSettings.tabGroupMode === "sidebar");
|
||||
// Outer [data-workspace-tab-navigation] / [data-special-page-navigation] owns
|
||||
// the shared vertical rail width; fill that rail so nested pane bars stay in
|
||||
// sync while the resize handle updates the outer panel (issue #9977).
|
||||
@@ -353,6 +358,7 @@ const tabGroupItems = computed(() => [
|
||||
{ value: "database-type", label: t("settings.tabGroupDatabaseType") },
|
||||
{ value: "database", label: t("settings.tabGroupDatabase") },
|
||||
{ value: "connection", label: t("settings.tabGroupConnection") },
|
||||
{ value: "sidebar", label: t("settings.tabGroupSidebar") },
|
||||
]);
|
||||
const tabSortItems = computed(() => [
|
||||
{ value: "manual", label: t("settings.tabSortManual") },
|
||||
@@ -377,7 +383,7 @@ async function persistTabPreferences(partial: TabPreferencePatch) {
|
||||
}
|
||||
|
||||
function updateTabGroupMode(value: string) {
|
||||
if (value === "none" || value === "database-type" || value === "database" || value === "connection") void persistTabPreferences({ tabGroupMode: value });
|
||||
if (value === "none" || value === "database-type" || value === "database" || value === "connection" || value === "sidebar") void persistTabPreferences({ tabGroupMode: value });
|
||||
}
|
||||
|
||||
function updateTabSortMode(value: string) {
|
||||
@@ -399,6 +405,7 @@ function databaseTabGroupKey(tab: QueryTab) {
|
||||
|
||||
function tabGroupKey(tab: QueryTab) {
|
||||
const connection = connectionStore.getConfig(tab.connectionId);
|
||||
if (settingsStore.editorSettings.tabGroupMode === "sidebar") return tab.connectionId;
|
||||
if (settingsStore.editorSettings.tabGroupMode === "connection") return tab.connectionId;
|
||||
if (settingsStore.editorSettings.tabGroupMode === "database") return databaseTabGroupKey(tab);
|
||||
return connection?.driver_profile || connection?.db_type || tab.connectionId || "unknown";
|
||||
@@ -436,6 +443,12 @@ function databaseTabGroupBaseLabel(tab: QueryTab) {
|
||||
return [tab.database, ...(tab.catalog ? [tab.catalog] : [])].join(" · ");
|
||||
}
|
||||
|
||||
function hierarchyDatabaseLabel(tab: QueryTab) {
|
||||
const connection = connectionStore.getConfig(tab.connectionId);
|
||||
if (connection?.db_type === "redis" && tab.database !== "") return redisDatabaseLabel(tab.database, connection.redis_database_aliases);
|
||||
return tab.database ? databaseTabGroupBaseLabel(tab) : tab.catalog || tabConnectionLabel(tab);
|
||||
}
|
||||
|
||||
const databaseTabGroupIdentityDisplaysByLabel = computed(() => {
|
||||
const identitiesByLabel = new Map<string, Map<string, { connectionLabel: string; connectionTargetLabel: string }>>();
|
||||
for (const tab of props.tabs) {
|
||||
@@ -497,6 +510,7 @@ const editingTabGroupFallbackColor = ref(tabGroupPalette[0]!);
|
||||
|
||||
function tabGroupDefaultLabel(tab: QueryTab) {
|
||||
const connection = connectionStore.getConfig(tab.connectionId);
|
||||
if (settingsStore.editorSettings.tabGroupMode === "sidebar") return tabConnectionLabel(tab);
|
||||
if (settingsStore.editorSettings.tabGroupMode === "connection") return connection?.name || tab.connectionId;
|
||||
if (settingsStore.editorSettings.tabGroupMode === "database") {
|
||||
const baseLabel = databaseTabGroupBaseLabel(tab);
|
||||
@@ -513,7 +527,8 @@ function tabGroupDefaultLabel(tab: QueryTab) {
|
||||
}
|
||||
|
||||
function tabGroupCustomizationKey(tab: QueryTab) {
|
||||
return `${settingsStore.editorSettings.tabGroupMode}:${tabGroupKey(tab)}`;
|
||||
const mode = settingsStore.editorSettings.tabGroupMode === "sidebar" ? "connection" : settingsStore.editorSettings.tabGroupMode;
|
||||
return `${mode}:${tabGroupKey(tab)}`;
|
||||
}
|
||||
|
||||
function tabGroupCustomization(tab: QueryTab) {
|
||||
@@ -529,18 +544,27 @@ function tabGroupId(tab: QueryTab) {
|
||||
return `${tab.pinned ? "fixed" : "regular"}:${settingsStore.editorSettings.tabGroupMode}:${tabGroupKey(tab)}`;
|
||||
}
|
||||
|
||||
function isTabGroupCollapsed(tab: QueryTab) {
|
||||
if (settingsStore.editorSettings.tabGroupMode === "none") return false;
|
||||
return collapsedTabGroups.value.has(tabGroupId(tab));
|
||||
function isGroupCollapsed(groupId: string) {
|
||||
return settingsStore.editorSettings.tabGroupMode !== "none" && collapsedTabGroups.value.has(groupId);
|
||||
}
|
||||
|
||||
const activeTabGroupId = computed(() => {
|
||||
const activeTabGroupIds = computed(() => {
|
||||
const activeTab = props.tabs.find((item) => isTabActive(item));
|
||||
return activeTab ? tabGroupId(activeTab) : null;
|
||||
if (!activeTab) return new Set<string>();
|
||||
if (settingsStore.editorSettings.tabGroupMode !== "sidebar") return new Set([tabGroupId(activeTab)]);
|
||||
const ids = new Set<string>();
|
||||
for (const section of stripSections.value) {
|
||||
const entry = section.entries.find((item) => item.kind === "tab" && item.tab.id === activeTab.id);
|
||||
if (entry?.kind === "tab") {
|
||||
entry.ancestorIds.forEach((id) => ids.add(id));
|
||||
ids.add(entry.groupId);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
});
|
||||
|
||||
function isTabGroupActive(tab: QueryTab) {
|
||||
return activeTabGroupId.value === tabGroupId(tab);
|
||||
function isGroupActive(groupId: string) {
|
||||
return activeTabGroupIds.value.has(groupId);
|
||||
}
|
||||
|
||||
function preserveTabScrollPosition() {
|
||||
@@ -643,9 +667,8 @@ function handleTabGroupTransitionEnd(event: TransitionEvent) {
|
||||
refreshHorizontalTabOverflow();
|
||||
}
|
||||
|
||||
function toggleTabGroup(tab: QueryTab) {
|
||||
function toggleTabGroupById(groupId: string) {
|
||||
preserveTabScrollPosition();
|
||||
const groupId = tabGroupId(tab);
|
||||
if (collapsingTabGroups.value.has(groupId)) {
|
||||
cancelTabGroupCollapse(groupId);
|
||||
}
|
||||
@@ -663,6 +686,9 @@ function toggleTabGroup(tab: QueryTab) {
|
||||
|
||||
function tabGroupIdsInPane() {
|
||||
if (settingsStore.editorSettings.tabGroupMode === "none") return [];
|
||||
if (settingsStore.editorSettings.tabGroupMode === "sidebar") {
|
||||
return [...new Set(stripSections.value.flatMap((section) => section.entries.filter((entry) => entry.kind === "header").map((entry) => entry.groupId)))];
|
||||
}
|
||||
return [...new Set(props.tabs.map((tab) => tabGroupId(tab)))];
|
||||
}
|
||||
|
||||
@@ -682,11 +708,12 @@ function expandTabGroupForTab(tabId: string | null) {
|
||||
if (!tabId || settingsStore.editorSettings.tabGroupMode === "none") return;
|
||||
const tab = queryStore.tabs.find((item) => item.id === tabId);
|
||||
if (!tab) return;
|
||||
const groupId = tabGroupId(tab);
|
||||
cancelTabGroupCollapse(groupId);
|
||||
if (!collapsedTabGroups.value.has(groupId)) return;
|
||||
const groupIds = settingsStore.editorSettings.tabGroupMode === "sidebar" ? stripSections.value.flatMap((section) => section.entries.filter((entry) => entry.kind === "tab" && entry.tab.id === tabId).flatMap((entry) => [entry.groupId, ...entry.ancestorIds])) : [tabGroupId(tab)];
|
||||
groupIds.forEach((groupId) => cancelTabGroupCollapse(groupId));
|
||||
const hidden = groupIds.filter((groupId) => collapsedTabGroups.value.has(groupId));
|
||||
if (!hidden.length) return;
|
||||
const next = new Set(collapsedTabGroups.value);
|
||||
next.delete(groupId);
|
||||
hidden.forEach((groupId) => next.delete(groupId));
|
||||
collapsedTabGroups.value = next;
|
||||
}
|
||||
|
||||
@@ -712,6 +739,56 @@ function tabGroupStyle(tab: QueryTab): CSSProperties {
|
||||
return groupColorStyle(resolvedTabGroupColor(tab));
|
||||
}
|
||||
|
||||
function tabGroupStyleForEntry(entry: Extract<StripEntry, { kind: "header" }>): CSSProperties {
|
||||
if (entry.level === "connection") return tabGroupStyle(entry.tab);
|
||||
return tabGroupStyleForGroupId(entry.groupId);
|
||||
}
|
||||
|
||||
function tabGroupStyleForGroupId(groupId: string): CSSProperties {
|
||||
let hash = 0;
|
||||
for (const character of groupId) hash = (hash * 31 + character.codePointAt(0)!) | 0;
|
||||
return groupColorStyle(tabGroupPalette[Math.abs(hash) % tabGroupPalette.length]!);
|
||||
}
|
||||
|
||||
function tabGroupStyleForTabEntry(entry: Extract<StripEntry, { kind: "tab" }>): CSSProperties {
|
||||
return settingsStore.editorSettings.tabGroupMode === "sidebar" ? tabGroupStyleForGroupId(entry.groupId) : tabGroupStyle(entry.tab);
|
||||
}
|
||||
|
||||
function tabGroupHeaderDepthStyle(entry: Extract<StripEntry, { kind: "header" }>): CSSProperties | undefined {
|
||||
if (!isVerticalLayout.value || isTabBarCollapsed.value || settingsStore.editorSettings.tabGroupMode !== "sidebar") return undefined;
|
||||
return {
|
||||
"--tab-group-depth-offset": `${entry.depth * 0.75}rem`,
|
||||
...tabGroupTreeRowStyle(entry),
|
||||
} as CSSProperties;
|
||||
}
|
||||
|
||||
function tabGroupTreeRowStyle(entry: StripEntry): CSSProperties | undefined {
|
||||
if (!showTabTreeGuides.value) return undefined;
|
||||
const parentColor = resolvedTabGroupColor(entry.tab);
|
||||
const childColor = entry.kind === "header" && entry.level === "connection" ? parentColor : tabGroupPalette[Math.abs([...entry.groupId].reduce((hash, character) => (hash * 31 + character.codePointAt(0)!) | 0, 0)) % tabGroupPalette.length]!;
|
||||
return {
|
||||
"--tab-tree-guide-base-x": entry.kind === "header" ? "calc(var(--tab-group-root-rail-x) - var(--tab-group-header-inset))" : "var(--tab-group-root-rail-x)",
|
||||
"--tab-tree-guide-child-x": entry.kind === "header" ? `calc(var(--tab-group-root-rail-x) - var(--tab-group-header-inset) + ${entry.depth * 0.75}rem)` : `calc(var(--tab-group-tab-inset) + ${entry.depth * 0.5}rem)`,
|
||||
"--tab-tree-parent-color": parentColor,
|
||||
"--tab-tree-child-color": childColor,
|
||||
...(entry.kind === "header" ? tabGroupStyleForEntry(entry) : tabGroupStyleForTabEntry(entry)),
|
||||
} as CSSProperties;
|
||||
}
|
||||
|
||||
function tabGroupTabDepthStyle(entry: Extract<StripEntry, { kind: "tab" }>): CSSProperties | undefined {
|
||||
if (!isVerticalLayout.value || isTabBarCollapsed.value || settingsStore.editorSettings.tabGroupMode !== "sidebar") return undefined;
|
||||
return {
|
||||
"--tab-group-depth-offset": `${entry.depth * 0.75}rem`,
|
||||
"--tab-group-vertical-depth-offset": `${entry.depth * 0.5}rem`,
|
||||
} as CSSProperties;
|
||||
}
|
||||
|
||||
function isEntryHidden(entry: StripEntry) {
|
||||
if (tabSearchQuery.value.trim() || settingsStore.editorSettings.tabGroupMode === "none") return false;
|
||||
const ids = entry.kind === "header" ? entry.ancestorIds : [...entry.ancestorIds, entry.groupId];
|
||||
return ids.some((id) => collapsedTabGroups.value.has(id));
|
||||
}
|
||||
|
||||
const tabGroupEditorPreviewStyle = computed(() => groupColorStyle(editingTabGroupColor.value || editingTabGroupFallbackColor.value));
|
||||
const editingTabGroupHasCustomization = computed(() => {
|
||||
const customization = settingsStore.editorSettings.tabGroupCustomizations[editingTabGroupKey.value];
|
||||
@@ -781,9 +858,22 @@ function closeTabGroup(tab: QueryTab) {
|
||||
queryStore.closeTabsByIds(tabsToClose, finalActiveTabId);
|
||||
}
|
||||
|
||||
function closeTabsByIds(tabIds: string[]) {
|
||||
const uniqueIds = [...new Set(tabIds)];
|
||||
if (!uniqueIds.length) return;
|
||||
const finalActiveTabId = queryStore.activeTabId && !uniqueIds.includes(queryStore.activeTabId) ? queryStore.activeTabId : (queryStore.tabs.find((item) => !uniqueIds.includes(item.id))?.id ?? null);
|
||||
queryStore.closeTabsByIds(uniqueIds, finalActiveTabId);
|
||||
}
|
||||
|
||||
const tabOrganizationItems = computed(() => [
|
||||
...tabPlacementItems.value.map((item, index) => ({ ...item, value: `placement:${item.value}`, icon: { top: PanelTop, bottom: PanelBottom, left: PanelLeft, right: PanelRight }[item.value], groupLabel: index === 0 ? t("settings.tabPlacement") : undefined })),
|
||||
...tabGroupItems.value.map((item, index) => ({ ...item, value: `group:${item.value}`, icon: { none: Ungroup, "database-type": Database, database: Database, connection: Server }[item.value], separatorBefore: index === 0, groupLabel: index === 0 ? t("settings.tabGroup") : undefined })),
|
||||
...tabGroupItems.value.map((item, index) => ({
|
||||
...item,
|
||||
value: `group:${item.value}`,
|
||||
icon: { none: Ungroup, "database-type": Database, database: Database, connection: Server, sidebar: Server }[item.value],
|
||||
separatorBefore: index === 0,
|
||||
groupLabel: index === 0 ? t("settings.tabGroup") : undefined,
|
||||
})),
|
||||
...tabSortItems.value.map((item, index) => ({ ...item, value: `sort:${item.value}`, icon: { manual: ListOrdered, "created-asc": Clock3, "title-asc": ArrowDownAZ }[item.value], separatorBefore: index === 0, groupLabel: index === 0 ? t("settings.tabSort") : undefined })),
|
||||
]);
|
||||
const selectedTabOrganizationItems = computed(() => [`placement:${settingsStore.editorSettings.tabPlacement}`, `group:${settingsStore.editorSettings.tabGroupMode}`, `sort:${settingsStore.editorSettings.tabSortMode}`]);
|
||||
@@ -833,13 +923,59 @@ function getTabGroupMenuItems(tab: QueryTab): ContextMenuItem[] {
|
||||
];
|
||||
}
|
||||
|
||||
function getTabGroupHeaderMenuItems(entry: Extract<StripEntry, { kind: "header" }>): ContextMenuItem[] {
|
||||
if (settingsStore.editorSettings.tabGroupMode !== "sidebar") return getTabGroupMenuItems(entry.tab);
|
||||
const customization = tabGroupCustomization(entry.tab);
|
||||
const customizationItems: ContextMenuItem[] =
|
||||
entry.level === "connection"
|
||||
? [
|
||||
{ label: t("contextMenu.editTabGroup"), action: () => openTabGroupEditor(entry.tab), icon: Pencil },
|
||||
{ label: t("contextMenu.resetTabGroup"), action: () => resetTabGroupCustomization(entry.tab), icon: RotateCcw, visible: !!(customization?.name || customization?.color) },
|
||||
{ label: "", separator: true },
|
||||
]
|
||||
: [];
|
||||
return [
|
||||
...customizationItems,
|
||||
{ label: t("contextMenu.collapseAll"), action: collapseAllTabGroups, icon: ChevronsDownUp },
|
||||
{ label: t("contextMenu.expandAll"), action: () => expandAllTabGroups(), icon: ChevronsUpDown },
|
||||
{ label: "", separator: true },
|
||||
{ label: t("contextMenu.closeTabGroup"), action: () => closeTabsByIds(entry.tabIds), icon: X, variant: "destructive" },
|
||||
];
|
||||
}
|
||||
|
||||
function openTabGroupContextMenu(event: MouseEvent, open: (event: MouseEvent) => void) {
|
||||
event.preventDefault();
|
||||
document.getSelection()?.removeAllRanges();
|
||||
open(event);
|
||||
}
|
||||
|
||||
type StripEntry = { kind: "header"; key: string; tab: QueryTab; pinned: boolean; count: number } | { kind: "tab"; key: string; tab: QueryTab; groupFirst: boolean; groupLast: boolean; grouping: boolean };
|
||||
type StripEntry =
|
||||
| {
|
||||
kind: "header";
|
||||
key: string;
|
||||
tab: QueryTab;
|
||||
groupId: string;
|
||||
pinned: boolean;
|
||||
count: number;
|
||||
label: string;
|
||||
level: "connection" | "database";
|
||||
depth: number;
|
||||
tabIds: string[];
|
||||
ancestorIds: string[];
|
||||
treeGuides?: TabGroupTreeGuide[];
|
||||
}
|
||||
| {
|
||||
kind: "tab";
|
||||
key: string;
|
||||
tab: QueryTab;
|
||||
groupId: string;
|
||||
depth: number;
|
||||
ancestorIds: string[];
|
||||
groupFirst: boolean;
|
||||
groupLast: boolean;
|
||||
grouping: boolean;
|
||||
treeGuides?: TabGroupTreeGuide[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Flattens the strip's two sections (pinned, then regular) into render
|
||||
@@ -866,6 +1002,18 @@ const filteredRegularTabs = computed(() => {
|
||||
});
|
||||
|
||||
function buildStripEntries(section: QueryTab[], pinned: boolean): StripEntry[] {
|
||||
if (settingsStore.editorSettings.tabGroupMode === "sidebar") {
|
||||
const connectionlessEntries: StripEntry[] = section.filter((tab) => !tab.connectionId).map((tab) => ({ kind: "tab", key: tab.id, tab, groupId: "", depth: 0, ancestorIds: [], groupFirst: false, groupLast: false, grouping: false }));
|
||||
const hierarchyEntries = buildConnectionDatabaseTabGroupStripEntries(
|
||||
section.filter((tab) => tab.connectionId),
|
||||
pinned,
|
||||
).map((entry): StripEntry => {
|
||||
if (entry.kind === "tab") return entry;
|
||||
const label = entry.level === "connection" ? tabGroupLabel(entry.tab) : hierarchyDatabaseLabel(entry.tab);
|
||||
return { ...entry, label };
|
||||
});
|
||||
return [...connectionlessEntries, ...hierarchyEntries];
|
||||
}
|
||||
const entries: StripEntry[] = [];
|
||||
const grouping = settingsStore.editorSettings.tabGroupMode !== "none";
|
||||
const groupKeys = grouping ? section.map(tabGroupKey) : [];
|
||||
@@ -878,9 +1026,10 @@ function buildStripEntries(section: QueryTab[], pinned: boolean): StripEntry[] {
|
||||
const first = grouping && (index === 0 || groupKeys[index - 1] !== groupKey);
|
||||
const last = grouping && (index === section.length - 1 || groupKeys[index + 1] !== groupKey);
|
||||
if (first) {
|
||||
entries.push({ kind: "header", key: `header:${tab.id}`, tab, pinned, count: groupCounts.get(groupKey!) ?? 0 });
|
||||
const groupId = tabGroupId(tab);
|
||||
entries.push({ kind: "header", key: `header:${groupId}`, tab, groupId, pinned, count: groupCounts.get(groupKey!) ?? 0, label: tabGroupLabel(tab), level: "connection", depth: 0, tabIds: section.filter((item) => tabGroupKey(item) === groupKey).map((item) => item.id), ancestorIds: [] });
|
||||
}
|
||||
entries.push({ kind: "tab", key: tab.id, tab, groupFirst: first, groupLast: last, grouping });
|
||||
entries.push({ kind: "tab", key: tab.id, tab, groupId: grouping ? tabGroupId(tab) : "", depth: 0, ancestorIds: grouping ? [tabGroupId(tab)] : [], groupFirst: first, groupLast: last, grouping });
|
||||
});
|
||||
return entries;
|
||||
}
|
||||
@@ -1490,6 +1639,7 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
|
||||
:show-chevron="false"
|
||||
:close-on-select="false"
|
||||
:match-trigger-width="false"
|
||||
max-height="min(600px, calc(100vh - 16px))"
|
||||
align="end"
|
||||
@update:model-value="selectTabOrganizationItem"
|
||||
/>
|
||||
@@ -1516,6 +1666,7 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
|
||||
:show-chevron="false"
|
||||
:close-on-select="false"
|
||||
:match-trigger-width="false"
|
||||
max-height="min(600px, calc(100vh - 16px))"
|
||||
@update:model-value="selectTabOrganizationItem"
|
||||
/>
|
||||
<div class="app-tab-strip relative h-full min-w-0 flex-1 overflow-hidden">
|
||||
@@ -1559,24 +1710,28 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
|
||||
@wheel="hasHorizontalFixedRows && onHorizontalTabWheel($event)"
|
||||
>
|
||||
<template v-for="entry in section.entries" :key="entry.key">
|
||||
<CustomContextMenu v-if="entry.kind === 'header'" :items="() => getTabGroupMenuItems(entry.tab)" v-slot="{ onContextMenu }">
|
||||
<CustomContextMenu v-if="entry.kind === 'header'" :items="() => getTabGroupHeaderMenuItems(entry)" v-slot="{ onContextMenu }">
|
||||
<button
|
||||
type="button"
|
||||
class="tab-group-header"
|
||||
:class="{ 'tab-group-header--collapsed': isTabGroupCollapsed(entry.tab), 'tab-group-header--active': isTabGroupActive(entry.tab) }"
|
||||
:style="tabGroupStyle(entry.tab)"
|
||||
:aria-expanded="!isTabGroupCollapsed(entry.tab)"
|
||||
:title="tabGroupLabel(entry.tab)"
|
||||
@click="toggleTabGroup(entry.tab)"
|
||||
:class="{ 'tab-group-header--collapsed': isGroupCollapsed(entry.groupId), 'tab-group-header--active': isGroupActive(entry.groupId), 'tab-group-header--hidden': isEntryHidden(entry) }"
|
||||
:style="[tabGroupStyleForEntry(entry), tabGroupHeaderDepthStyle(entry)]"
|
||||
:data-tree-level="settingsStore.editorSettings.tabGroupMode === 'sidebar' ? entry.level : undefined"
|
||||
:aria-expanded="!isGroupCollapsed(entry.groupId)"
|
||||
:title="entry.label"
|
||||
@click="toggleTabGroupById(entry.groupId)"
|
||||
@contextmenu="openTabGroupContextMenu($event, onContextMenu)"
|
||||
>
|
||||
<TabGroupTreeGuides v-if="showTabTreeGuides" :guides="entry.treeGuides ?? []" :expanded="!isGroupCollapsed(entry.groupId) || !!tabSearchQuery.trim()" />
|
||||
<span class="tab-group-header-content">
|
||||
<span class="tab-group-marker" aria-hidden="true" />
|
||||
<Pin v-if="entry.pinned" class="tab-group-pin" aria-hidden="true" />
|
||||
<ChevronDown class="tab-group-chevron" :class="{ 'tab-group-chevron--collapsed': isTabGroupCollapsed(entry.tab) }" aria-hidden="true" />
|
||||
<DatabaseIcon :db-type="tabDatabaseIconType(entry.tab)" class="tab-group-database-icon" aria-hidden="true" />
|
||||
<span class="tab-group-label">{{ tabGroupLabel(entry.tab) }}</span>
|
||||
<span v-if="isTabGroupCollapsed(entry.tab)" class="tab-group-count">{{ entry.count }}</span>
|
||||
<ChevronDown class="tab-group-chevron" :class="{ 'tab-group-chevron--collapsed': isGroupCollapsed(entry.groupId) }" aria-hidden="true" />
|
||||
<ConnectionIcon v-if="entry.level === 'connection' && settingsStore.editorSettings.tabGroupMode === 'sidebar'" :connection="connectionStore.getConfig(entry.tab.connectionId)" class="tab-group-database-icon tab-group-connection-icon" aria-hidden="true" />
|
||||
<DatabaseIcon v-else-if="entry.level === 'connection'" :db-type="tabDatabaseIconType(entry.tab)" class="tab-group-database-icon tab-group-connection-icon" aria-hidden="true" />
|
||||
<Database v-else class="tab-group-database-icon tab-group-library-icon text-yellow-500" aria-hidden="true" />
|
||||
<span class="tab-group-label">{{ entry.label }}</span>
|
||||
<span v-if="isGroupCollapsed(entry.groupId)" class="tab-group-count">{{ entry.count }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</CustomContextMenu>
|
||||
@@ -1586,16 +1741,18 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
|
||||
'tab-group-entry',
|
||||
isClassicLayout && !isVerticalLayout ? 'h-full' : '',
|
||||
{
|
||||
'tab-group-entry--collapsing': entry.grouping && !tabSearchQuery.trim() && collapsingTabGroups.has(tabGroupId(entry.tab)),
|
||||
'tab-group-entry--collapsed': entry.grouping && !tabSearchQuery.trim() && isTabGroupCollapsed(entry.tab),
|
||||
'tab-group-entry--collapsing': entry.grouping && !tabSearchQuery.trim() && collapsingTabGroups.has(entry.groupId),
|
||||
'tab-group-entry--collapsed': entry.grouping && !tabSearchQuery.trim() && isEntryHidden(entry),
|
||||
},
|
||||
]"
|
||||
:data-tab-group-id="entry.grouping ? tabGroupId(entry.tab) : undefined"
|
||||
:aria-hidden="entry.grouping && !tabSearchQuery.trim() && isTabGroupCollapsed(entry.tab)"
|
||||
:inert="entry.grouping && !tabSearchQuery.trim() && isTabGroupCollapsed(entry.tab)"
|
||||
:data-tab-group-id="entry.grouping ? entry.groupId : undefined"
|
||||
:style="tabGroupTreeRowStyle(entry)"
|
||||
:aria-hidden="entry.grouping && !tabSearchQuery.trim() && isEntryHidden(entry)"
|
||||
:inert="entry.grouping && !tabSearchQuery.trim() && isEntryHidden(entry)"
|
||||
@contextmenu="onContextMenu"
|
||||
@transitionend.self="handleTabGroupTransitionEnd"
|
||||
>
|
||||
<TabGroupTreeGuides v-if="showTabTreeGuides" :guides="entry.treeGuides ?? []" />
|
||||
<Tooltip :open="openTabTooltipId === entry.tab.id" @update:open="updateTabTooltipOpen(entry.tab.id, $event)">
|
||||
<TooltipTrigger as-child>
|
||||
<div
|
||||
@@ -1610,7 +1767,7 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?
|
||||
'tab-group-tab--last': entry.grouping && entry.groupLast,
|
||||
},
|
||||
]"
|
||||
:style="[tabColorStyle(entry.tab), entry.grouping ? tabGroupStyle(entry.tab) : undefined, tabDropStyle(entry.tab)]"
|
||||
:style="[tabColorStyle(entry.tab), entry.grouping ? tabGroupStyleForTabEntry(entry) : undefined, tabDropStyle(entry.tab), entry.grouping ? tabGroupTabDepthStyle(entry) : undefined]"
|
||||
:data-active-tab="isTabActive(entry.tab)"
|
||||
:data-tab-id="entry.tab.id"
|
||||
@pointerdown="handleTabPointerDown($event, entry.tab)"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { TabGroupTreeGuide } from "@/lib/tabs/tabGroupTree";
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
guides: TabGroupTreeGuide[];
|
||||
expanded?: boolean;
|
||||
}>(),
|
||||
{ expanded: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="tab-tree-guides" aria-hidden="true">
|
||||
<template v-for="guide in guides" :key="guide.depth">
|
||||
<span v-if="guide.kind !== 'start' || expanded" class="tab-tree-guide" :class="`tab-tree-guide--${guide.kind}`" :data-depth="guide.depth" :style="{ '--tab-tree-guide-depth': guide.depth }" />
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
+134
@@ -75,6 +75,8 @@ function mountBar(groupId: string, tabs: ReturnType<ReturnType<typeof useQuerySt
|
||||
closeTabGroup: "Close group",
|
||||
editTabGroup: "Edit group",
|
||||
resetTabGroup: "Reset group",
|
||||
collapseAll: "Collapse all",
|
||||
expandAll: "Expand all",
|
||||
pinTab: "Pin",
|
||||
unpinTab: "Unpin",
|
||||
fullTabTitle: "Full title",
|
||||
@@ -338,6 +340,138 @@ describe("EditorGroupTabBar group behavior", () => {
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("renders connection-to-database-to-tab guide segments for multiple databases", async () => {
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.tabGroupMode = "sidebar";
|
||||
settings.editorSettings.tabPlacement = "left";
|
||||
store.createTab("mysql-1", "app", "App 1", "query");
|
||||
store.createTab("mysql-1", "app", "App 2", "query");
|
||||
store.createTab("mysql-1", "audit", "Audit", "query");
|
||||
const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), store.activeTabId, pinia);
|
||||
await settle();
|
||||
|
||||
expect(host.querySelectorAll(".tab-group-header")).toHaveLength(3);
|
||||
expect(host.querySelectorAll("[data-tree-level='connection']")).toHaveLength(1);
|
||||
expect(host.querySelectorAll("[data-tree-level='database']")).toHaveLength(2);
|
||||
expect(host.querySelector("[data-tree-level='connection'] .tab-group-connection-icon")).not.toBeNull();
|
||||
expect(host.querySelector("[data-tree-level='database'] .tab-group-library-icon")).not.toBeNull();
|
||||
expect(host.querySelectorAll(".tab-tree-guide--through")).toHaveLength(2);
|
||||
expect(host.querySelectorAll(".tab-tree-guide--branch")).toHaveLength(2);
|
||||
expect(host.querySelectorAll(".tab-tree-guide--last-branch")).toHaveLength(3);
|
||||
|
||||
const databaseHeader = host.querySelector<HTMLElement>("[data-tree-level='database']")!;
|
||||
databaseHeader.click();
|
||||
await settle();
|
||||
expect(databaseHeader.querySelector(".tab-tree-guide--start")).toBeNull();
|
||||
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("renders standalone plugin workbenches outside the connection hierarchy", async () => {
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.tabGroupMode = "sidebar";
|
||||
settings.editorSettings.tabPlacement = "left";
|
||||
const pluginTabId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server" });
|
||||
const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), pluginTabId, pinia);
|
||||
await settle();
|
||||
|
||||
expect(host.querySelectorAll(".tab-group-header")).toHaveLength(0);
|
||||
expect(host.querySelector(`[data-tab-id="${pluginTabId}"]`)?.textContent).toContain("SSH server");
|
||||
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("uses plugin-aware icons for sidebar connection headers", async () => {
|
||||
const connectionStore = useConnectionStore();
|
||||
connectionStore.connections = [
|
||||
{
|
||||
id: "ssh-1",
|
||||
name: "SSH",
|
||||
db_type: "plugin",
|
||||
driver_profile: "plugin",
|
||||
host: "127.0.0.1",
|
||||
port: 22,
|
||||
color: "",
|
||||
plugin_id: "io.dbx.ssh",
|
||||
plugin_connection_provider: "io.dbx.ssh.connection",
|
||||
} as ConnectionConfig,
|
||||
];
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.tabGroupMode = "sidebar";
|
||||
settings.editorSettings.tabPlacement = "left";
|
||||
const pluginTabId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server", connectionId: "ssh-1" });
|
||||
const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), pluginTabId, pinia);
|
||||
for (let index = 0; index < 20 && !host.querySelector("[data-tree-level='connection'] img"); index += 1) {
|
||||
await new Promise((resolveTimeout) => setTimeout(resolveTimeout, 5));
|
||||
}
|
||||
|
||||
expect(host.querySelector("[data-tree-level='connection'] img")).not.toBeNull();
|
||||
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("labels Redis database branches with their indexes and aliases", async () => {
|
||||
const connectionStore = useConnectionStore();
|
||||
connectionStore.connections = [
|
||||
{
|
||||
id: "redis-1",
|
||||
name: "Redis Cache",
|
||||
db_type: "redis",
|
||||
driver_profile: "redis",
|
||||
host: "127.0.0.1",
|
||||
port: 6379,
|
||||
color: "",
|
||||
redis_database_aliases: { "1": "Sessions" },
|
||||
} as ConnectionConfig,
|
||||
];
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.tabGroupMode = "sidebar";
|
||||
settings.editorSettings.tabPlacement = "left";
|
||||
const db0 = store.createTab("redis-1", "0", "Redis 0", "redis");
|
||||
store.createTab("redis-1", "1", "Redis 1", "redis");
|
||||
const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), db0, pinia);
|
||||
await settle();
|
||||
|
||||
const headers = Array.from(host.querySelectorAll<HTMLButtonElement>(".tab-group-header"));
|
||||
expect(headers.map((header) => header.title)).toEqual(["Redis Cache", "db0", "db1 · Sessions"]);
|
||||
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("collapses every sidebar connection and database branch from a header menu", async () => {
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
settings.editorSettings.tabGroupMode = "sidebar";
|
||||
settings.editorSettings.tabPlacement = "left";
|
||||
store.createTab("mysql-1", "app", "App", "query");
|
||||
store.createTab("mysql-1", "audit", "Audit", "query");
|
||||
store.createTab("pg-1", "app", "Postgres", "query");
|
||||
const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), store.activeTabId, pinia);
|
||||
await settle();
|
||||
|
||||
host.querySelector<HTMLElement>(".tab-group-header")!.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 10, clientY: 10 }));
|
||||
await settle();
|
||||
const menu = document.body.querySelector<HTMLElement>("[data-dbx-context-menu]")!;
|
||||
const collapseAll = Array.from(menu.querySelectorAll<HTMLButtonElement>("button")).find((button) => button.textContent?.includes("Collapse all"));
|
||||
expect(collapseAll).toBeDefined();
|
||||
collapseAll!.click();
|
||||
await settle();
|
||||
|
||||
expect(Array.from(host.querySelectorAll(".tab-group-header"), (header) => header.getAttribute("aria-expanded"))).toEqual(["false", "false", "false", "false", "false"]);
|
||||
expect(host.querySelectorAll(".tab-group-entry--collapsed")).toHaveLength(3);
|
||||
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
|
||||
it("sizes the header chevron and rotates it only while the cluster is collapsed", async () => {
|
||||
const store = useQueryStore();
|
||||
const settings = useSettingsStore();
|
||||
|
||||
@@ -460,6 +460,10 @@
|
||||
box-shadow 150ms ease;
|
||||
}
|
||||
|
||||
.tab-group-header--hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tab-group-header:focus-visible {
|
||||
box-shadow: 0 0 0 2px var(--ring);
|
||||
}
|
||||
@@ -477,6 +481,10 @@
|
||||
transform 120ms ease;
|
||||
}
|
||||
|
||||
.tab-group-entry .tab-group-tab {
|
||||
margin-inline-start: var(--tab-group-depth-offset, 0rem);
|
||||
}
|
||||
|
||||
.tab-group-marker {
|
||||
width: 0.22rem;
|
||||
height: 1rem;
|
||||
@@ -1177,6 +1185,10 @@ html.dbx-legacy-webview .vertical-tab-layout .app-tab-pill:not(.tab-group-tab)[d
|
||||
padding-inline: 0.55rem;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-header-content {
|
||||
padding-inline-start: calc(0.55rem + var(--tab-group-depth-offset, 0rem));
|
||||
}
|
||||
|
||||
.vertical-tab-layout .tab-group-header:hover .tab-group-header-content,
|
||||
.vertical-tab-layout .tab-group-header--active .tab-group-header-content {
|
||||
background: var(--tab-group-soft);
|
||||
@@ -1200,6 +1212,83 @@ html.dbx-legacy-webview .vertical-tab-layout .app-tab-pill:not(.tab-group-tab)[d
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Sidebar mode uses row-local guide segments. Keeping the guides on each
|
||||
* rendered row makes sibling databases connect correctly and naturally
|
||||
* shortens the rail when a group is collapsed. */
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-header::after,
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-tab::before,
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-tab::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-header,
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-entry {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-header {
|
||||
--tab-tree-guide-before: -0.35rem;
|
||||
--tab-tree-guide-after: calc(0rem - var(--tab-group-header-gap));
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guides {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
/* Keep the guide's center aligned with the marker and its branches. */
|
||||
left: calc(var(--tab-tree-guide-base-x) + var(--tab-tree-guide-depth) * 0.75rem - 0.5px);
|
||||
width: 1px;
|
||||
color: var(--tab-tree-parent-color);
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide[data-depth="1"] {
|
||||
color: var(--tab-tree-child-color);
|
||||
}
|
||||
|
||||
/* Every non-final sibling owns a full-height rail and a centered branch.
|
||||
* Only the final sibling ends the rail at its center. Header rails also own
|
||||
* their margins, so collapsed subtrees leave no gaps between database rows. */
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: var(--tab-tree-guide-before, 0);
|
||||
bottom: var(--tab-tree-guide-after, 0);
|
||||
left: 0;
|
||||
width: 1px;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide--start::before {
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide--last-branch::before {
|
||||
bottom: 50%;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide--branch::after,
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-tree-guide--last-branch::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 0.5px);
|
||||
left: 0.5px;
|
||||
width: calc(var(--tab-tree-guide-child-x) - (var(--tab-tree-guide-base-x) + var(--tab-tree-guide-depth) * 0.75rem));
|
||||
height: 1px;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
.vertical-tab-layout[data-group-mode="sidebar"] .tab-group-entry--collapsed .tab-tree-guides {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.vertical-tab-layout .tab-group-header:not(.tab-group-header--collapsed) .tab-group-marker {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
@@ -1207,8 +1296,8 @@ html.dbx-legacy-webview .vertical-tab-layout .app-tab-pill:not(.tab-group-tab)[d
|
||||
|
||||
.vertical-tab-layout .tab-group-tab {
|
||||
position: relative;
|
||||
width: calc(100% - var(--tab-group-tab-inset) - 0.25rem);
|
||||
margin-inline: var(--tab-group-tab-inset) 0.25rem;
|
||||
width: calc(100% - var(--tab-group-tab-inset) - var(--tab-group-vertical-depth-offset, 0rem) - 0.25rem);
|
||||
margin-inline: calc(var(--tab-group-tab-inset) + var(--tab-group-vertical-depth-offset, 0rem)) 0.25rem;
|
||||
padding-inline: 0.2rem 0.25rem !important;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ const props = withDefaults(
|
||||
closeOnSelect?: boolean;
|
||||
label?: string;
|
||||
matchTriggerWidth?: boolean;
|
||||
maxHeight?: string;
|
||||
}>(),
|
||||
{
|
||||
ariaLabel: undefined,
|
||||
@@ -65,6 +66,7 @@ const props = withDefaults(
|
||||
closeOnSelect: true,
|
||||
label: undefined,
|
||||
matchTriggerWidth: true,
|
||||
maxHeight: "min(420px, calc(100vh - 16px))",
|
||||
},
|
||||
);
|
||||
|
||||
@@ -85,7 +87,7 @@ const menuStyle = computed(() => ({
|
||||
left: `${x.value}px`,
|
||||
top: `${y.value}px`,
|
||||
minWidth: props.matchTriggerWidth ? `${minWidth.value}px` : undefined,
|
||||
maxHeight: "min(420px, calc(100vh - 16px))",
|
||||
maxHeight: props.maxHeight,
|
||||
}));
|
||||
|
||||
function onScroll(event: Event) {
|
||||
|
||||
Reference in new issue
Block a user