1 parent
4e09b007c0
commit
701f188e45
3 files changed
+24
-8
No files matched your search
@@ -545,6 +545,11 @@ function activateSettingsPage() {
|
||||
driverStoreActive.value = false;
|
||||
}
|
||||
|
||||
function activateQuerySurface() {
|
||||
driverStoreActive.value = false;
|
||||
settingsStore.settingsPageActive = false;
|
||||
}
|
||||
|
||||
function closeSettingsPage() {
|
||||
settingsPageTabOpen.value = false;
|
||||
settingsStore.settingsPageActive = false;
|
||||
@@ -750,8 +755,7 @@ watch(
|
||||
pendingTabHistoryNavigationId = null;
|
||||
}
|
||||
if (id) newQueryContextSource.value = "tab";
|
||||
if (id && driverStoreActive.value) driverStoreActive.value = false;
|
||||
if (id && settingsStore.settingsPageActive) settingsStore.settingsPageActive = false;
|
||||
if (id) activateQuerySurface();
|
||||
selectedSql.value = "";
|
||||
activeOutputView.value = "result";
|
||||
if (id) queryStore.reloadEvictedTab(id);
|
||||
@@ -2318,8 +2322,7 @@ function activateQueryTab(tabId: string): boolean {
|
||||
if (!queryStore.tabs.some((tab) => tab.id === tabId)) return false;
|
||||
dispatchBeforeTabSwitch(tabId);
|
||||
queryStore.activeTabId = tabId;
|
||||
driverStoreActive.value = false;
|
||||
settingsStore.settingsPageActive = false;
|
||||
activateQuerySurface();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2706,6 +2709,7 @@ onMounted(async () => {
|
||||
window.addEventListener("blur", handleTabSwitcherWindowBlur);
|
||||
document.addEventListener("visibilitychange", handleTabSwitcherVisibilityChange);
|
||||
window.addEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
|
||||
window.addEventListener("dbx:activate-query-surface", activateQuerySurface);
|
||||
window.addEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);
|
||||
if (isDesktop) {
|
||||
document.addEventListener("contextmenu", handleContextMenu);
|
||||
@@ -2779,6 +2783,7 @@ onUnmounted(() => {
|
||||
document.removeEventListener("visibilitychange", handleTabSwitcherVisibilityChange);
|
||||
tabSwitcherKeyboard.reset();
|
||||
window.removeEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
|
||||
window.removeEventListener("dbx:activate-query-surface", activateQuerySurface);
|
||||
window.removeEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);
|
||||
document.removeEventListener("contextmenu", handleContextMenu);
|
||||
window.clearTimeout(sqlLibraryFlyAnimationTimer);
|
||||
@@ -2854,10 +2859,7 @@ onUnmounted(() => {
|
||||
@activate-driver-store="openDriverStorePage"
|
||||
@activate-settings-page="activateSettingsPage"
|
||||
@locate-tab="locateTabInSidebar"
|
||||
@activate-tab="
|
||||
driverStoreActive = false;
|
||||
settingsStore.settingsPageActive = false;
|
||||
"
|
||||
@activate-tab="activateQuerySurface"
|
||||
@close-driver-store="closeDriverStorePage"
|
||||
@close-settings-page="closeSettingsPage"
|
||||
@save-tab="handleSaveTab"
|
||||
|
||||
@@ -11,6 +11,7 @@ describe("queryStore switchTab", () => {
|
||||
setItem: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
});
|
||||
vi.stubGlobal("window", { dispatchEvent: vi.fn() });
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
@@ -36,6 +37,16 @@ describe("queryStore switchTab", () => {
|
||||
expect(queryStore.activeTabId).toBe(tabId);
|
||||
});
|
||||
|
||||
it("notifies the app when switching to an existing tab", async () => {
|
||||
const queryStore = useQueryStore();
|
||||
const tabId = queryStore.createTab("pg-1", "app", "users", "data", "public");
|
||||
const dispatchEvent = window.dispatchEvent as ReturnType<typeof vi.fn>;
|
||||
|
||||
queryStore.switchTab(tabId);
|
||||
|
||||
expect(dispatchEvent).toHaveBeenCalledWith(expect.objectContaining({ type: "dbx:activate-query-surface" }));
|
||||
});
|
||||
|
||||
it("deactivates settings page when switching to a different tab", async () => {
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
|
||||
@@ -84,6 +84,8 @@ import type { SqlExecutionTargetContext } from "@/lib/database/sqlExecutionTarge
|
||||
import type { DriverProfileWorkspaceScope } from "@/lib/database/driverProfileExtensions";
|
||||
import type { MultiDbExecutionTarget, MultiDbResultRunExecution } from "@/types/sqlExecution";
|
||||
|
||||
const QUERY_SURFACE_ACTIVATION_EVENT = "dbx:activate-query-surface";
|
||||
|
||||
const ORACLE_LIKE_METADATA_TYPES = new Set<string>(["oracle", "dameng", "oceanbase-oracle"]);
|
||||
const ORACLE_DEFERRED_LOB_TYPES = new Set<string>(["CLOB", "NCLOB", "BLOB", "BFILE", "XMLTYPE", "SYS.XMLTYPE"]);
|
||||
|
||||
@@ -1960,6 +1962,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
function switchTab(tabId: string) {
|
||||
activeTabId.value = tabId;
|
||||
settingsStore.settingsPageActive = false;
|
||||
if (typeof window !== "undefined") window.dispatchEvent(new Event(QUERY_SURFACE_ACTIVATION_EVENT));
|
||||
}
|
||||
|
||||
function openUserAdmin(connectionId: string) {
|
||||
|
||||
Reference in new issue
Block a user