From 28b84f4cf81062a2127e2d79f4febcd9d1586a69 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 15 Dec 2022 13:27:01 +0300 Subject: [PATCH] Load all pods in node details Signed-off-by: Alex Andreev --- src/renderer/components/+nodes/details.tsx | 17 +++++++++++++++++ .../+workloads-pods/pod-details-list.tsx | 16 ---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/renderer/components/+nodes/details.tsx b/src/renderer/components/+nodes/details.tsx index 2975c04a88..dc2a956ba0 100644 --- a/src/renderer/components/+nodes/details.tsx +++ b/src/renderer/components/+nodes/details.tsx @@ -31,6 +31,10 @@ import type { GetActiveClusterEntity } from "../../api/catalog/entity/get-active import getActiveClusterEntityInjectable from "../../api/catalog/entity/get-active-cluster-entity.injectable"; import type { ClusterMetricData, RequestClusterMetricsByNodeNames } from "../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable"; import requestClusterMetricsByNodeNamesInjectable from "../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable"; +import type { ShowNotification } from "../notifications/notifications"; +import type { NamespaceStore } from "../+namespaces/store"; +import namespaceStoreInjectable from "../+namespaces/store.injectable"; +import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable"; export interface NodeDetailsProps extends KubeObjectDetailsProps { } @@ -40,6 +44,8 @@ interface Dependencies { podStore: PodStore; getActiveClusterEntity: GetActiveClusterEntity; requestClusterMetricsByNodeNames: RequestClusterMetricsByNodeNames; + namespaceStore: NamespaceStore; + showErrorNotification: ShowNotification; } @observer @@ -55,6 +61,7 @@ class NonInjectedNodeDetails extends React.Component this.props.object.getName(), () => { this.metrics = null; + this.loadAllPods(); }), this.props.subscribeStores([ @@ -63,6 +70,14 @@ class NonInjectedNodeDetails extends React.Component ns.getName())], + onLoadFailure: error => + this.props.showErrorNotification(`Can not load Pods. ${String(error)}`) + }); + } + loadMetrics = async () => { const { object: node, requestClusterMetricsByNodeNames } = this.props; @@ -196,8 +211,10 @@ export const NodeDetails = withInjectables(NonIn ...props, subscribeStores: di.inject(subscribeStoresInjectable), podStore: di.inject(podStoreInjectable), + namespaceStore: di.inject(namespaceStoreInjectable), getActiveClusterEntity: di.inject(getActiveClusterEntityInjectable), requestClusterMetricsByNodeNames: di.inject(requestClusterMetricsByNodeNamesInjectable), + showErrorNotification: di.inject(showErrorNotificationInjectable) }), }); diff --git a/src/renderer/components/+workloads-pods/pod-details-list.tsx b/src/renderer/components/+workloads-pods/pod-details-list.tsx index a00f236c94..9ff03d992c 100644 --- a/src/renderer/components/+workloads-pods/pod-details-list.tsx +++ b/src/renderer/components/+workloads-pods/pod-details-list.tsx @@ -21,10 +21,6 @@ import { Spinner } from "../spinner"; import { Table, TableCell, TableHead, TableRow } from "../table"; import type { PodStore } from "./store"; import podStoreInjectable from "./store.injectable"; -import namespaceStoreInjectable from "../+namespaces/store.injectable"; -import type { NamespaceStore } from "../+namespaces/store"; -import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable"; -import type { ShowNotification } from "../notifications/notifications"; enum sortBy { name = "name", @@ -43,8 +39,6 @@ export interface PodDetailsListProps { interface Dependencies { getDetailsUrl: GetDetailsUrl; podStore: PodStore; - namespaceStore: NamespaceStore; - showErrorNotification: ShowNotification; } @observer @@ -58,14 +52,6 @@ export class NonInjectedPodDetailsList extends React.Component this.props.pods[0]?.getNs(), () => this.metricsWatcher.restart(true)), ]); - - this.props.podStore.loadAll({ - namespaces: [ - ...this.props.namespaceStore.getItems().map(ns => ns.getName()) - ], - onLoadFailure: error => - this.props.showErrorNotification(`Can not load Pods. ${String(error)}`) - }); } componentWillUnmount() { @@ -222,7 +208,5 @@ export const PodDetailsList = withInjectables ...props, getDetailsUrl: di.inject(getDetailsUrlInjectable), podStore: di.inject(podStoreInjectable), - namespaceStore: di.inject(namespaceStoreInjectable), - showErrorNotification: di.inject(showErrorNotificationInjectable) }), }); \ No newline at end of file