Skip to content

Commit

Permalink
Merge pull request #12412 from AlexSCorey/11994-FailedJobErrorMessage
Browse files Browse the repository at this point in the history
Adds a failure message to job output when job failed and no events exist
  • Loading branch information
AlexSCorey committed Jun 29, 2022
2 parents b70231f + 93d1aa0 commit ff882a3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
29 changes: 28 additions & 1 deletion awx/ui/src/screens/Job/JobOutput/EmptyOutput.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React, { useEffect } from 'react';
import { Link, useParams } from 'react-router-dom';
import 'styled-components/macro';
import { t } from '@lingui/macro';
import { SearchIcon } from '@patternfly/react-icons';
import {
SearchIcon,
ExclamationCircleIcon as PFExclamationCircleIcon,
} from '@patternfly/react-icons';
import ContentEmpty from 'components/ContentEmpty';

import styled from 'styled-components';

const ExclamationCircleIcon = styled(PFExclamationCircleIcon)`
color: var(--pf-global--danger-color--100);
`;

export default function EmptyOutput({
hasQueryParams,
isJobRunning,
onUnmount,
job,
}) {
let title;
let message;
let icon;
const { typeSegment, id } = useParams();

useEffect(() => onUnmount);

Expand All @@ -21,6 +33,21 @@ export default function EmptyOutput({
icon = SearchIcon;
} else if (isJobRunning) {
title = t`Waiting for job output…`;
} else if (job.status === 'failed') {
title = t`This job failed and has no output.`;
message = (
<>
{t`Return to `}{' '}
<Link to={`/jobs/${typeSegment}/${id}/details`}>{t`details.`}</Link>
<br />
{job.job_explanation && (
<>
{t`Failure Explanation:`} {`${job.job_explanation}`}
</>
)}
</>
);
icon = ExclamationCircleIcon;
} else {
title = t`No output found for this job.`;
}
Expand Down
1 change: 1 addition & 0 deletions awx/ui/src/screens/Job/JobOutput/JobOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
) {
return (
<EmptyOutput
job={job}
hasQueryParams={location.search.length > 1}
isJobRunning={isJobRunning(jobStatus)}
onUnmount={() => {
Expand Down
16 changes: 16 additions & 0 deletions awx/ui/src/screens/Job/JobOutput/JobOutput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,20 @@ describe('<JobOutput />', () => {
});
await waitForElement(wrapper, 'ContentError', (el) => el.length === 1);
});
test('should show failed empty output screen', async () => {
JobsAPI.readEvents.mockResolvedValue({
data: {
count: 0,
next: null,
previous: null,
results: [],
},
});
await act(async () => {
wrapper = mountWithContexts(
<JobOutput job={{ ...mockJob, status: 'failed' }} />
);
});
await waitForElement(wrapper, 'EmptyOutput', (el) => el.length === 1);
});
});

0 comments on commit ff882a3

Please sign in to comment.