From 6462e00d038d3e4d928932b717251dd42154ea9a Mon Sep 17 00:00:00 2001 From: Nikita Manovich <40690625+nmanovic@users.noreply.github.com> Date: Thu, 17 Oct 2019 19:29:38 +0300 Subject: [PATCH] Fixed a case when a task's owner can be undefined. (#782) --- cvat-ui/src/components/tasks-page/task-item.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cvat-ui/src/components/tasks-page/task-item.tsx b/cvat-ui/src/components/tasks-page/task-item.tsx index 4f0438a9e251..a053586882cf 100644 --- a/cvat-ui/src/components/tasks-page/task-item.tsx +++ b/cvat-ui/src/components/tasks-page/task-item.tsx @@ -20,19 +20,20 @@ export interface TaskItemProps { export default function TaskItem(props: TaskItemProps) { // Task info - const id = props.task.id; - const owner = props.task.owner.username; - const updated = moment(props.task.updatedDate).fromNow(); - const created = moment(props.task.createdDate).format('MMMM Do YYYY'); + const task = props.task; + const id = task.id; + const owner = task.owner? task.owner.username : undefined; + const updated = moment(task.updatedDate).fromNow(); + const created = moment(task.createdDate).format('MMMM Do YYYY'); const preview = props.preview; // Get and truncate a task name - let name = props.task.name; + let name = task.name; name = `${name.substring(0, 70)}${name.length > 70 ? '...' : ''}`; // Count number of jobs and performed jobs - const numOfJobs = props.task.jobs.length; - const numOfCompleted = props.task.jobs.filter( + const numOfJobs = task.jobs.length; + const numOfCompleted = task.jobs.filter( (job: any) => job.status === 'completed' ).length; @@ -65,7 +66,7 @@ export default function TaskItem(props: TaskItemProps) { {id} {name}
- Created by { owner } on {created}
+ Created { owner? 'by ' + owner : '' } on {created}
Last updated {updated}