Skip to content

Commit

Permalink
Adds friendly schedule, "paused" columns for job description in list (#…
Browse files Browse the repository at this point in the history
…138)

* Adds friendly schedule column

* Adds friendly status column
  • Loading branch information
JasonWeill authored Oct 12, 2022
1 parent 9631ff4 commit 4b51b83
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/job-definition-row.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';

import cronstrue from 'cronstrue';

import { JupyterFrontEnd } from '@jupyterlab/application';
import { PathExt } from '@jupyterlab/coreutils';

import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';

import { Scheduler } from '../handler';
import { useTranslator } from '../hooks';

function CreatedAt(props: {
job: Scheduler.IDescribeJobDefinition;
Expand All @@ -21,18 +24,32 @@ function CreatedAt(props: {
return <>{create_display_date}</>;
}

function ScheduleSummary(props: {
schedule: string | undefined;
}): JSX.Element | null {
if (props.schedule === undefined) {
return null;
}

return <>{cronstrue.toString(props.schedule)}</>;
}

export function buildJobDefinitionRow(
jobDef: Scheduler.IDescribeJobDefinition,
app: JupyterFrontEnd,
openJobDefinitionDetail: (jobDefId: string) => unknown
): JSX.Element {
const trans = useTranslator('jupyterlab');

const cellContents: React.ReactNode[] = [
// name
<a onClick={() => openJobDefinitionDetail(jobDef.job_definition_id)}>
{jobDef.name}
</a>,
PathExt.basename(jobDef.input_uri),
<CreatedAt job={jobDef} />
<CreatedAt job={jobDef} />,
<ScheduleSummary schedule={jobDef.schedule} />,
<>{jobDef.active ? trans.__('Active') : trans.__('Paused')}</>
];

return (
Expand Down
8 changes: 8 additions & 0 deletions src/mainviews/list-jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ function ListJobDefinitionsTable(props: ListJobDefinitionsTableProps) {
{
sortField: 'create_time',
name: trans.__('Created at')
},
{
sortField: null,
name: trans.__('Schedule')
},
{
sortField: null,
name: trans.__('Status')
}
];

Expand Down

0 comments on commit 4b51b83

Please sign in to comment.