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 { workloadInjectionToken } from "../workload-injection-token";
|
||||||
import { ResourceNames } from "../../../../utils/rbac";
|
import { ResourceNames } from "../../../../utils/rbac";
|
||||||
import navigateToPodsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/pods/navigate-to-pods.injectable";
|
import navigateToPodsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/pods/navigate-to-pods.injectable";
|
||||||
import namespaceStoreInjectable from "../../../+namespaces/store.injectable";
|
import totalCountOfPodsInSelectedNamespacesInjectable from "../../../+workloads-pods/total-count.injectable";
|
||||||
import { computed } from "mobx";
|
import totalStatusesForPodsInSelectedNamespacesInjectable from "../../../+workloads-pods/statuses.injectable";
|
||||||
import podStoreInjectable from "../../../+workloads-pods/store.injectable";
|
|
||||||
|
|
||||||
const podsWorkloadInjectable = getInjectable({
|
const podsWorkloadInjectable = getInjectable({
|
||||||
id: "pods-workload",
|
id: "pods-workload",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => ({
|
||||||
const navigate = di.inject(navigateToPodsInjectable);
|
|
||||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
|
||||||
const store = di.inject(podStoreInjectable);
|
|
||||||
|
|
||||||
return {
|
|
||||||
resource: {
|
resource: {
|
||||||
apiName: "pods",
|
apiName: "pods",
|
||||||
group: "",
|
group: "",
|
||||||
},
|
},
|
||||||
open: navigate,
|
open: di.inject(navigateToPodsInjectable),
|
||||||
|
amountOfItems: di.inject(totalCountOfPodsInSelectedNamespacesInjectable),
|
||||||
amountOfItems: computed(
|
status: di.inject(totalStatusesForPodsInSelectedNamespacesInjectable),
|
||||||
() => store.getAllByNs(namespaceStore.contextNamespaces).length,
|
|
||||||
),
|
|
||||||
|
|
||||||
status: computed(() =>
|
|
||||||
store.getStatuses(store.getAllByNs(namespaceStore.contextNamespaces)),
|
|
||||||
),
|
|
||||||
|
|
||||||
title: ResourceNames.pods,
|
title: ResourceNames.pods,
|
||||||
orderNumber: 10,
|
orderNumber: 10,
|
||||||
};
|
}),
|
||||||
},
|
|
||||||
|
|
||||||
injectionToken: workloadInjectionToken,
|
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