diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index de17e3f8d1..54c047bcfe 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -1015,6 +1015,12 @@ const specialPageTabs = computed(() => ({ })); provide(GROUP_TAB_BAR_PORTAL, createGroupTabBarPortal(computed(() => !isDetachedWindowContext && (driverStoreActive.value || pluginCenterActive.value || settingsStore.settingsPageActive)))); provide(EDITOR_TOOLBAR_ACTIONS, { + canNewQuery: canCreateNewQuery, + newQuery: (groupId: string) => { + queryStore.focusGroup(groupId); + newQueryContextSource.value = "tab"; + void newQuery(); + }, explainMode, blockDangerousRedisCommands, databaseRequiredSignalFor: (tabId: string) => (databaseRequiredTabId.value === tabId ? databaseRequiredSignal.value : 0), diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index 3523e4e7d8..41e230f968 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -12193,6 +12193,8 @@ defineExpose({ toggleDdl: toggleTableInfo, showTableInfo, toggleTableInfo, + canOpenTableStructureEditor, + openTableStructureEditor, multiRowTranspose, setMultiRowTranspose, toggleMultiRowTranspose, diff --git a/apps/desktop/src/components/grid/__tests__/DataGridEditTableStructureShortcut.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridEditTableStructureShortcut.spec.ts index 48409800d6..e3f9d24eda 100644 --- a/apps/desktop/src/components/grid/__tests__/DataGridEditTableStructureShortcut.spec.ts +++ b/apps/desktop/src/components/grid/__tests__/DataGridEditTableStructureShortcut.spec.ts @@ -1,6 +1,6 @@ // @vitest-environment happy-dom -import { createApp, defineComponent, h, markRaw, nextTick, type App, type PropType } from "vue"; +import { createApp, defineComponent, h, markRaw, nextTick, ref, type App, type PropType } from "vue"; import { createPinia, setActivePinia } from "pinia"; import { afterEach, describe, expect, it, vi } from "vitest"; import i18n from "@/i18n"; @@ -95,6 +95,7 @@ function mountGrid( }; const host = document.createElement("div"); + const grid = ref<{ canOpenTableStructureEditor: boolean; openTableStructureEditor: (tab: TableInfoTab) => void }>(); document.body.append(host); const Root = defineComponent({ setup() { @@ -105,6 +106,7 @@ function mountGrid( { default: () => h(DataGrid, { + ref: grid, result, databaseType: options.databaseType ?? "mysql", context: options.context ?? "table-data", @@ -123,7 +125,7 @@ function mountGrid( app.component("RecycleScroller", RecycleScroller); app.mount(host); mountedApps.push({ app, host }); - return { host, openTableStructure }; + return { host, openTableStructure, grid }; } async function settle() { @@ -153,6 +155,15 @@ afterEach(() => { }); describe("DataGrid edit-table-structure shortcut", () => { + it("exposes columns navigation to the table header even when the information drawer is closed", async () => { + const { host, openTableStructure, grid } = mountGrid({ tableInfoTab: "indexes" }); + await settle(); + expect(host.querySelector("[data-edit-table-structure]")).toBeNull(); + expect(grid.value?.canOpenTableStructureEditor).toBe(true); + grid.value!.openTableStructureEditor("columns"); + expect(openTableStructure).toHaveBeenCalledExactlyOnceWith("connection-1", "app", "public", "users", "columns", undefined, "warehouse", "table"); + }); + it("opens the existing structure editor route for an eligible table-data grid", async () => { const { host, openTableStructure } = mountGrid(); await settle(); @@ -219,6 +230,7 @@ describe("DataGrid edit-table-structure shortcut", () => { expect(event.defaultPrevented).toBe(false); expect(bubbled).toHaveBeenCalledOnce(); expect(openTableStructure).not.toHaveBeenCalled(); + expect(host.querySelector("[data-edit-table-structure]")).toBeNull(); }); it("leaves editable text targets untouched", async () => { @@ -268,7 +280,7 @@ describe("DataGrid edit-table-structure shortcut", () => { const { host, openTableStructure } = mountGrid({ tableInfoTab: "triggers", autoShowTableInfo: true }); await settle(); - const editButton = host.querySelector(`button[aria-label="${i18n.global.t("contextMenu.editStructure")}"]`); + const editButton = host.querySelector(`.table-info-action-button[aria-label="${i18n.global.t("contextMenu.editStructure")}"]`); expect(editButton).not.toBeNull(); editButton!.click(); await settle(); diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue index d8c3cdc46f..b5b4eed195 100644 --- a/apps/desktop/src/components/layout/ContentArea.vue +++ b/apps/desktop/src/components/layout/ContentArea.vue @@ -36,6 +36,7 @@ import { X, Pin, Pencil, + PencilRuler, Rows3, Hash, SquareDashed, @@ -220,6 +221,8 @@ type DataGridHandle = DataGridColumnLayoutHandle & { openExtractorConfiguration: () => void; showDdl: boolean; toggleDdl: (tab?: TableInfoTab) => void; + canOpenTableStructureEditor: boolean; + openTableStructureEditor: (tab: TableInfoTab) => void; multiRowTranspose: boolean; setMultiRowTranspose: (value: boolean) => void; exportCsv: () => Promise; @@ -2691,6 +2694,12 @@ defineExpose({ {{ activeDataTabTableMeta.columns.length }} {{ t("tree.columns") }} + + + + + + + diff --git a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts index e75d3d2810..f091adb10f 100644 --- a/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts +++ b/apps/desktop/src/components/structure/TableStructureEditor.primaryKey.spec.ts @@ -43,6 +43,7 @@ vi.mock("@lucide/vue", async () => { AlertTriangle: Icon, Check: Icon, ChevronDown: Icon, + ChevronRight: Icon, ChevronUp: Icon, ClipboardList: Icon, Copy: Icon, diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue index b3328fc731..4287536885 100644 --- a/apps/desktop/src/components/structure/TableStructureEditor.vue +++ b/apps/desktop/src/components/structure/TableStructureEditor.vue @@ -1,6 +1,7 @@