mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactor / fix cluster view visibility (#2654)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
d7199fda8e
commit
41c9a355ed
6 files changed
+55
-45
No files matched your search
@@ -2,49 +2,21 @@ import "./cluster-manager.scss";
|
||||
|
||||
import React from "react";
|
||||
import { Redirect, Route, Switch } from "react-router";
|
||||
import { comparer, reaction } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { observer } from "mobx-react";
|
||||
import { BottomBar } from "./bottom-bar";
|
||||
import { Catalog, catalogRoute } from "../+catalog";
|
||||
import { Preferences, preferencesRoute } from "../+preferences";
|
||||
import { AddCluster, addClusterRoute } from "../+add-cluster";
|
||||
import { ClusterView } from "./cluster-view";
|
||||
import { clusterViewRoute } from "./cluster-view.route";
|
||||
import { ClusterStore } from "../../../common/cluster-store";
|
||||
import { hasLoadedView, initView, lensViews, refreshViews } from "./lens-views";
|
||||
import { globalPageRegistry } from "../../../extensions/registries/page-registry";
|
||||
import { Extensions, extensionsRoute } from "../+extensions";
|
||||
import { getMatchedClusterId } from "../../navigation";
|
||||
import { HotbarMenu } from "../hotbar/hotbar-menu";
|
||||
import { EntitySettings, entitySettingsRoute } from "../+entity-settings";
|
||||
import { Welcome, welcomeRoute, welcomeURL } from "../+welcome";
|
||||
|
||||
@observer
|
||||
export class ClusterManager extends React.Component {
|
||||
componentDidMount() {
|
||||
const getMatchedCluster = () => ClusterStore.getInstance().getById(getMatchedClusterId());
|
||||
|
||||
disposeOnUnmount(this, [
|
||||
reaction(getMatchedClusterId, initView, {
|
||||
fireImmediately: true
|
||||
}),
|
||||
reaction(() => !getMatchedClusterId(), () => ClusterStore.getInstance().setActive(null)),
|
||||
reaction(() => [
|
||||
getMatchedClusterId(), // refresh when active cluster-view changed
|
||||
hasLoadedView(getMatchedClusterId()), // refresh when cluster's webview loaded
|
||||
getMatchedCluster()?.available, // refresh on disconnect active-cluster
|
||||
getMatchedCluster()?.ready, // refresh when cluster ready-state change
|
||||
], refreshViews, {
|
||||
fireImmediately: true,
|
||||
equals: comparer.shallow,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
lensViews.clear();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="ClusterManager">
|
||||
|
||||
Reference in new issue
Block a user