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

Fixed a case when a task's owner can be undefined. #782

Merged
merged 1 commit into from
Oct 17, 2019
Merged
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
17 changes: 9 additions & 8 deletions cvat-ui/src/components/tasks-page/task-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -65,7 +66,7 @@ export default function TaskItem(props: TaskItemProps) {
</Col>
<Col span={10}>
<Text strong> {id} {name} </Text> <br/>
<Text type='secondary'> Created by { owner } on {created} </Text> <br/>
<Text type='secondary'> Created { owner? 'by ' + owner : '' } on {created} </Text> <br/>
<Text type='secondary'> Last updated {updated} </Text>
</Col>
<Col span={6}>
Expand Down