refactoring / clean up

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2021-01-26 14:51:35 +02:00
1 parent 4ddd32b05f
commit 03794e6c38
5 files changed
+39 -27

No files matched your search

@@ -52,6 +52,10 @@ export class EventStore extends KubeObjectStore<KubeEvent> {
return compact(eventsWithError);
}
getWarningsCount() {
return this.getWarnings().length;
}
}
export const eventStore = new EventStore();
@@ -122,7 +122,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
// if user has given static list of namespaces let's not start watches because watch adds stuff that's not wanted
if (accessibleNamespaces.length > 0) {
return []; // no-op
return [];
}
return super.getSubscribeApis();
@@ -1,3 +1,4 @@
import { sum } from "lodash";
import { action, computed, observable } from "mobx";
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
import { autobind } from "../../utils";
@@ -62,6 +63,10 @@ export class NodesStore extends KubeObjectStore<Node> {
});
}
getWarningsCount(): number {
return sum(this.items.map((node: Node) => node.getWarningConditions().length));
}
reset() {
super.reset();
this.metrics = {};
+3 -9
View File
@@ -46,7 +46,6 @@ import { computed, reaction } from "mobx";
import { nodesStore } from "./+nodes/nodes.store";
import { podsStore } from "./+workloads-pods/pods.store";
import { kubeWatchApi } from "../api/kube-watch-api";
import { sum } from "lodash";
import { ReplicaSetScaleDialog } from "./+workloads-replicasets/replicaset-scale-dialog";
@observer
@@ -82,19 +81,14 @@ export class App extends React.Component {
preload: true,
}),
reaction(() => this.warningsCount, (count) => {
reaction(() => this.warningsTotal, (count: number) => {
broadcastMessage(`cluster-warning-event-count:${getHostedCluster().id}`, count);
}),
]);
}
// todo: move to nodes-store.ts
@computed get warningsCount() {
let warnings = sum(nodesStore.items.map(node => node.getWarningConditions().length));
warnings = warnings + eventStore.getWarnings().length;
return warnings;
@computed get warningsTotal(): number {
return nodesStore.getWarningsCount() + eventStore.getWarningsCount();
}
get startURL() {