Skip to content

Commit

Permalink
Use Electron's shell.openpath() for pcap slices (#2992)
Browse files Browse the repository at this point in the history
  • Loading branch information
philrz authored Feb 7, 2024
1 parent 334a80e commit 7e9525a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 155 deletions.
5 changes: 0 additions & 5 deletions apps/zui/src/domain/env/plugin-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import env from "src/app/core/env"
import {getPath} from "src/js/api/core/get-path"
import open from "src/js/lib/open"
import {join} from "path"

export class EnvApi {
Expand All @@ -20,10 +19,6 @@ export class EnvApi {
return env.isTest
}

openExternal(uri: string, opts: {newWindow?: boolean} = {}) {
return open(uri, opts)
}

getExePath(relPath: string) {
return join(getPath("zdeps"), relPath) + (env.isWindows ? ".exe" : "")
}
Expand Down
4 changes: 2 additions & 2 deletions apps/zui/src/electron/ops/open-link-op.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createOperation} from "../../core/operations"
import open from "src/js/lib/open"
import {shell} from "electron"

export const openLinkOp = createOperation("openLinkOp", (_ctx, url: string) => {
open(url)
shell.openExternal(url)
})
12 changes: 5 additions & 7 deletions apps/zui/src/js/components/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import Login from "./Login"
import {rest} from "msw"
import LakeStatuses from "../state/LakeStatuses"
import lake from "../models/lake"
import open from "src/js/lib/open"

jest.mock("src/js/lib/open", () => jest.fn())
import {shell} from "electron"

const system = new SystemTest("Login.test.ts")

Expand Down Expand Up @@ -76,12 +74,12 @@ function getLake() {
}

async function expectBrowserToOpen() {
await waitFor(() =>
expect(open).toHaveBeenCalledWith(
await waitFor(() => {
expect(shell.openExternal).toHaveBeenCalledWith(
expect.stringContaining("http://test.com/authorize?")
)
)
const auth0Url = (open as jest.Mock).mock.calls[0][0]
})
const auth0Url = (shell.openExternal as jest.Mock).mock.calls[0][0]
const urlParts = url.parse(auth0Url, true)
return urlParts.query.state
}
139 changes: 0 additions & 139 deletions apps/zui/src/js/lib/open.ts

This file was deleted.

5 changes: 3 additions & 2 deletions apps/zui/src/plugins/brimcap/packets/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as zed from "@brimdata/zed-js"
import {join} from "path"
import {createCli} from "../cli"
import os from "os"
import {window, env, commands} from "src/zui"
import {window, commands} from "src/zui"
import {queryForConnLog} from "./query-conn-log"
import {DOWNLOAD} from "./types"
import {shell} from "electron"

function getSearchArgsFromConn(conn: zed.Record) {
const dur = conn.try("duration") as zed.Duration
Expand Down Expand Up @@ -38,7 +39,7 @@ export async function downloadPackets(root: string, pool: string, uid: string) {
const msg = JSON.parse(err)?.error || `brimcap search failed: ${err}`
window.showErrorMessage(msg)
} else {
env.openExternal(dest)
shell.openPath(dest)
window.showSuccessMessage("Packets extracted. Opening...")
}
}
Expand Down

0 comments on commit 7e9525a

Please sign in to comment.