Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Menu Option with Shortcut for Opening File #2864

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/insiders/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export default {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/insiders',
};
17 changes: 10 additions & 7 deletions apps/zui/src/domain/loads/handlers/choose-files.ts
Original file line number Diff line number Diff line change
@@ -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})
}
}
})
)
7 changes: 5 additions & 2 deletions apps/zui/src/domain/loads/messages.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,12 +15,14 @@ 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
"loads.abortPreview": typeof ops.abortPreview
"loads.abort": typeof ops.abort
}

export type LoadersHandlers = {}
export type LoadsHandlers = {
"loads.chooseFiles": typeof handlers.chooseFiles
}
6 changes: 3 additions & 3 deletions apps/zui/src/domain/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ 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 &
LegacyOperations &
E2EOperations &
ResultsOperations &
EnvOperations &
LoadersOperations &
LoadsOperations &
WindowOperations

export type OperationName = keyof Operations
Expand Down
9 changes: 8 additions & 1 deletion apps/zui/src/electron/windows/search/app-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/sample-data/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ export default {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/sample-data',
};
11 changes: 0 additions & 11 deletions packages/zed-node/src/zq.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 0 additions & 1 deletion packages/zui-test-data/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export default {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/test-data',
};
Loading