diff --git a/awx/ui_next/src/api/models/Jobs.js b/awx/ui_next/src/api/models/Jobs.js index 1c3375691c..60f08466dd 100644 --- a/awx/ui_next/src/api/models/Jobs.js +++ b/awx/ui_next/src/api/models/Jobs.js @@ -1,5 +1,14 @@ import Base from '../Base'; +const BASE_URLS = { + playbook: '/jobs/', + project: '/project_updates/', + system: '/system_jobs/', + inventory: '/inventory_updates/', + command: '/ad_hoc_commands/', + workflow: '/workflow_jobs/', +}; + class Jobs extends Base { constructor(http) { super(http); @@ -7,8 +16,7 @@ class Jobs extends Base { } readDetail (id, type) { - // TODO: adjust url based on type - return this.http.get(`${this.baseUrl}${id}/`); + return this.http.get(`/api/v2${BASE_URLS[type]}${id}/`); } } diff --git a/awx/ui_next/src/screens/Job/Job.jsx b/awx/ui_next/src/screens/Job/Job.jsx index b936edb0fa..5d21eafd30 100644 --- a/awx/ui_next/src/screens/Job/Job.jsx +++ b/awx/ui_next/src/screens/Job/Job.jsx @@ -8,7 +8,6 @@ import { CardHeader as PFCardHeader, PageSection, } from '@patternfly/react-core'; - import { JobsAPI } from '@api'; import ContentError from '@components/ContentError'; import CardCloseButton from '@components/CardCloseButton'; @@ -111,28 +110,18 @@ class Job extends Component { to="/jobs/:type/:id/details" exact /> - {job && ( + {job && [ ( - - )} - /> - )} - {job && ( + render={() => } + />, ( - - )} - /> - )} + render={() => } + />, + ]} diff --git a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx index 57e03638ed..904150dada 100644 --- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx +++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import { shape } from 'prop-types'; import { Link, withRouter } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; @@ -48,35 +49,41 @@ function JobDetail ({ job, i18n }) { label={i18n._(t`Finished`)} value={job.finished} /> - - {jobTemplate.name} - - )} - /> + {jobTemplate && ( + + {jobTemplate.name} + + )} + /> + )} - - {inventory.name} - - )} - /> + {inventory && ( + + {inventory.name} + + )} + /> + )} {/* TODO: show project status icon */} - - {project.name} - - )} - /> + {project && ( + + {project.name} + + )} + /> + )} - - {instanceGroup.name} - - )} - /> - + {instanceGroup && ( + + {instanceGroup.name} + + )} + /> + )} + { + typeof job.job_slice_number === 'number' + && typeof job.job_slice_count === 'number' + && ( + + ) + } {(credentials && credentials.length > 0) && ( )} - + {job.extra_vars && ( + + )} ); } +JobDetail.propTypes = { + job: shape({}).isRequired, +}; export default withI18n()(withRouter(JobDetail)); diff --git a/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx b/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx index 805d4e1506..58cf43a772 100644 --- a/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx +++ b/awx/ui_next/src/screens/Job/JobList/JobListItem.jsx @@ -11,6 +11,15 @@ import DataListCell from '@components/DataListCell'; import VerticalSeparator from '@components/VerticalSeparator'; import { toTitleCase } from '@util/strings'; +const JOB_TYPE_URLS = { + job: 'playbook', + project_update: 'project', + system_job: 'system', + inventory_update: 'inventory', + ad_hoc_command: 'command', + workflow_job: 'workflow', +}; + class JobListItem extends Component { render() { const { job, isSelected, onSelect } = this.props; @@ -27,19 +36,18 @@ class JobListItem extends Component { onChange={onSelect} aria-labelledby={`check-action-${job.id}`} /> - - - - - {job.name} - - - , - {toTitleCase(job.type)}, - {job.finished}, - ]} + + + + + {job.name} + + + , + {toTitleCase(job.type)}, + {job.finished}, + ]} />