mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move open context menu event handler to initializers
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
a7939b2285
commit
ed940cbfac
@ -26,10 +26,10 @@ import { initialize as initializeRemote } from "@electron/remote/main";
|
|||||||
import * as Mobx from "mobx";
|
import * as Mobx from "mobx";
|
||||||
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
||||||
import * as LensExtensionsMainApi from "../extensions/main-api";
|
import * as LensExtensionsMainApi from "../extensions/main-api";
|
||||||
import { app, autoUpdater, BrowserWindow, dialog, Menu, powerMonitor } from "electron";
|
import { app, autoUpdater, dialog, powerMonitor } from "electron";
|
||||||
import { appName, isIntegrationTesting, isMac, isWindows, productName } from "../common/vars";
|
import { appName, isIntegrationTesting, isMac, isWindows, productName } from "../common/vars";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
import { IpcMainWindowEvents, WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import { ClusterManager } from "./cluster-manager";
|
import { ClusterManager } from "./cluster-manager";
|
||||||
import { shellSync } from "./shell-sync";
|
import { shellSync } from "./shell-sync";
|
||||||
import { mangleProxyEnv } from "./proxy-env";
|
import { mangleProxyEnv } from "./proxy-env";
|
||||||
@ -61,7 +61,7 @@ import { FilesystemProvisionerStore } from "./extension-filesystem";
|
|||||||
import { SentryInit } from "../common/sentry";
|
import { SentryInit } from "../common/sentry";
|
||||||
import { ensureDir } from "fs-extra";
|
import { ensureDir } from "fs-extra";
|
||||||
import { Router } from "./router";
|
import { Router } from "./router";
|
||||||
import { getAppMenu, initMenu } from "./menu";
|
import { initMenu } from "./menu";
|
||||||
import { initTray } from "./tray";
|
import { initTray } from "./tray";
|
||||||
import { kubeApiRequest, shellApiRequest, ShellRequestAuthenticator } from "./proxy-functions";
|
import { kubeApiRequest, shellApiRequest, ShellRequestAuthenticator } from "./proxy-functions";
|
||||||
import { AppPaths } from "../common/app-paths";
|
import { AppPaths } from "../common/app-paths";
|
||||||
@ -256,12 +256,6 @@ app.on("ready", async () => {
|
|||||||
LensProtocolRouterMain.getInstance().rendererLoaded = true;
|
LensProtocolRouterMain.getInstance().rendererLoaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMainOn(IpcMainWindowEvents.OPEN_CONTEXT_MENU, (event) => {
|
|
||||||
const menu = Menu.buildFromTemplate(getAppMenu(windowManager));
|
|
||||||
|
|
||||||
menu.popup(BrowserWindow.fromWebContents(event.sender) as Electron.PopupOptions);
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info("🧩 Initializing extensions");
|
logger.info("🧩 Initializing extensions");
|
||||||
|
|
||||||
// call after windowManager to see splash earlier
|
// call after windowManager to see splash earlier
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BrowserWindow, dialog, IpcMainInvokeEvent } from "electron";
|
import { BrowserWindow, dialog, IpcMainInvokeEvent, Menu } from "electron";
|
||||||
import { clusterFrameMap } from "../../common/cluster-frames";
|
import { clusterFrameMap } from "../../common/cluster-frames";
|
||||||
import { clusterActivateHandler, clusterSetFrameIdHandler, clusterVisibilityHandler, clusterRefreshHandler, clusterDisconnectHandler, clusterKubectlApplyAllHandler, clusterKubectlDeleteAllHandler, clusterDeleteHandler, clusterSetDeletingHandler, clusterClearDeletingHandler } from "../../common/cluster-ipc";
|
import { clusterActivateHandler, clusterSetFrameIdHandler, clusterVisibilityHandler, clusterRefreshHandler, clusterDisconnectHandler, clusterKubectlApplyAllHandler, clusterKubectlDeleteAllHandler, clusterDeleteHandler, clusterSetDeletingHandler, clusterClearDeletingHandler } from "../../common/cluster-ipc";
|
||||||
import type { ClusterId } from "../../common/cluster-types";
|
import type { ClusterId } from "../../common/cluster-types";
|
||||||
@ -30,10 +30,11 @@ import { catalogEntityRegistry } from "../catalog";
|
|||||||
import { pushCatalogToRenderer } from "../catalog-pusher";
|
import { pushCatalogToRenderer } from "../catalog-pusher";
|
||||||
import { ClusterManager } from "../cluster-manager";
|
import { ClusterManager } from "../cluster-manager";
|
||||||
import { ResourceApplier } from "../resource-applier";
|
import { ResourceApplier } from "../resource-applier";
|
||||||
import { WindowManager } from "../window-manager";
|
import { IpcMainWindowEvents, WindowManager } from "../window-manager";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { remove } from "fs-extra";
|
import { remove } from "fs-extra";
|
||||||
import { AppPaths } from "../../common/app-paths";
|
import { AppPaths } from "../../common/app-paths";
|
||||||
|
import { getAppMenu } from "../menu";
|
||||||
|
|
||||||
export function initIpcMainHandlers() {
|
export function initIpcMainHandlers() {
|
||||||
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
|
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
|
||||||
@ -148,4 +149,10 @@ export function initIpcMainHandlers() {
|
|||||||
|
|
||||||
return dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), dialogOpts);
|
return dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), dialogOpts);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMainOn(IpcMainWindowEvents.OPEN_CONTEXT_MENU, async (event) => {
|
||||||
|
const menu = Menu.buildFromTemplate(getAppMenu(WindowManager.getInstance()));
|
||||||
|
|
||||||
|
menu.popup(BrowserWindow.fromWebContents(event.sender) as Electron.PopupOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user