Skip to content

Commit

Permalink
Change: Show status information for container tasks and reports
Browse files Browse the repository at this point in the history
Container tasks now show "processing" when uploading reports or
creating assets and show "interrupted" when upload is interrupted.
Reports show "uploading" during upload  and "interrupted" if
upload is interrupted.
  • Loading branch information
a-h-abdelsalam authored and timopollmeier committed Nov 14, 2023
1 parent 177128e commit c6587df
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/gmp/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const TASK_STATUS = {
interrupted: 'Interrupted',
container: 'Container',
uploading: 'Uploading',
uploadinginterrupted: 'Uploading Interrupted',
processing: 'Processing',
done: 'Done',
};
Expand All @@ -84,6 +85,7 @@ const TASK_STATUS_TRANSLATIONS = {
Done: _l('Done'),
Queued: _l('Queued'),
Processing: _l('Processing'),
'Uploading Interrupted': _l('Interrupted'),
};
/* eslint-disable quote-props */

Expand Down
4 changes: 3 additions & 1 deletion src/web/pages/reports/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ const Row = ({
if (isDefined(task)) {
if (task.isContainer() && status !== TASK_STATUS.processing) {
status =
status === TASK_STATUS.running
status === TASK_STATUS.interrupted
? TASK_STATUS.uploadinginterrupted
: status === TASK_STATUS.running || status === TASK_STATUS.processing
? TASK_STATUS.uploading
: TASK_STATUS.container;
}
Expand Down
42 changes: 42 additions & 0 deletions src/web/pages/tasks/__tests__/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,46 @@ describe('Task Status tests', () => {
expect(detailslink).toHaveTextContent('Container');
expect(detailslink).toHaveAttribute('href', '/report/42');
});

test('should render container with status interrupted', () => {
const task = Task.fromElement({
status: TASK_STATUS.interrupted,
permissions: {permission: [{name: 'everything'}]},
});

const {render} = rendererWith({capabilities: caps});
const {getByTestId} = render(<Status task={task} />);

const bar = getByTestId('progressbar-box');
expect(bar).toHaveAttribute('title', TASK_STATUS.interrupted);
expect(bar).toHaveTextContent(TASK_STATUS.interrupted);
});

test('should render running container task as processing', () => {
const task = Task.fromElement({
status: TASK_STATUS.running,
permissions: {permission: [{name: 'everything'}]},
});

const {render} = rendererWith({capabilities: caps});
const {getByTestId} = render(<Status task={task} />);

const bar = getByTestId('progressbar-box');
expect(bar).toHaveAttribute('title', TASK_STATUS.processing);
expect(bar).toHaveTextContent(TASK_STATUS.processing);
});

test('should render processing container task as processing', () => {
const task = Task.fromElement({
status: TASK_STATUS.processing,
permissions: {permission: [{name: 'everything'}]},
});

const {render} = rendererWith({capabilities: caps});
const {getByTestId} = render(<Status task={task} />);

const bar = getByTestId('progressbar-box');
expect(bar).toHaveAttribute('title', TASK_STATUS.processing);
expect(bar).toHaveTextContent(TASK_STATUS.processing);
});
});
11 changes: 10 additions & 1 deletion src/web/pages/tasks/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ const TaskStatus = ({task, links = true}) => {
return (
<StyledDetailsLink type="report" id={report_id} textOnly={!links}>
<StatusBar
status={task.isContainer() ? TASK_STATUS.container : task.status}
status={
task.isContainer()
? task.status === TASK_STATUS.interrupted
? TASK_STATUS.uploadinginterrupted
: task.status === TASK_STATUS.running ||
task.status === TASK_STATUS.processing
? TASK_STATUS.processing
: TASK_STATUS.container
: task.status
}
progress={task.progress}
/>
</StyledDetailsLink>
Expand Down

0 comments on commit c6587df

Please sign in to comment.