fix(desktop): show and switch special page tabs in empty workspace

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-09-14 13:23:35 +08:00
1 parent 9c973a2ee3
commit 94617a5923
3 files changed
+45 -7

No files matched your search

+31 -3
View File
@@ -1059,6 +1059,10 @@ function activateOpenSpecialPageFallback() {
}
if (driverStoreTabOpen.value) {
activateMainContentSurface("driverStore");
return;
}
if (pluginCenterTabOpen.value) {
activateMainContentSurface("pluginCenter");
}
}
@@ -1072,6 +1076,14 @@ function closeSettingsPage() {
activateMainContentSurface("pluginCenter");
return;
}
if (driverStoreTabOpen.value) {
activateMainContentSurface("driverStore");
return;
}
if (pluginCenterTabOpen.value) {
activateMainContentSurface("pluginCenter");
return;
}
activateMainContentSurface("query");
}
@@ -1093,7 +1105,17 @@ function openDriverStorePage(target?: "agent" | "jdbc" | "storage" | "runtime" |
function closeDriverStorePage() {
driverStoreTabOpen.value = false;
activateMainContentSurface("query");
// Keep another open special page visible when closing the active one. The
// previous implementation always switched to the query surface, which
// cleared pluginCenterActive and made an already-open Plugin Center tab
// disappear together with Driver Manager.
if (pluginCenterTabOpen.value) {
activateMainContentSurface("pluginCenter");
} else if (settingsPageTabOpen.value) {
activateMainContentSurface("settings");
} else {
activateMainContentSurface("query");
}
driverStoreActiveTab.value = "agent";
driverStoreFocus.value = null;
}
@@ -1107,7 +1129,13 @@ function openPluginCenterPage(focus?: PluginCenterFocus | null) {
function closePluginCenterPage() {
pluginCenterTabOpen.value = false;
pluginCenterFocus.value = null;
activateMainContentSurface("query");
if (driverStoreTabOpen.value) {
activateMainContentSurface("driverStore");
} else if (settingsPageTabOpen.value) {
activateMainContentSurface("settings");
} else {
activateMainContentSurface("query");
}
}
function openPluginConnectionDialog(pluginId: string, providerId: string) {
@@ -3712,7 +3740,7 @@ onUnmounted(() => {
@start-resize="startTabBarResize"
@toggle-collapse="toggleTabBarCollapsed"
:active-tab="activeTab ?? undefined"
:show-tab-navigation="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen"
:show-tab-navigation="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen || pluginCenterTabOpen"
:active-connection="activeConnection"
:tab-bar-width="tabBarWidth"
:tab-bar-collapsed="tabBarCollapsed"
@@ -138,7 +138,15 @@ const suppressNextTabClick = ref(false);
const isClassicLayout = computed(() => settingsStore.editorSettings.appLayout === "classic");
// Special pages append to the focused group's strip only: one instance at a
// time, in the pane the user is working in (v0.6.2 kept them in the single strip).
const showSpecialPageTabs = computed(() => !!props.specialPageTabs && (props.specialPageTabs.settingsOpen || props.specialPageTabs.driverStoreOpen || props.specialPageTabs.pluginCenterOpen) && queryStore.focusedGroupId === props.groupId);
const showSpecialPageTabs = computed(() => {
if (!props.specialPageTabs || !(props.specialPageTabs.settingsOpen || props.specialPageTabs.driverStoreOpen || props.specialPageTabs.pluginCenterOpen)) return false;
// With no regular query tabs there is no focus event to establish the
// focused group. Render the special-page tab in the sole (main) group so
// opening Plugin Center or Driver Manager by itself still creates a tab.
const isFocusedGroup = queryStore.focusedGroupId === props.groupId;
const isEmptyWorkspaceMainGroup = queryStore.tabs.length === 0 && props.groupId === queryStore.groups[0]?.id;
return isFocusedGroup || isEmptyWorkspaceMainGroup;
});
const specialPageActive = computed(() => !!(props.specialPageTabs?.settingsActive || props.specialPageTabs?.driverStoreActive || props.specialPageTabs?.pluginCenterActive));
function isTabActive(tab: QueryTab): boolean {
@@ -22,15 +22,17 @@ describe("App main content surface structure", () => {
});
it("keeps navigation independent from the workspace welcome content", () => {
expect(appSource).toContain(':show-tab-navigation="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen"');
expect(appSource).toContain(':show-tab-navigation="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen || pluginCenterTabOpen"');
expect(appSource).toContain(':active-tab="activeTab ?? undefined"');
expect(appSource).toMatch(/<template #empty>\s*<WelcomeScreen/);
expect(appSource).not.toContain('v-if="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen"');
expect(appSource).not.toContain('v-if="queryStore.tabs.length > 0 || settingsPageTabOpen || driverStoreTabOpen || pluginCenterTabOpen"');
});
it("returns to an open special page after the final query tab closes", () => {
expect(appSource).toContain("else if (previousId) activateOpenSpecialPageFallback();");
expect(appSource).toMatch(/function activateOpenSpecialPageFallback\(\)[\s\S]*?settingsPageTabOpen\.value[\s\S]*?activateMainContentSurface\("settings"\)[\s\S]*?driverStoreTabOpen\.value[\s\S]*?activateMainContentSurface\("driverStore"\)/);
expect(appSource).toMatch(
/function activateOpenSpecialPageFallback\(\)[\s\S]*?settingsPageTabOpen\.value[\s\S]*?activateMainContentSurface\("settings"\)[\s\S]*?driverStoreTabOpen\.value[\s\S]*?activateMainContentSurface\("driverStore"\)[\s\S]*?pluginCenterTabOpen\.value[\s\S]*?activateMainContentSurface\("pluginCenter"\)/,
);
});
it("anchors the drag-back hit test on every pane strip and the special-surfaces bar", () => {