mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Optimize CronJob workloads status computation
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
19a57ba731
commit
61801db635
@ -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 cronJobStoreInjectable from "./store.injectable";
|
||||
|
||||
const totalStatusesForCronJobsInSelectedNamespacesInjectable = getInjectable({
|
||||
id: "total-statuses-for-cron-jobs-in-selected-namespaces",
|
||||
instantiate: (di) => {
|
||||
const cronJobStore = di.inject(cronJobStoreInjectable);
|
||||
const computeStatusCountsForOwners = di.inject(computeStatusCountsForOwnersInjectable);
|
||||
|
||||
return computed(() => computeStatusCountsForOwners(cronJobStore.contextItems));
|
||||
},
|
||||
});
|
||||
|
||||
export default totalStatusesForCronJobsInSelectedNamespacesInjectable;
|
||||
@ -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 cronJobStoreInjectable from "./store.injectable";
|
||||
|
||||
const totalCountOfCronJobsInSelectedNamespacesInjectable = getInjectable({
|
||||
id: "total-count-of-cron-jobs-in-selected-namespaces",
|
||||
instantiate: (di) => {
|
||||
const cronJobStore = di.inject(cronJobStoreInjectable);
|
||||
|
||||
return computed(() => cronJobStore.getTotalCount());
|
||||
},
|
||||
});
|
||||
|
||||
export default totalCountOfCronJobsInSelectedNamespacesInjectable;
|
||||
@ -6,34 +6,23 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { workloadInjectionToken } from "../workload-injection-token";
|
||||
import { ResourceNames } from "../../../../utils/rbac";
|
||||
import navigateToCronJobsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/cron-jobs/navigate-to-cron-jobs.injectable";
|
||||
import namespaceStoreInjectable from "../../../+namespaces/store.injectable";
|
||||
import cronJobsStoreInjectable from "../../../+workloads-cronjobs/store.injectable";
|
||||
import { computed } from "mobx";
|
||||
import totalCountOfCronJobsInSelectedNamespacesInjectable from "../../../+workloads-cronjobs/total-count.injectable";
|
||||
import totalStatusesForCronJobsInSelectedNamespacesInjectable from "../../../+workloads-cronjobs/statuses.injectable";
|
||||
|
||||
const cronJobsWorkloadInjectable = getInjectable({
|
||||
id: "cron-jobs-workload",
|
||||
|
||||
instantiate: (di) => {
|
||||
const navigate = di.inject(navigateToCronJobsInjectable);
|
||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
||||
const store = di.inject(cronJobsStoreInjectable);
|
||||
|
||||
return {
|
||||
instantiate: (di) => ({
|
||||
resource: {
|
||||
apiName: "cronjobs",
|
||||
group: "batch",
|
||||
},
|
||||
open: navigate,
|
||||
amountOfItems: computed(
|
||||
() => store.getAllByNs(namespaceStore.contextNamespaces).length,
|
||||
),
|
||||
status: computed(() =>
|
||||
store.getStatuses(store.getAllByNs(namespaceStore.contextNamespaces)),
|
||||
),
|
||||
open: di.inject(navigateToCronJobsInjectable),
|
||||
amountOfItems: di.inject(totalCountOfCronJobsInSelectedNamespacesInjectable),
|
||||
status: di.inject(totalStatusesForCronJobsInSelectedNamespacesInjectable),
|
||||
title: ResourceNames.cronjobs,
|
||||
orderNumber: 70,
|
||||
};
|
||||
},
|
||||
}),
|
||||
|
||||
injectionToken: workloadInjectionToken,
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user