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

Adds a failure message to job output when job failed and no events exist #12412

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
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
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);
});
});