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

Fix: cluster-settings page back-button navigation is broken (#2330)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-03-12 19:48:09 +02:00 committed by GitHub
parent 7d1b5e4627
commit c815396622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 17 deletions

View File

@ -138,13 +138,12 @@ export class WindowManager extends Singleton {
async navigate(url: string, frameId?: number) {
await this.ensureMainWindow();
let frameInfo: ClusterFrameInfo;
if (frameId) {
frameInfo = Array.from(clusterFrameMap.values()).find((frameInfo) => frameInfo.frameId === frameId);
}
const frameInfo = Array.from(clusterFrameMap.values()).find((frameInfo) => frameInfo.frameId === frameId);
const channel = frameInfo ? "renderer:navigate-in-cluster" : "renderer:navigate";
this.sendToView({
channel: "renderer:navigate",
channel,
frameInfo,
data: [url],
});

View File

@ -10,22 +10,37 @@ export function bindEvents() {
}
if (process.isMainFrame) {
// Keep track of active cluster-id for handling IPC/menus/etc.
reaction(() => getMatchedClusterId(), clusterId => {
broadcastMessage("cluster-view:current-id", clusterId);
}, {
fireImmediately: true
});
bindClusterManagerRouteEvents();
} else {
bindClusterFrameRouteEvents();
}
// Handle navigation via IPC (e.g. from top menu)
subscribeToBroadcast("renderer:navigate", (event, url: string) => {
logger.info(`[IPC]: ${event.type} ${JSON.stringify(url)}`, event);
navigate(url);
});
// Reload dashboard window
subscribeToBroadcast("renderer:reload", () => {
location.reload();
});
}
// Handle events only in main window renderer process (see also: cluster-manager.tsx)
function bindClusterManagerRouteEvents() {
// Keep track of active cluster-id for handling IPC/menus/etc.
reaction(() => getMatchedClusterId(), clusterId => {
broadcastMessage("cluster-view:current-id", clusterId);
}, {
fireImmediately: true
});
// Handle navigation via IPC
subscribeToBroadcast("renderer:navigate", (event, url: string) => {
logger.info(`[IPC]: ${event.type}: ${url}`, { currentLocation: location.href });
navigate(url);
});
}
// Handle cluster-view renderer process events within iframes
function bindClusterFrameRouteEvents() {
subscribeToBroadcast("renderer:navigate-cluster-view", (event, url: string) => {
logger.info(`[IPC]: ${event.type}: ${url}`, { currentLocation: location.href });
navigate(url);
});
}