Skip to content

Commit

Permalink
Adds a failure message to job output when job failed and no events ex…
Browse files Browse the repository at this point in the history
…ist.
  • Loading branch information
AlexSCorey committed Jun 22, 2022
1 parent 35a5f93 commit 3e85682
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
34 changes: 33 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 { LaunchButton, ReLaunchDropDown } from 'components/LaunchButton';
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,26 @@ 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 not output.`;
message = (
<>
{t`Please relaunch the job or, for more information see the`}{' '}
<Link to={`/jobs/${typeSegment}/${id}/details`}>{t`details.`}</Link>{' '}
<br />
<LaunchButton resource={job}>
{({ handleRelaunch, isLaunching }) => (
<ReLaunchDropDown
isPrimary
handleRelaunch={handleRelaunch}
isLaunching={isLaunching}
id={`relaunch-job-${job.id}`}
/>
)}
</LaunchButton>
</>
);
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 3e85682

Please sign in to comment.