Skip to content

Commit 6462e00

Browse files
nmanovicbsekachev
authored andcommitted
Fixed a case when a task's owner can be undefined. (#782)
1 parent f3be6ae commit 6462e00

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cvat-ui/src/components/tasks-page/task-item.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ export interface TaskItemProps {
2020

2121
export default function TaskItem(props: TaskItemProps) {
2222
// Task info
23-
const id = props.task.id;
24-
const owner = props.task.owner.username;
25-
const updated = moment(props.task.updatedDate).fromNow();
26-
const created = moment(props.task.createdDate).format('MMMM Do YYYY');
23+
const task = props.task;
24+
const id = task.id;
25+
const owner = task.owner? task.owner.username : undefined;
26+
const updated = moment(task.updatedDate).fromNow();
27+
const created = moment(task.createdDate).format('MMMM Do YYYY');
2728
const preview = props.preview;
2829

2930
// Get and truncate a task name
30-
let name = props.task.name;
31+
let name = task.name;
3132
name = `${name.substring(0, 70)}${name.length > 70 ? '...' : ''}`;
3233

3334
// Count number of jobs and performed jobs
34-
const numOfJobs = props.task.jobs.length;
35-
const numOfCompleted = props.task.jobs.filter(
35+
const numOfJobs = task.jobs.length;
36+
const numOfCompleted = task.jobs.filter(
3637
(job: any) => job.status === 'completed'
3738
).length;
3839

@@ -65,7 +66,7 @@ export default function TaskItem(props: TaskItemProps) {
6566
</Col>
6667
<Col span={10}>
6768
<Text strong> {id} {name} </Text> <br/>
68-
<Text type='secondary'> Created by { owner } on {created} </Text> <br/>
69+
<Text type='secondary'> Created { owner? 'by ' + owner : '' } on {created} </Text> <br/>
6970
<Text type='secondary'> Last updated {updated} </Text>
7071
</Col>
7172
<Col span={6}>

0 commit comments

Comments
 (0)