mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Optimize StatefulSet workloads status computation
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
ab519a9264
commit
8460832d0f
@ -5,38 +5,24 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
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 namespaceStoreInjectable from "../../../+namespaces/store.injectable";
|
|
||||||
import statefulsetsStoreInjectable from "../../../+workloads-statefulsets/store.injectable";
|
|
||||||
import { computed } from "mobx";
|
|
||||||
import navigateToStatefulsetsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/statefulsets/navigate-to-statefulsets.injectable";
|
import navigateToStatefulsetsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/statefulsets/navigate-to-statefulsets.injectable";
|
||||||
|
import totalCountOfStatefulSetsInSelectedNamespacesInjectable from "../../../+workloads-statefulsets/total-count.injectable";
|
||||||
|
import totalStatusesForStatefulSetsInSelectedNamespacesInjectable from "../../../+workloads-statefulsets/statuses.injectable";
|
||||||
|
|
||||||
const statefulsetsWorkloadInjectable = getInjectable({
|
const statefulsetsWorkloadInjectable = getInjectable({
|
||||||
id: "statefulsets-workload",
|
id: "statefulsets-workload",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => ({
|
||||||
const navigate = di.inject(navigateToStatefulsetsInjectable);
|
resource: {
|
||||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
apiName: "statefulsets",
|
||||||
const store = di.inject(statefulsetsStoreInjectable);
|
group: "apps",
|
||||||
|
},
|
||||||
return {
|
open: di.inject(navigateToStatefulsetsInjectable),
|
||||||
resource: {
|
amountOfItems: di.inject(totalCountOfStatefulSetsInSelectedNamespacesInjectable),
|
||||||
apiName: "statefulsets",
|
status: di.inject(totalStatusesForStatefulSetsInSelectedNamespacesInjectable),
|
||||||
group: "apps",
|
title: ResourceNames.statefulsets,
|
||||||
},
|
orderNumber: 40,
|
||||||
open: navigate,
|
}),
|
||||||
|
|
||||||
amountOfItems: computed(
|
|
||||||
() => store.getAllByNs(namespaceStore.contextNamespaces).length,
|
|
||||||
),
|
|
||||||
|
|
||||||
status: computed(() =>
|
|
||||||
store.getStatuses(store.getAllByNs(namespaceStore.contextNamespaces)),
|
|
||||||
),
|
|
||||||
|
|
||||||
title: ResourceNames.statefulsets,
|
|
||||||
orderNumber: 40,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
injectionToken: workloadInjectionToken,
|
injectionToken: workloadInjectionToken,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* 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 computeStatusCountsForOwnersInjectable from "../../utils/compute-status-counts.injectable";
|
||||||
|
import statefulSetStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
const totalStatusesForStatefulSetsInSelectedNamespacesInjectable = getInjectable({
|
||||||
|
id: "total-statuses-for-stateful-sets-in-selected-namespaces",
|
||||||
|
instantiate: (di) => {
|
||||||
|
const statefulSetStore = di.inject(statefulSetStoreInjectable);
|
||||||
|
const computeStatusCountsForOwners = di.inject(computeStatusCountsForOwnersInjectable);
|
||||||
|
|
||||||
|
return computed(() => computeStatusCountsForOwners(statefulSetStore.contextItems));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default totalStatusesForStatefulSetsInSelectedNamespacesInjectable;
|
||||||
@ -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 statefulSetStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
const totalCountOfStatefulSetsInSelectedNamespacesInjectable = getInjectable({
|
||||||
|
id: "total-count-of-stateful-sets-in-selected-namespaces",
|
||||||
|
instantiate: (di) => {
|
||||||
|
const statefulSetStore = di.inject(statefulSetStoreInjectable);
|
||||||
|
|
||||||
|
return computed(() => statefulSetStore.getTotalCount());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default totalCountOfStatefulSetsInSelectedNamespacesInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user