mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
change over cluster actions and loaded events
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
08bff81bf3
commit
b173d758f2
@ -29,6 +29,7 @@ import { LensProtocolRouterMain } from "./protocol-handler";
|
||||
import { getAppVersion, getAppVersionFromProxyServer } from "../common/utils";
|
||||
import { bindBroadcastHandlers } from "../common/ipc";
|
||||
import { startUpdateChecking } from "./app-updater";
|
||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||
|
||||
const workingDir = path.join(app.getPath("appData"), appName);
|
||||
let proxyPort: number;
|
||||
@ -162,7 +163,7 @@ app.on("ready", async () => {
|
||||
windowManager.initMainWindow();
|
||||
}
|
||||
|
||||
ipcMain.on("renderer:loaded", () => {
|
||||
ipcMain.on(IpcRendererNavigationEvents.LOADED, () => {
|
||||
startUpdateChecking();
|
||||
LensProtocolRouterMain
|
||||
.getInstance<LensProtocolRouterMain>()
|
||||
|
||||
@ -9,9 +9,10 @@ import { clusterDisconnectHandler } from "../../../common/cluster-ipc";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { Cluster } from "../../../main/cluster";
|
||||
import { Tooltip } from "../../components//tooltip";
|
||||
import { IpcRendererNavigationEvents } from "../../navigation/events";
|
||||
|
||||
const navigate = (route: string) =>
|
||||
broadcastMessage("renderer:navigate", route);
|
||||
broadcastMessage(IpcRendererNavigationEvents.NAVIGATE_IN_APP, route);
|
||||
|
||||
/**
|
||||
* Creates handlers for high-level actions
|
||||
|
||||
@ -10,6 +10,7 @@ import { workspaceStore } from "../../../../common/workspace-store";
|
||||
import { broadcastMessage, requestMain } from "../../../../common/ipc";
|
||||
import { clusterDisconnectHandler } from "../../../../common/cluster-ipc";
|
||||
import { ConfirmDialog } from "../../confirm-dialog";
|
||||
import { IpcRendererNavigationEvents } from "../../../navigation/events";
|
||||
|
||||
const mockBroadcastIpc = broadcastMessage as jest.MockedFunction<typeof broadcastMessage>;
|
||||
const mockRequestMain = requestMain as jest.MockedFunction<typeof requestMain>;
|
||||
@ -76,7 +77,7 @@ describe("<MainLayoutHeader />", () => {
|
||||
|
||||
it("navigates to cluster settings", () => {
|
||||
fireEvent.click(settingsBtn);
|
||||
expect(mockBroadcastIpc).toBeCalledWith("renderer:navigate", "/cluster/foo/settings");
|
||||
expect(mockBroadcastIpc).toBeCalledWith(IpcRendererNavigationEvents.NAVIGATE_IN_APP, "/cluster/foo/settings");
|
||||
});
|
||||
|
||||
it("disconnects from cluster", () => {
|
||||
@ -86,7 +87,7 @@ describe("<MainLayoutHeader />", () => {
|
||||
|
||||
it("opens 'Remove cluster' dialog", async () => {
|
||||
fireEvent.click(removeBtn);
|
||||
|
||||
|
||||
const dialog = document.querySelector(".ConfirmDialog");
|
||||
|
||||
expect(dialog).toBeDefined();
|
||||
@ -94,7 +95,7 @@ describe("<MainLayoutHeader />", () => {
|
||||
|
||||
const okBtn = dialog.querySelector("button.ok");
|
||||
|
||||
expect(okBtn.textContent).toBe("Remove");
|
||||
expect(okBtn.textContent).toBe("Remove");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -15,6 +15,7 @@ import { CommandContainer } from "./components/command-palette/command-container
|
||||
import { LensProtocolRouterRenderer, bindProtocolAddRouteHandlers } from "./protocol-handler";
|
||||
import { registerIpcHandlers } from "./ipc";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { IpcRendererNavigationEvents } from "./navigation/events";
|
||||
|
||||
@observer
|
||||
export class LensApp extends React.Component {
|
||||
@ -30,7 +31,7 @@ export class LensApp extends React.Component {
|
||||
});
|
||||
|
||||
registerIpcHandlers();
|
||||
ipcRenderer.send("renderer:loaded");
|
||||
ipcRenderer.send(IpcRendererNavigationEvents.LOADED);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@ -9,6 +9,7 @@ export const enum IpcRendererNavigationEvents {
|
||||
CLUSTER_VIEW_CURRENT_ID = "renderer:cluster-id-of-active-view",
|
||||
NAVIGATE_IN_APP = "renderer:navigate",
|
||||
NAVIGATE_IN_CLUSTER = "renderer:navigate-in-cluster",
|
||||
LOADED = "renderer:loaded",
|
||||
}
|
||||
|
||||
export function bindEvents() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user