diff --git a/src/renderer/components/cluster-manager/cluster-view.tsx b/src/renderer/components/cluster-manager/cluster-view.tsx index 5e46c63c3b..1fe11ff472 100644 --- a/src/renderer/components/cluster-manager/cluster-view.tsx +++ b/src/renderer/components/cluster-manager/cluster-view.tsx @@ -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 { } @@ -29,8 +31,14 @@ export class ClusterView extends React.Component { 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()); + } }) ]); } diff --git a/src/renderer/components/cluster-manager/lens-views.ts b/src/renderer/components/cluster-manager/lens-views.ts index 4b08ad9efe..60d90c45d7 100644 --- a/src/renderer/components/cluster-manager/lens-views.ts +++ b/src/renderer/components/cluster-manager/lens-views.ts @@ -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) {