Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds friendly schedule, "paused" columns for job description in list #138

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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