mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix disconnect on currently connecting cluster
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
668ac58cb3
commit
4ac53a5481
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import "./cluster-view.scss";
|
import "./cluster-view.scss";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { computed, makeObservable, reaction } from "mobx";
|
import { computed, makeObservable, reaction, when } from "mobx";
|
||||||
import { disposeOnUnmount, observer } from "mobx-react";
|
import { disposeOnUnmount, observer } from "mobx-react";
|
||||||
import type { RouteComponentProps } from "react-router";
|
import type { RouteComponentProps } from "react-router";
|
||||||
import { ClusterStatus } from "./cluster-status";
|
import { ClusterStatus } from "./cluster-status";
|
||||||
@ -55,18 +55,28 @@ export class ClusterView extends React.Component<Props> {
|
|||||||
bindEvents() {
|
bindEvents() {
|
||||||
disposeOnUnmount(this, [
|
disposeOnUnmount(this, [
|
||||||
reaction(() => this.clusterId, async (clusterId) => {
|
reaction(() => this.clusterId, async (clusterId) => {
|
||||||
ClusterFrameHandler.getInstance().setVisibleCluster(clusterId);
|
console.log(`[CLUSTER-VIEW]: clusterId=${clusterId} is now matched`, this.cluster?.getMeta());
|
||||||
ClusterFrameHandler.getInstance().initView(clusterId);
|
|
||||||
requestClusterActivation(clusterId, false); // activate and fetch cluster's state from main
|
const frameHandler = ClusterFrameHandler.getInstance();
|
||||||
|
|
||||||
|
frameHandler.setVisibleCluster(clusterId);
|
||||||
|
frameHandler.initView(clusterId);
|
||||||
|
requestClusterActivation(clusterId, !this.cluster.disconnected); // activate and fetch cluster's state from main
|
||||||
catalogEntityRegistry.activeEntity = clusterId;
|
catalogEntityRegistry.activeEntity = clusterId;
|
||||||
}, {
|
}, {
|
||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
reaction(() => [this.cluster?.ready, this.cluster?.disconnected], ([, disconnected]) => {
|
reaction(() => this.cluster?.disconnected, disconnected => {
|
||||||
if (ClusterFrameHandler.getInstance().hasLoadedView(this.clusterId) && disconnected) {
|
if (!disconnected) {
|
||||||
|
const cluster = this.cluster; // save a reference for the when so that changes in `clusterId` do
|
||||||
|
|
||||||
|
when(() => cluster?.disconnected, () => {
|
||||||
|
if (cluster.id === this.clusterId) {
|
||||||
navigate(catalogURL()); // redirect to catalog when active cluster get disconnected/not available
|
navigate(catalogURL()); // redirect to catalog when active cluster get disconnected/not available
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,11 +63,7 @@ export class ClusterFrameHandler extends Singleton {
|
|||||||
() => !cluster.disconnected,
|
() => !cluster.disconnected,
|
||||||
() => {
|
() => {
|
||||||
when(
|
when(
|
||||||
() => {
|
() => !cluster || (cluster.disconnected && this.views.get(clusterId)?.isLoaded),
|
||||||
const cluster = ClusterStore.getInstance().getById(clusterId);
|
|
||||||
|
|
||||||
return !cluster || (cluster.disconnected && this.views.get(clusterId)?.isLoaded);
|
|
||||||
},
|
|
||||||
() => {
|
() => {
|
||||||
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`);
|
||||||
this.views.delete(clusterId);
|
this.views.delete(clusterId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user