mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce and use "openBrowser" (#4876)
Co-authored-by: Steven Johnstone <sjohntone@mirantis.com>
This commit is contained in:
1 parent
8088d3b5c2
commit
625b00c247
7 files changed
+46
-21
No files matched your search
@@ -2,13 +2,14 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { app, BrowserWindow, dialog, Menu, MenuItem, MenuItemConstructorOptions, webContents, shell } from "electron";
|
||||
import { app, BrowserWindow, dialog, Menu, MenuItem, MenuItemConstructorOptions, webContents } from "electron";
|
||||
import { autorun, IComputedValue } from "mobx";
|
||||
import type { WindowManager } from "../window-manager";
|
||||
import { appName, isMac, isWindows, docsUrl, supportUrl, productName } from "../../common/vars";
|
||||
import logger from "../logger";
|
||||
import { exitApp } from "../exit-app";
|
||||
import { broadcastMessage } from "../../common/ipc";
|
||||
import { openBrowser } from "../../common/utils";
|
||||
import * as packageJson from "../../../package.json";
|
||||
import { preferencesURL, extensionsURL, addClusterURL, catalogURL, welcomeURL } from "../../common/routes";
|
||||
import { checkForUpdates, isAutoUpdateEnabled } from "../app-updater";
|
||||
@@ -261,14 +262,18 @@ export function getAppMenu(
|
||||
label: "Documentation",
|
||||
id: "documentation",
|
||||
click: async () => {
|
||||
shell.openExternal(docsUrl);
|
||||
openBrowser(docsUrl).catch(error => {
|
||||
logger.error("[MENU]: failed to open browser", { error });
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Support",
|
||||
id: "support",
|
||||
click: async () => {
|
||||
shell.openExternal(supportUrl);
|
||||
openBrowser(supportUrl).catch(error => {
|
||||
logger.error("[MENU]: failed to open browser", { error });
|
||||
});
|
||||
},
|
||||
},
|
||||
...ignoreIf(isMac, [
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
import type { ClusterId } from "../common/cluster-types";
|
||||
import { makeObservable, observable } from "mobx";
|
||||
import { app, BrowserWindow, dialog, ipcMain, shell, webContents } from "electron";
|
||||
import { app, BrowserWindow, dialog, ipcMain, webContents } from "electron";
|
||||
import windowStateKeeper from "electron-window-state";
|
||||
import { appEventBus } from "../common/app-event-bus/event-bus";
|
||||
import { ipcMainOn } from "../common/ipc";
|
||||
import { delay, iter, Singleton } from "../common/utils";
|
||||
import { delay, iter, Singleton, openBrowser } from "../common/utils";
|
||||
import { ClusterFrameInfo, clusterFrameMap } from "../common/cluster-frames";
|
||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||
import logger from "./logger";
|
||||
@@ -134,7 +134,9 @@ export class WindowManager extends Singleton {
|
||||
webPreferences.nodeIntegration = false;
|
||||
})
|
||||
.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url);
|
||||
openBrowser(details.url).catch(error => {
|
||||
logger.error("[WINDOW-MANAGER]: failed to open browser", { error });
|
||||
});
|
||||
|
||||
return { action: "deny" };
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user