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

Fix: load pods from all namespaces in node details (#6794)

* Load pods from all namespaces in Node details

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Lint fixes

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-12-20 16:34:43 +03:00 committed by GitHub
parent ed26e245e6
commit 5dde02733b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.inj
import type { PodStore } from "../+workloads-pods/store";
import podStoreInjectable from "../+workloads-pods/store.injectable";
import loggerInjectable from "../../../common/logger.injectable";
import loadPodsFromAllNamespacesInjectable from "../+workloads-pods/load-pods-from-all-namespaces.injectable";
export interface NodeDetailsProps extends KubeObjectDetailsProps<Node> {
}
@ -31,6 +32,7 @@ interface Dependencies {
subscribeStores: SubscribeStores;
podStore: PodStore;
logger: Logger;
loadPodsFromAllNamespaces: () => void;
}
@observer
@ -41,6 +43,8 @@ class NonInjectedNodeDetails extends React.Component<NodeDetailsProps & Dependen
this.props.podStore,
]),
]);
this.props.loadPodsFromAllNamespaces();
}
render() {
@ -154,6 +158,7 @@ export const NodeDetails = withInjectables<Dependencies, NodeDetailsProps>(NonIn
subscribeStores: di.inject(subscribeStoresInjectable),
podStore: di.inject(podStoreInjectable),
logger: di.inject(loggerInjectable),
loadPodsFromAllNamespaces: di.inject(loadPodsFromAllNamespacesInjectable),
}),
});

View File

@ -0,0 +1,28 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import namespaceStoreInjectable from "../+namespaces/store.injectable";
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
import podStoreInjectable from "./store.injectable";
const loadPodsFromAllNamespacesInjectable = getInjectable({
id: "load-pods-from-all-namespaces",
instantiate: (di) => {
const podStore = di.inject(podStoreInjectable);
const namespaceStore = di.inject(namespaceStoreInjectable);
const showErrorNotification = di.inject(showErrorNotificationInjectable);
return () => {
podStore.loadAll({
namespaces: [...namespaceStore.getItems().map(ns => ns.getName())],
onLoadFailure: error =>
showErrorNotification(`Can not load Pods. ${String(error)}`),
});
};
},
});
export default loadPodsFromAllNamespacesInjectable;