From 550fcf49205f4d614d9b8c829326d47194ce4b7d Mon Sep 17 00:00:00 2001 From: James Kerr Date: Wed, 25 Oct 2023 10:07:29 -0700 Subject: [PATCH 1/3] Add Menu Option with Shortcut for Opening File --- .../src/domain/loads/handlers/choose-files.ts | 17 ++++++++++------- apps/zui/src/domain/loads/messages.ts | 7 +++++-- apps/zui/src/domain/messages.ts | 6 +++--- .../zui/src/electron/windows/search/app-menu.ts | 9 ++++++++- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/apps/zui/src/domain/loads/handlers/choose-files.ts b/apps/zui/src/domain/loads/handlers/choose-files.ts index be070d7576..38f6e4ecbc 100644 --- a/apps/zui/src/domain/loads/handlers/choose-files.ts +++ b/apps/zui/src/domain/loads/handlers/choose-files.ts @@ -1,11 +1,14 @@ import {createHandler} from "src/core/handlers" import {previewLoadFiles} from "./preview-load-files" -export const chooseFiles = createHandler(async ({invoke}, poolId?: string) => { - const result = await invoke("window.showOpenDialog", { - properties: ["openFile", "multiSelections"], - }) - if (!result.canceled && result.filePaths.length) { - previewLoadFiles({files: result.filePaths, poolId}) +export const chooseFiles = createHandler( + "loads.chooseFiles", + async ({invoke}, poolId?: string) => { + const result = await invoke("window.showOpenDialog", { + properties: ["openFile", "multiSelections"], + }) + if (!result.canceled && result.filePaths.length) { + previewLoadFiles({files: result.filePaths, poolId}) + } } -}) +) diff --git a/apps/zui/src/domain/loads/messages.ts b/apps/zui/src/domain/loads/messages.ts index 3ccbfd45ab..7de843963f 100644 --- a/apps/zui/src/domain/loads/messages.ts +++ b/apps/zui/src/domain/loads/messages.ts @@ -1,5 +1,6 @@ import {LoadFormat} from "@brimdata/zed-js" import * as ops from "./operations" +import * as handlers from "./handlers" export type LoadFormData = { windowId: string @@ -14,7 +15,7 @@ export type LoadFormData = { format?: LoadFormat } -export type LoadersOperations = { +export type LoadsOperations = { "loads.create": typeof ops.submit "loads.preview": typeof ops.preview "loads.getFileTypes": typeof ops.getFileTypes @@ -22,4 +23,6 @@ export type LoadersOperations = { "loads.abort": typeof ops.abort } -export type LoadersHandlers = {} +export type LoadsHandlers = { + "loads.chooseFiles": typeof handlers.chooseFiles +} diff --git a/apps/zui/src/domain/messages.ts b/apps/zui/src/domain/messages.ts index c71c3e981b..9d43e8c0cb 100644 --- a/apps/zui/src/domain/messages.ts +++ b/apps/zui/src/domain/messages.ts @@ -7,14 +7,14 @@ import {WindowHandlers, WindowOperations} from "./window/messages" import {LegacyOperations} from "./legacy-ops/messages" import {E2EOperations} from "./e2e/messages" import {EnvOperations} from "./env/messages" -import {LoadersHandlers, LoadersOperations} from "./loads/messages" +import {LoadsHandlers, LoadsOperations} from "./loads/messages" export type Handlers = ResultsHandlers & MenusHandlers & PanesHandlers & WindowHandlers & SessionHandlers & - LoadersHandlers & + LoadsHandlers & PoolsHandlers export type Operations = PoolsOperations & @@ -22,7 +22,7 @@ export type Operations = PoolsOperations & E2EOperations & ResultsOperations & EnvOperations & - LoadersOperations & + LoadsOperations & WindowOperations export type OperationName = keyof Operations diff --git a/apps/zui/src/electron/windows/search/app-menu.ts b/apps/zui/src/electron/windows/search/app-menu.ts index 3a913f47d6..d39a12111e 100644 --- a/apps/zui/src/electron/windows/search/app-menu.ts +++ b/apps/zui/src/electron/windows/search/app-menu.ts @@ -72,6 +72,12 @@ export function compileTemplate( click: () => window.send("showExportResults"), } + const openFile: MenuItemConstructorOptions = { + label: "Open Data File...", + click: () => sendToFocusedWindow("loads.chooseFiles"), + accelerator: "CmdOrCtrl+O", + } + const brimMenu: MenuItemConstructorOptions = { label: app.getName(), submenu: [ @@ -90,11 +96,12 @@ export function compileTemplate( function fileSubmenu(): MenuItemConstructorOptions[] { if (mac) { - return [newWindow, __, exportResults, __, closeTab, closeWindow] + return [newWindow, __, openFile, exportResults, __, closeTab, closeWindow] } else { return [ newWindow, __, + openFile, exportResults, __, preferences, From 78d52d18880e21764d75c74ecb6fe0cef147d77a Mon Sep 17 00:00:00 2001 From: James Kerr Date: Wed, 25 Oct 2023 14:33:04 -0700 Subject: [PATCH 2/3] Remove coverage directory --- apps/insiders/jest.config.ts | 1 - packages/sample-data/jest.config.ts | 1 - packages/zui-test-data/jest.config.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/apps/insiders/jest.config.ts b/apps/insiders/jest.config.ts index 987be47bb5..55064fd73e 100644 --- a/apps/insiders/jest.config.ts +++ b/apps/insiders/jest.config.ts @@ -6,5 +6,4 @@ export default { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/apps/insiders', }; diff --git a/packages/sample-data/jest.config.ts b/packages/sample-data/jest.config.ts index 65aa259bbd..da77e663ec 100644 --- a/packages/sample-data/jest.config.ts +++ b/packages/sample-data/jest.config.ts @@ -20,5 +20,4 @@ export default { '^.+\\.[tj]s$': ['@swc/jest', swcJestConfig], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/sample-data', }; diff --git a/packages/zui-test-data/jest.config.ts b/packages/zui-test-data/jest.config.ts index 6804e08d57..f5140067aa 100644 --- a/packages/zui-test-data/jest.config.ts +++ b/packages/zui-test-data/jest.config.ts @@ -6,5 +6,4 @@ export default { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/test-data', }; From ad711b045bff5fbce242d773d0e6a10a7eef1f12 Mon Sep 17 00:00:00 2001 From: James Kerr Date: Wed, 25 Oct 2023 14:35:53 -0700 Subject: [PATCH 3/3] Remove flaky test --- packages/zed-node/src/zq.test.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/zed-node/src/zq.test.ts b/packages/zed-node/src/zq.test.ts index f4c8ccc7fb..a0bb085ede 100644 --- a/packages/zed-node/src/zq.test.ts +++ b/packages/zed-node/src/zq.test.ts @@ -114,17 +114,6 @@ test('zq with a bad zed ', async () => { expect(promise).rejects.toThrowError('error parsing Zed'); }); -test('zq with a bad zed with file', async () => { - const path = getPath('prs.json'); - const promise = zq({ - query: 'over this | isNull(*)) | head 10', - as: 'zjson', - file: path, - }); - - expect(promise).rejects.toThrowError('error parsing Zed'); -}); - test('head 100 on guns ', async () => { const path = getPath('background_checks.csv'); const data = await zq({