mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
1 parent
e468105143
commit
b1ff34879a
470 files changed
+8447
-7443
No files matched your search
@@ -1,2 +1,2 @@
|
||||
export * from "./jobs"
|
||||
export * from "./job-details"
|
||||
export * from "./jobs";
|
||||
export * from "./job-details";
|
||||
@@ -26,21 +26,23 @@ interface Props extends KubeObjectDetailsProps<Job> {
|
||||
|
||||
@observer
|
||||
export class JobDetails extends React.Component<Props> {
|
||||
async componentDidMount() {
|
||||
async componentDidMount(): Promise<void> {
|
||||
if (!podsStore.isLoaded) {
|
||||
podsStore.loadAll();
|
||||
return podsStore.loadAll();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
render(): JSX.Element {
|
||||
const { object: job } = this.props;
|
||||
if (!job) return null;
|
||||
const selectors = job.getSelectors()
|
||||
const nodeSelector = job.getNodeSelectors()
|
||||
const images = job.getImages()
|
||||
const childPods = jobStore.getChildPods(job)
|
||||
const ownerRefs = job.getOwnerRefs()
|
||||
const condition = job.getCondition()
|
||||
if (!job) {
|
||||
return null;
|
||||
}
|
||||
const selectors = job.getSelectors();
|
||||
const nodeSelector = job.getNodeSelectors();
|
||||
const images = job.getImages();
|
||||
const childPods = jobStore.getChildPods(job);
|
||||
const ownerRefs = job.getOwnerRefs();
|
||||
const condition = job.getCondition();
|
||||
return (
|
||||
<div className="JobDetails">
|
||||
<KubeObjectMeta object={job}/>
|
||||
@@ -70,7 +72,7 @@ export class JobDetails extends React.Component<Props> {
|
||||
{
|
||||
ownerRefs.map(ref => {
|
||||
const { name, kind } = ref;
|
||||
const detailsUrl = getDetailsUrl(lookupApiLink(ref, job))
|
||||
const detailsUrl = getDetailsUrl(lookupApiLink(ref, job));
|
||||
return (
|
||||
<p key={name}>
|
||||
{kind} <Link to={detailsUrl}>{name}</Link>
|
||||
@@ -93,7 +95,7 @@ export class JobDetails extends React.Component<Props> {
|
||||
{job.getDesiredCompletions()}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={<Trans>Parallelism</Trans>}>
|
||||
{job.getParallelism()}
|
||||
{job.spec.parallelism}
|
||||
</DrawerItem>
|
||||
<PodDetailsTolerations workload={job}/>
|
||||
<PodDetailsAffinities workload={job}/>
|
||||
@@ -103,7 +105,7 @@ export class JobDetails extends React.Component<Props> {
|
||||
<PodDetailsList pods={childPods} owner={job}/>
|
||||
<KubeEventDetails object={job}/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,40 +4,38 @@ import { Job, jobApi } from "../../api/endpoints/job.api";
|
||||
import { CronJob, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { Dictionary } from "lodash";
|
||||
|
||||
@autobind()
|
||||
export class JobStore extends KubeObjectStore<Job> {
|
||||
api = jobApi
|
||||
|
||||
getChildPods(job: Job): Pod[] {
|
||||
return podsStore.getPodsByOwner(job)
|
||||
return podsStore.getPodsByOwner(job);
|
||||
}
|
||||
|
||||
getJobsByOwner(cronJob: CronJob) {
|
||||
getJobsByOwner(cronJob: CronJob): Job[] {
|
||||
return this.items.filter(job =>
|
||||
job.getNs() == cronJob.getNs() &&
|
||||
job.getOwnerRefs().find(ref => ref.name === cronJob.getName() && ref.kind === cronJob.kind)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
getStatuses(jobs?: Job[]) {
|
||||
const status = { failed: 0, pending: 0, running: 0, succeeded: 0 }
|
||||
getStatuses(jobs?: Job[]): Dictionary<number> {
|
||||
const status = { failed: 0, pending: 0, running: 0, succeeded: 0 };
|
||||
jobs.forEach(job => {
|
||||
const pods = this.getChildPods(job)
|
||||
const pods = this.getChildPods(job);
|
||||
if (pods.some(pod => pod.getStatus() === PodStatus.FAILED)) {
|
||||
status.failed++
|
||||
status.failed++;
|
||||
} else if (pods.some(pod => pod.getStatus() === PodStatus.PENDING)) {
|
||||
status.pending++;
|
||||
} else if (pods.some(pod => pod.getStatus() === PodStatus.RUNNING)) {
|
||||
status.running++;
|
||||
} else {
|
||||
status.succeeded++;
|
||||
}
|
||||
else if (pods.some(pod => pod.getStatus() === PodStatus.PENDING)) {
|
||||
status.pending++
|
||||
}
|
||||
else if (pods.some(pod => pod.getStatus() === PodStatus.RUNNING)) {
|
||||
status.running++
|
||||
}
|
||||
else {
|
||||
status.succeeded++
|
||||
}
|
||||
})
|
||||
return status
|
||||
});
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { eventStore } from "../+events/event.store";
|
||||
import { Job, jobApi } from "../../api/endpoints/job.api";
|
||||
import { KubeObjectMenu, KubeObjectMenuProps } from "../kube-object/kube-object-menu";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IJobsRouteParams } from "../+workloads";
|
||||
import { JobsRouteParams } from "../+workloads";
|
||||
import { KubeEventIcon } from "../+events/kube-event-icon";
|
||||
import kebabCase from "lodash/kebabCase";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
@@ -22,24 +22,24 @@ enum sortBy {
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<IJobsRouteParams> {
|
||||
interface Props extends RouteComponentProps<JobsRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class Jobs extends React.Component<Props> {
|
||||
render() {
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
className="Jobs" store={jobStore}
|
||||
dependentStores={[podsStore, eventStore]}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (job: Job) => job.getName(),
|
||||
[sortBy.namespace]: (job: Job) => job.getNs(),
|
||||
[sortBy.conditions]: (job: Job) => job.getCondition() != null ? job.getCondition().type : "",
|
||||
[sortBy.age]: (job: Job) => job.metadata.creationTimestamp,
|
||||
[sortBy.name]: (job: Job): string => job.getName(),
|
||||
[sortBy.namespace]: (job: Job): string => job.getNs(),
|
||||
[sortBy.conditions]: (job: Job): string => job.getCondition() != null ? job.getCondition().type : "",
|
||||
[sortBy.age]: (job: Job): string => job.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(job: Job) => job.getSearchFields(),
|
||||
(job: Job): string[]=> job.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle={<Trans>Jobs</Trans>}
|
||||
renderTableHeader={[
|
||||
@@ -50,34 +50,34 @@ export class Jobs extends React.Component<Props> {
|
||||
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
|
||||
{ title: <Trans>Conditions</Trans>, className: "conditions", sortBy: sortBy.conditions },
|
||||
]}
|
||||
renderTableContents={(job: Job) => {
|
||||
renderTableContents={(job: Job): (string | React.ReactNode | JSX.Element)[] => {
|
||||
const condition = job.getCondition();
|
||||
return [
|
||||
job.getName(),
|
||||
job.getNs(),
|
||||
`${job.getCompletions()} / ${job.getDesiredCompletions()}`,
|
||||
<KubeEventIcon object={job}/>,
|
||||
<KubeEventIcon key="job" object={job}/>,
|
||||
job.getAge(),
|
||||
condition && {
|
||||
title: condition.type,
|
||||
className: kebabCase(condition.type),
|
||||
}
|
||||
]
|
||||
];
|
||||
}}
|
||||
renderItemMenu={(item: Job) => {
|
||||
return <JobMenu object={item}/>
|
||||
renderItemMenu={(item: Job): JSX.Element => {
|
||||
return <JobMenu object={item}/>;
|
||||
}}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function JobMenu(props: KubeObjectMenuProps<Job>) {
|
||||
export function JobMenu(props: KubeObjectMenuProps<Job>): JSX.Element {
|
||||
return (
|
||||
<KubeObjectMenu {...props}/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
apiManager.registerViews(jobApi, {
|
||||
Menu: JobMenu,
|
||||
})
|
||||
});
|
||||
Reference in new issue
Block a user