mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove legacy store of CronJobs
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
1f78c66cc2
commit
72f199f6c2
@ -13,11 +13,9 @@ import moment from "moment";
|
||||
import { SiblingsInTabLayout } from "../layout/siblings-in-tab-layout";
|
||||
import { KubeObjectAge } from "../kube-object/age";
|
||||
import type { CronJobStore } from "./store";
|
||||
import type { JobStore } from "../+workloads-jobs/store";
|
||||
import type { EventStore } from "../+events/store";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import cronJobStoreInjectable from "./store.injectable";
|
||||
import jobStoreInjectable from "../+workloads-jobs/store.injectable";
|
||||
import eventStoreInjectable from "../+events/store.injectable";
|
||||
import { prevDefault } from "../../utils";
|
||||
import type { FilterByNamespace } from "../+namespaces/namespace-select-filter-model/filter-by-namespace.injectable";
|
||||
@ -35,84 +33,78 @@ enum columnId {
|
||||
|
||||
interface Dependencies {
|
||||
cronJobStore: CronJobStore;
|
||||
jobStore: JobStore;
|
||||
eventStore: EventStore;
|
||||
filterByNamespace: FilterByNamespace;
|
||||
}
|
||||
|
||||
@observer
|
||||
class NonInjectedCronJobs extends React.Component<Dependencies>{
|
||||
render() {
|
||||
const {
|
||||
cronJobStore,
|
||||
eventStore,
|
||||
jobStore,
|
||||
filterByNamespace,
|
||||
} = this.props;
|
||||
const NonInjectedCronJobs = observer((props: Dependencies) => {
|
||||
const {
|
||||
cronJobStore,
|
||||
eventStore,
|
||||
filterByNamespace,
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<SiblingsInTabLayout>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="workload_cronjobs"
|
||||
className="CronJobs"
|
||||
store={cronJobStore}
|
||||
dependentStores={[jobStore, eventStore]}
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: cronJob => cronJob.getName(),
|
||||
[columnId.namespace]: cronJob => cronJob.getNs(),
|
||||
[columnId.suspend]: cronJob => cronJob.getSuspendFlag(),
|
||||
[columnId.active]: cronJob => cronJobStore.getActiveJobsNum(cronJob),
|
||||
[columnId.lastSchedule]: cronJob => (
|
||||
cronJob.status?.lastScheduleTime
|
||||
? moment().diff(cronJob.status.lastScheduleTime)
|
||||
: 0
|
||||
),
|
||||
[columnId.age]: cronJob => -cronJob.getCreationTimestamp(),
|
||||
}}
|
||||
searchFilters={[
|
||||
cronJob => cronJob.getSearchFields(),
|
||||
cronJob => cronJob.getSchedule(),
|
||||
]}
|
||||
renderHeaderTitle="Cron Jobs"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Schedule", className: "schedule", id: columnId.schedule },
|
||||
{ title: "Suspend", className: "suspend", sortBy: columnId.suspend, id: columnId.suspend },
|
||||
{ title: "Active", className: "active", sortBy: columnId.active, id: columnId.active },
|
||||
{ title: "Last schedule", className: "last-schedule", sortBy: columnId.lastSchedule, id: columnId.lastSchedule },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={cronJob => [
|
||||
cronJob.getName(),
|
||||
<KubeObjectStatusIcon key="icon" object={cronJob} />,
|
||||
<a
|
||||
key="namespace"
|
||||
className="filterNamespace"
|
||||
onClick={prevDefault(() => filterByNamespace(cronJob.getNs()))}
|
||||
>
|
||||
{cronJob.getNs()}
|
||||
</a>,
|
||||
cronJob.isNeverRun() ? "never" : cronJob.getSchedule(),
|
||||
cronJob.getSuspendFlag(),
|
||||
cronJobStore.getActiveJobsNum(cronJob),
|
||||
cronJob.getLastScheduleTime(),
|
||||
<KubeObjectAge key="age" object={cronJob} />,
|
||||
]}
|
||||
/>
|
||||
</SiblingsInTabLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<SiblingsInTabLayout>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="workload_cronjobs"
|
||||
className="CronJobs"
|
||||
store={cronJobStore}
|
||||
dependentStores={[eventStore]}
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: cronJob => cronJob.getName(),
|
||||
[columnId.namespace]: cronJob => cronJob.getNs(),
|
||||
[columnId.suspend]: cronJob => cronJob.getSuspendFlag(),
|
||||
[columnId.active]: cronJob => cronJobStore.getActiveJobsNum(cronJob),
|
||||
[columnId.lastSchedule]: cronJob => (
|
||||
cronJob.status?.lastScheduleTime
|
||||
? moment().diff(cronJob.status.lastScheduleTime)
|
||||
: 0
|
||||
),
|
||||
[columnId.age]: cronJob => -cronJob.getCreationTimestamp(),
|
||||
}}
|
||||
searchFilters={[
|
||||
cronJob => cronJob.getSearchFields(),
|
||||
cronJob => cronJob.getSchedule(),
|
||||
]}
|
||||
renderHeaderTitle="Cron Jobs"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Schedule", className: "schedule", id: columnId.schedule },
|
||||
{ title: "Suspend", className: "suspend", sortBy: columnId.suspend, id: columnId.suspend },
|
||||
{ title: "Active", className: "active", sortBy: columnId.active, id: columnId.active },
|
||||
{ title: "Last schedule", className: "last-schedule", sortBy: columnId.lastSchedule, id: columnId.lastSchedule },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={cronJob => [
|
||||
cronJob.getName(),
|
||||
<KubeObjectStatusIcon key="icon" object={cronJob} />,
|
||||
<a
|
||||
key="namespace"
|
||||
className="filterNamespace"
|
||||
onClick={prevDefault(() => filterByNamespace(cronJob.getNs()))}
|
||||
>
|
||||
{cronJob.getNs()}
|
||||
</a>,
|
||||
cronJob.isNeverRun() ? "never" : cronJob.getSchedule(),
|
||||
cronJob.getSuspendFlag(),
|
||||
cronJobStore.getActiveJobsNum(cronJob),
|
||||
cronJob.getLastScheduleTime(),
|
||||
<KubeObjectAge key="age" object={cronJob} />,
|
||||
]}
|
||||
/>
|
||||
</SiblingsInTabLayout>
|
||||
);
|
||||
});
|
||||
|
||||
export const CronJobs = withInjectables<Dependencies>(NonInjectedCronJobs, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
cronJobStore: di.inject(cronJobStoreInjectable),
|
||||
eventStore: di.inject(eventStoreInjectable),
|
||||
jobStore: di.inject(jobStoreInjectable),
|
||||
filterByNamespace: di.inject(filterByNamespaceInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user