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

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2021-03-12 12:48:09 -05:00
1 parent 7d1b5e4627
commit c815396622
2 files changed
+31 -17

No files matched your search

+4 -5
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],
});
+27 -12
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);
});
}