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

Fix cluster disconnect not going switching to catalog (#2703)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-05-05 15:01:21 +03:00 committed by GitHub
parent 8fff064e0c
commit 1044c544ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -5,12 +5,14 @@ import { disposeOnUnmount, observer } from "mobx-react";
import { RouteComponentProps } from "react-router";
import { IClusterViewRouteParams } from "./cluster-view.route";
import { ClusterStatus } from "./cluster-status";
import { hasLoadedView, initView, refreshViews } from "./lens-views";
import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
import { Cluster } from "../../../main/cluster";
import { ClusterStore } from "../../../common/cluster-store";
import { requestMain } from "../../../common/ipc";
import { clusterActivateHandler } from "../../../common/cluster-ipc";
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
import { catalogURL } from "../+catalog";
import { navigate } from "../../navigation";
interface Props extends RouteComponentProps<IClusterViewRouteParams> {
}
@ -29,8 +31,14 @@ export class ClusterView extends React.Component<Props> {
disposeOnUnmount(this, [
reaction(() => this.clusterId, (clusterId) => {
this.showCluster(clusterId);
}, {
fireImmediately: true,
}, { fireImmediately: true}
),
reaction(() => this.cluster?.ready, (ready) => {
const clusterView = lensViews.get(this.clusterId);
if (clusterView && clusterView.isLoaded && !ready) {
navigate(catalogURL());
}
})
]);
}

View File

@ -1,8 +1,6 @@
import { observable, when } from "mobx";
import { ClusterId, ClusterStore, getClusterFrameUrl } from "../../../common/cluster-store";
import { navigate } from "../../navigation";
import logger from "../../../main/logger";
import { catalogURL } from "../+catalog";
export interface LensView {
isLoaded?: boolean
@ -55,8 +53,6 @@ export async function autoCleanOnRemove(clusterId: ClusterId, iframe: HTMLIFrame
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
lensViews.delete(clusterId);
const wasVisible = iframe.style.display !== "none";
// Keep frame in DOM to avoid possible bugs when same cluster re-created after being removed.
// In that case for some reasons `webFrame.routingId` returns some previous frameId (usage in app.tsx)
// Issue: https://github.com/lensapp/lens/issues/811
@ -64,10 +60,6 @@ export async function autoCleanOnRemove(clusterId: ClusterId, iframe: HTMLIFrame
iframe.dataset.meta = `${iframe.name} was removed at ${new Date().toLocaleString()}`;
iframe.removeAttribute("name");
iframe.contentWindow.postMessage("teardown", "*");
if (wasVisible) {
navigate(catalogURL());
}
}
export function refreshViews(visibleClusterId?: string) {