feat(grid): add configurable shortcut to focus WHERE condition
This commit is contained in:
27 files changed
+325
No files matched your search
@@ -200,6 +200,7 @@ import { isAiRedisConsoleTarget, type AiConversationBinding } from "@/lib/ai/aiC
|
||||
type DataGridHandle = DataGridColumnLayoutHandle & {
|
||||
onToolbarRefresh: () => Promise<void> | void;
|
||||
focusSearch: (target?: Element | null) => boolean;
|
||||
focusWhere: () => boolean;
|
||||
openGoToColumn: () => boolean;
|
||||
openCellDetailSearch: () => boolean;
|
||||
nullColumnsHidden: boolean;
|
||||
@@ -1160,6 +1161,11 @@ function focusSearch(target: Element | null = null): boolean {
|
||||
return dataGridRef.value?.focusSearch(target) ?? false;
|
||||
}
|
||||
|
||||
function focusWhere(): boolean {
|
||||
if (props.activeTab.mode !== "data") return false;
|
||||
return dataGridRef.value?.focusWhere() ?? false;
|
||||
}
|
||||
|
||||
function openGoToColumn(): boolean {
|
||||
if (props.activeTab.mode !== "data") return false;
|
||||
return dataGridRef.value?.openGoToColumn() ?? false;
|
||||
@@ -1624,6 +1630,7 @@ function locateExecutionSummaryError(item: ExecutionSummaryItem) {
|
||||
|
||||
defineExpose({
|
||||
focusSearch,
|
||||
focusWhere,
|
||||
openGoToColumn,
|
||||
refreshData,
|
||||
toggleResultsPane,
|
||||
|
||||
@@ -72,6 +72,7 @@ const activeSurfaceRef = ref<QueryEditorSurfaceHandle | null>(null);
|
||||
|
||||
defineExpose({
|
||||
focusSearch: (target: Element | null = null) => activeSurfaceRef.value?.focusSearch(target) ?? false,
|
||||
focusWhere: () => activeSurfaceRef.value?.focusWhere() ?? false,
|
||||
openGoToColumn: () => activeSurfaceRef.value?.openGoToColumn() ?? false,
|
||||
refreshData: () => activeSurfaceRef.value?.refreshData() ?? false,
|
||||
toggleResultsPane: () => activeSurfaceRef.value?.toggleResultsPane() ?? false,
|
||||
|
||||
@@ -24,6 +24,7 @@ const contentAreaRef = ref<InstanceType<typeof ContentArea> | null>(null);
|
||||
|
||||
defineExpose<QueryEditorSurfaceHandle>({
|
||||
focusSearch: (target: Element | null = null) => contentAreaRef.value?.focusSearch(target) ?? false,
|
||||
focusWhere: () => contentAreaRef.value?.focusWhere() ?? false,
|
||||
openGoToColumn: () => contentAreaRef.value?.openGoToColumn() ?? false,
|
||||
refreshData: () => contentAreaRef.value?.refreshData() ?? false,
|
||||
toggleResultsPane: () => contentAreaRef.value?.toggleResultsPane() ?? false,
|
||||
|
||||
@@ -73,6 +73,7 @@ defineExpose({
|
||||
const group = groupForElement(element) ?? activeEditorGroup();
|
||||
return group?.focusSearch(element) ?? false;
|
||||
},
|
||||
focusWhere: () => activeEditorGroup()?.focusWhere() ?? false,
|
||||
openGoToColumn: () => activeEditorGroup()?.openGoToColumn() ?? false,
|
||||
refreshData: (target: Element | null = null) => {
|
||||
const element = commandTargetElement(target);
|
||||
|
||||
+45
@@ -18,6 +18,7 @@ vi.mock("splitpanes", () => ({
|
||||
const editorPreviewCalls = vi.hoisted(() => [] as Array<{ tabId: string; range: unknown }>);
|
||||
const editorFocusCalls = vi.hoisted(() => [] as Array<{ tabId: string; range: unknown }>);
|
||||
const groupHandleModRCalls = vi.hoisted(() => [] as Element[]);
|
||||
const groupFocusWhereCalls = vi.hoisted(() => [] as string[]);
|
||||
const groupFocusSearchCalls = vi.hoisted(() => [] as Array<Element | null>);
|
||||
const resultHandleModRCalls = vi.hoisted(() => [] as Element[]);
|
||||
const resultFocusSearchCalls = vi.hoisted(() => [] as boolean[]);
|
||||
@@ -41,6 +42,10 @@ vi.mock("@/components/layout/EditorGroup.vue", () => ({
|
||||
groupHandleModRCalls.push(target);
|
||||
return true;
|
||||
},
|
||||
focusWhere(this: { groupId: string }) {
|
||||
groupFocusWhereCalls.push(this.groupId);
|
||||
return true;
|
||||
},
|
||||
focusSearch(target?: Element | null) {
|
||||
groupFocusSearchCalls.push(target ?? null);
|
||||
return true;
|
||||
@@ -157,6 +162,7 @@ describe("SqlEditorWorkspace mount contract", () => {
|
||||
editorFocusCalls.length = 0;
|
||||
groupHandleModRCalls.length = 0;
|
||||
groupFocusSearchCalls.length = 0;
|
||||
groupFocusWhereCalls.length = 0;
|
||||
resultHandleModRCalls.length = 0;
|
||||
resultFocusSearchCalls.length = 0;
|
||||
groupExecutionCalls.capture.length = 0;
|
||||
@@ -714,4 +720,43 @@ describe("SqlEditorWorkspace mount contract", () => {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
});
|
||||
it("routes WHERE focus only to the active editor group after switching groups", async () => {
|
||||
const store = useQueryStore();
|
||||
store.tabs = [dataTab("data-a"), dataTab("data-b")];
|
||||
store.activeTabId = "data-a";
|
||||
store.groups = [
|
||||
{ id: "g1", tabIds: ["data-a"], activeTabId: "data-a" },
|
||||
{ id: "g2", tabIds: ["data-b"], activeTabId: "data-b" },
|
||||
];
|
||||
store.focusedGroupId = "g1";
|
||||
store.orientation = "vertical";
|
||||
store.sizes = [50, 50];
|
||||
const host = createHost();
|
||||
const app = createApp(SqlEditorWorkspace, {
|
||||
activeTab: store.tabs[0],
|
||||
activeOutputView: "result",
|
||||
executableSql: "",
|
||||
formatSqlRequest: null,
|
||||
compressSqlRequest: null,
|
||||
selectedSql: "",
|
||||
cursorPos: 0,
|
||||
blockDangerousRedisCommands: false,
|
||||
});
|
||||
app.use(pinia);
|
||||
app.use(i18n);
|
||||
const vm = app.mount(host) as unknown as { focusWhere: () => boolean };
|
||||
try {
|
||||
await nextTick();
|
||||
expect(vm.focusWhere()).toBe(true);
|
||||
expect(groupFocusWhereCalls).toEqual(["g1"]);
|
||||
store.focusedGroupId = "g2";
|
||||
store.activeTabId = "data-b";
|
||||
await nextTick();
|
||||
expect(vm.focusWhere()).toBe(true);
|
||||
expect(groupFocusWhereCalls).toEqual(["g1", "g2"]);
|
||||
} finally {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ export interface StatementRange {
|
||||
|
||||
export interface QueryEditorSurfaceHandle {
|
||||
focusSearch(target?: Element | null): boolean;
|
||||
focusWhere(): boolean;
|
||||
openGoToColumn(): boolean;
|
||||
refreshData(target?: Element | null): boolean;
|
||||
toggleResultsPane(): boolean;
|
||||
|
||||
Reference in new issue
Block a user