mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Extract Pods workloads status computation
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
83f4a53eaa
commit
ab519a9264
@ -6,37 +6,23 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { workloadInjectionToken } from "../workload-injection-token";
|
||||
import { ResourceNames } from "../../../../utils/rbac";
|
||||
import navigateToPodsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/pods/navigate-to-pods.injectable";
|
||||
import namespaceStoreInjectable from "../../../+namespaces/store.injectable";
|
||||
import { computed } from "mobx";
|
||||
import podStoreInjectable from "../../../+workloads-pods/store.injectable";
|
||||
import totalCountOfPodsInSelectedNamespacesInjectable from "../../../+workloads-pods/total-count.injectable";
|
||||
import totalStatusesForPodsInSelectedNamespacesInjectable from "../../../+workloads-pods/statuses.injectable";
|
||||
|
||||
const podsWorkloadInjectable = getInjectable({
|
||||
id: "pods-workload",
|
||||
|
||||
instantiate: (di) => {
|
||||
const navigate = di.inject(navigateToPodsInjectable);
|
||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
||||
const store = di.inject(podStoreInjectable);
|
||||
|
||||
return {
|
||||
instantiate: (di) => ({
|
||||
resource: {
|
||||
apiName: "pods",
|
||||
group: "",
|
||||
},
|
||||
open: navigate,
|
||||
|
||||
amountOfItems: computed(
|
||||
() => store.getAllByNs(namespaceStore.contextNamespaces).length,
|
||||
),
|
||||
|
||||
status: computed(() =>
|
||||
store.getStatuses(store.getAllByNs(namespaceStore.contextNamespaces)),
|
||||
),
|
||||
|
||||
open: di.inject(navigateToPodsInjectable),
|
||||
amountOfItems: di.inject(totalCountOfPodsInSelectedNamespacesInjectable),
|
||||
status: di.inject(totalStatusesForPodsInSelectedNamespacesInjectable),
|
||||
title: ResourceNames.pods,
|
||||
orderNumber: 10,
|
||||
};
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: workloadInjectionToken,
|
||||
});
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 { computed } from "mobx";
|
||||
import podStoreInjectable from "./store.injectable";
|
||||
|
||||
const totalStatusesForPodsInSelectedNamespacesInjectable = getInjectable({
|
||||
id: "total-statuses-for-pods-in-selected-namespaces",
|
||||
instantiate: (di) => {
|
||||
const podStore = di.inject(podStoreInjectable);
|
||||
|
||||
return computed(() => podStore.getStatuses(podStore.contextItems));
|
||||
},
|
||||
});
|
||||
|
||||
export default totalStatusesForPodsInSelectedNamespacesInjectable;
|
||||
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 { computed } from "mobx";
|
||||
import podStoreInjectable from "./store.injectable";
|
||||
|
||||
const totalCountOfPodsInSelectedNamespacesInjectable = getInjectable({
|
||||
id: "total-count-of-pods-in-selected-namespaces",
|
||||
instantiate: (di) => {
|
||||
const podStore = di.inject(podStoreInjectable);
|
||||
|
||||
return computed(() => podStore.getTotalCount());
|
||||
},
|
||||
});
|
||||
|
||||
export default totalCountOfPodsInSelectedNamespacesInjectable;
|
||||
Loading…
Reference in New Issue
Block a user