1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

revert navigation changes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-11-11 19:38:56 +02:00
parent 4afb6d9b80
commit f084b721ec

View File

@ -3,24 +3,13 @@
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";
import { matchPath } from "react-router"; import { matchPath } from "react-router";
import { reaction } from "mobx"; import { reaction } from "mobx";
import { createObservableHistory, IObservableHistory } from "mobx-observable-history"; import { createObservableHistory } from "mobx-observable-history";
import { createBrowserHistory, createMemoryHistory, LocationDescriptor, History } from "history"; import { createBrowserHistory, createMemoryHistory, LocationDescriptor } from "history";
import logger from "../main/logger"; import logger from "../main/logger";
import { clusterViewRoute, IClusterViewRouteParams } from "./components/cluster-manager/cluster-view.route"; import { clusterViewRoute, IClusterViewRouteParams } from "./components/cluster-manager/cluster-view.route";
let history: History export const history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory();
let navigation: IObservableHistory export const navigation = createObservableHistory(history);
if (ipcRenderer) {
history = typeof window !== "undefined" ? createBrowserHistory() : createMemoryHistory();
navigation = createObservableHistory(history);
}
export {
history,
navigation
}
export function navigate(location: LocationDescriptor) { export function navigate(location: LocationDescriptor) {
const currentLocation = navigation.getPath(); const currentLocation = navigation.getPath();
@ -116,15 +105,14 @@ if (process.isMainFrame) {
fireImmediately: true fireImmediately: true
}) })
} }
if (ipcRenderer) {
// Handle navigation via IPC (e.g. from top menu)
ipcRenderer.on("menu:navigate", (event, location: LocationDescriptor) => {
logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event);
navigate(location);
});
// Reload dashboard window // Handle navigation via IPC (e.g. from top menu)
ipcRenderer.on("menu:reload", () => { ipcRenderer.on("menu:navigate", (event, location: LocationDescriptor) => {
location.reload(); logger.info(`[IPC]: ${event.type} ${JSON.stringify(location)}`, event);
}); navigate(location);
} });
// Reload dashboard window
ipcRenderer.on("menu:reload", () => {
location.reload();
});