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

remove unnecessary global watches in cluster view (#4073)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2021-10-19 13:52:25 +03:00 committed by Jim Ehrismann
parent 87e4a18bb0
commit 6ee234619d
3 changed files with 8 additions and 11 deletions

View File

@ -22,7 +22,7 @@
import "./cluster-issues.scss";
import React from "react";
import { disposeOnUnmount, observer } from "mobx-react";
import { observer } from "mobx-react";
import { computed, makeObservable } from "mobx";
import { Icon } from "../icon";
import { SubHeader } from "../layout/sub-header";
@ -34,7 +34,6 @@ import type { ItemObject } from "../../../common/item.store";
import { Spinner } from "../spinner";
import { ThemeStore } from "../../theme.store";
import { kubeSelectedUrlParam, toggleDetails } from "../kube-detail-params";
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
import { apiManager } from "../../../common/k8s-api/api-manager";
interface Props {
@ -66,10 +65,6 @@ export class ClusterIssues extends React.Component<Props> {
constructor(props: Props) {
super(props);
makeObservable(this);
disposeOnUnmount(this, [
kubeWatchApi.subscribeStores([eventStore, nodesStore])
]);
}
@computed get warnings() {

View File

@ -36,6 +36,8 @@ import { ClusterPieCharts } from "./cluster-pie-charts";
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
import { ClusterStore } from "../../../common/cluster-store";
import { kubeWatchApi } from "../../../common/k8s-api/kube-watch-api";
import { eventStore } from "../+events/event.store";
@observer
export class ClusterOverview extends React.Component {
@ -53,6 +55,9 @@ export class ClusterOverview extends React.Component {
this.metricPoller.start(true);
disposeOnUnmount(this, [
kubeWatchApi.subscribeStores([podsStore, eventStore, nodesStore], {
preload: true,
}),
reaction(
() => clusterOverviewStore.metricNodeRole, // Toggle Master/Worker node switcher
() => this.metricPoller.restart(true)
@ -91,7 +96,7 @@ export class ClusterOverview extends React.Component {
}
render() {
const isLoaded = nodesStore.isLoaded && podsStore.isLoaded;
const isLoaded = nodesStore.isLoaded && eventStore.isLoaded;
const isMetricHidden = getActiveClusterEntity()?.isMetricHidden(ClusterMetricsResourceType.Cluster);
return (

View File

@ -42,9 +42,6 @@ import whatInput from "what-input";
import { clusterSetFrameIdHandler } from "../../common/cluster-ipc";
import { ClusterPageMenuRegistration, ClusterPageMenuRegistry } from "../../extensions/registries";
import { StatefulSetScaleDialog } from "./+workloads-statefulsets/statefulset-scale-dialog";
import { eventStore } from "./+events/event.store";
import { nodesStore } from "./+nodes/nodes.store";
import { podsStore } from "./+workloads-pods/pods.store";
import { kubeWatchApi } from "../../common/k8s-api/kube-watch-api";
import { ReplicaSetScaleDialog } from "./+workloads-replicasets/replicaset-scale-dialog";
import { CommandContainer } from "./command-palette/command-container";
@ -136,7 +133,7 @@ export class App extends React.Component {
componentDidMount() {
disposeOnUnmount(this, [
kubeWatchApi.subscribeStores([podsStore, nodesStore, eventStore, namespaceStore], {
kubeWatchApi.subscribeStores([namespaceStore], {
preload: true,
}),