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:
parent
8fff064e0c
commit
1044c544ad
@ -5,12 +5,14 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
|||||||
import { RouteComponentProps } from "react-router";
|
import { RouteComponentProps } from "react-router";
|
||||||
import { IClusterViewRouteParams } from "./cluster-view.route";
|
import { IClusterViewRouteParams } from "./cluster-view.route";
|
||||||
import { ClusterStatus } from "./cluster-status";
|
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 { Cluster } from "../../../main/cluster";
|
||||||
import { ClusterStore } from "../../../common/cluster-store";
|
import { ClusterStore } from "../../../common/cluster-store";
|
||||||
import { requestMain } from "../../../common/ipc";
|
import { requestMain } from "../../../common/ipc";
|
||||||
import { clusterActivateHandler } from "../../../common/cluster-ipc";
|
import { clusterActivateHandler } from "../../../common/cluster-ipc";
|
||||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||||
|
import { catalogURL } from "../+catalog";
|
||||||
|
import { navigate } from "../../navigation";
|
||||||
|
|
||||||
interface Props extends RouteComponentProps<IClusterViewRouteParams> {
|
interface Props extends RouteComponentProps<IClusterViewRouteParams> {
|
||||||
}
|
}
|
||||||
@ -29,8 +31,14 @@ export class ClusterView extends React.Component<Props> {
|
|||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
reaction(() => this.clusterId, (clusterId) => {
|
reaction(() => this.clusterId, (clusterId) => {
|
||||||
this.showCluster(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());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
import { observable, when } from "mobx";
|
import { observable, when } from "mobx";
|
||||||
import { ClusterId, ClusterStore, getClusterFrameUrl } from "../../../common/cluster-store";
|
import { ClusterId, ClusterStore, getClusterFrameUrl } from "../../../common/cluster-store";
|
||||||
import { navigate } from "../../navigation";
|
|
||||||
import logger from "../../../main/logger";
|
import logger from "../../../main/logger";
|
||||||
import { catalogURL } from "../+catalog";
|
|
||||||
|
|
||||||
export interface LensView {
|
export interface LensView {
|
||||||
isLoaded?: boolean
|
isLoaded?: boolean
|
||||||
@ -55,8 +53,6 @@ export async function autoCleanOnRemove(clusterId: ClusterId, iframe: HTMLIFrame
|
|||||||
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
||||||
lensViews.delete(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.
|
// 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)
|
// In that case for some reasons `webFrame.routingId` returns some previous frameId (usage in app.tsx)
|
||||||
// Issue: https://github.com/lensapp/lens/issues/811
|
// 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.dataset.meta = `${iframe.name} was removed at ${new Date().toLocaleString()}`;
|
||||||
iframe.removeAttribute("name");
|
iframe.removeAttribute("name");
|
||||||
iframe.contentWindow.postMessage("teardown", "*");
|
iframe.contentWindow.postMessage("teardown", "*");
|
||||||
|
|
||||||
if (wasVisible) {
|
|
||||||
navigate(catalogURL());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshViews(visibleClusterId?: string) {
|
export function refreshViews(visibleClusterId?: string) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user