mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 06:29:31 -02:30
Add missing job detail fields and status icons
This commit is contained in:
@@ -11,7 +11,7 @@ const DetailList = ({ children, stacked, ...props }) => (
|
|||||||
export default styled(DetailList)`
|
export default styled(DetailList)`
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
align-items: baseline;
|
align-items: flex-start;
|
||||||
${props =>
|
${props =>
|
||||||
props.stacked
|
props.stacked
|
||||||
? `
|
? `
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { DetailList, Detail } from '@components/DetailList';
|
|||||||
import { ChipGroup, Chip, CredentialChip } from '@components/Chip';
|
import { ChipGroup, Chip, CredentialChip } from '@components/Chip';
|
||||||
import { VariablesInput as _VariablesInput } from '@components/CodeMirrorInput';
|
import { VariablesInput as _VariablesInput } from '@components/CodeMirrorInput';
|
||||||
import ErrorDetail from '@components/ErrorDetail';
|
import ErrorDetail from '@components/ErrorDetail';
|
||||||
|
import { StatusIcon } from '@components/Sparkline';
|
||||||
import { toTitleCase } from '@util/strings';
|
import { toTitleCase } from '@util/strings';
|
||||||
import { Job } from '../../../types';
|
import { Job } from '../../../types';
|
||||||
import {
|
import {
|
||||||
@@ -37,6 +38,14 @@ const VariablesInput = styled(_VariablesInput)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StatusDetailValue = styled.div`
|
||||||
|
align-items: center;
|
||||||
|
display: inline-flex;
|
||||||
|
> div {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const VERBOSITY = {
|
const VERBOSITY = {
|
||||||
0: '0 (Normal)',
|
0: '0 (Normal)',
|
||||||
1: '1 (Verbose)',
|
1: '1 (Verbose)',
|
||||||
@@ -45,18 +54,50 @@ const VERBOSITY = {
|
|||||||
4: '4 (Connection Debug)',
|
4: '4 (Connection Debug)',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getLaunchedByDetails = ({ summary_fields = {}, related = {} }) => {
|
||||||
|
const {
|
||||||
|
created_by: createdBy,
|
||||||
|
job_template: jobTemplate,
|
||||||
|
schedule,
|
||||||
|
} = summary_fields;
|
||||||
|
const { schedule: relatedSchedule } = related;
|
||||||
|
|
||||||
|
if (!createdBy && !schedule) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let link;
|
||||||
|
let value;
|
||||||
|
|
||||||
|
if (createdBy) {
|
||||||
|
link = `/users/${createdBy.id}`;
|
||||||
|
value = createdBy.username;
|
||||||
|
} else if (relatedSchedule && jobTemplate) {
|
||||||
|
link = `/templates/job_template/${jobTemplate.id}/schedules/${schedule.id}`;
|
||||||
|
value = schedule.name;
|
||||||
|
} else {
|
||||||
|
link = null;
|
||||||
|
value = schedule.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { link, value };
|
||||||
|
};
|
||||||
|
|
||||||
function JobDetail({ job, i18n, history }) {
|
function JobDetail({ job, i18n, history }) {
|
||||||
const {
|
const {
|
||||||
job_template: jobTemplate,
|
|
||||||
project,
|
|
||||||
inventory,
|
|
||||||
instance_group: instanceGroup,
|
|
||||||
credentials,
|
credentials,
|
||||||
|
instance_group: instanceGroup,
|
||||||
|
inventory,
|
||||||
|
job_template: jobTemplate,
|
||||||
labels,
|
labels,
|
||||||
|
project,
|
||||||
} = job.summary_fields;
|
} = job.summary_fields;
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [errorMsg, setErrorMsg] = useState();
|
const [errorMsg, setErrorMsg] = useState();
|
||||||
|
|
||||||
|
const { value: launchedByValue, link: launchedByLink } =
|
||||||
|
getLaunchedByDetails(job) || {};
|
||||||
|
|
||||||
const deleteJob = async () => {
|
const deleteJob = async () => {
|
||||||
try {
|
try {
|
||||||
switch (job.type) {
|
switch (job.type) {
|
||||||
@@ -84,11 +125,20 @@ function JobDetail({ job, i18n, history }) {
|
|||||||
setIsDeleteModalOpen(false);
|
setIsDeleteModalOpen(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<DetailList>
|
<DetailList>
|
||||||
{/* TODO: add status icon? */}
|
{/* TODO: hookup status to websockets */}
|
||||||
<Detail label={i18n._(t`Status`)} value={toTitleCase(job.status)} />
|
<Detail
|
||||||
|
label={i18n._(t`Status`)}
|
||||||
|
value={
|
||||||
|
<StatusDetailValue>
|
||||||
|
{job.status && <StatusIcon status={job.status} />}
|
||||||
|
{toTitleCase(job.status)}
|
||||||
|
</StatusDetailValue>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<Detail label={i18n._(t`Started`)} value={job.started} />
|
<Detail label={i18n._(t`Started`)} value={job.started} />
|
||||||
<Detail label={i18n._(t`Finished`)} value={job.finished} />
|
<Detail label={i18n._(t`Finished`)} value={job.finished} />
|
||||||
{jobTemplate && (
|
{jobTemplate && (
|
||||||
@@ -102,6 +152,18 @@ function JobDetail({ job, i18n, history }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Detail label={i18n._(t`Job Type`)} value={toTitleCase(job.job_type)} />
|
<Detail label={i18n._(t`Job Type`)} value={toTitleCase(job.job_type)} />
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Launched By`)}
|
||||||
|
value={
|
||||||
|
<>
|
||||||
|
{launchedByLink ? (
|
||||||
|
<Link to={`${launchedByLink}`}>{launchedByValue}</Link>
|
||||||
|
) : (
|
||||||
|
launchedByValue
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
{inventory && (
|
{inventory && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Inventory`)}
|
label={i18n._(t`Inventory`)}
|
||||||
@@ -110,19 +172,23 @@ function JobDetail({ job, i18n, history }) {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* TODO: show project status icon */}
|
|
||||||
{project && (
|
{project && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Project`)}
|
label={i18n._(t`Project`)}
|
||||||
value={<Link to={`/projects/${project.id}`}>{project.name}</Link>}
|
value={
|
||||||
|
<StatusDetailValue>
|
||||||
|
{project.status && <StatusIcon status={project.status} />}
|
||||||
|
<Link to={`/projects/${project.id}`}>{project.name}</Link>
|
||||||
|
</StatusDetailValue>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Detail label={i18n._(t`Revision`)} value={job.scm_revision} />
|
<Detail label={i18n._(t`Revision`)} value={job.scm_revision} />
|
||||||
<Detail label={i18n._(t`Playbook`)} value={null} />
|
<Detail label={i18n._(t`Playbook`)} value={job.playbook} />
|
||||||
<Detail label={i18n._(t`Limit`)} value={job.limit} />
|
<Detail label={i18n._(t`Limit`)} value={job.limit} />
|
||||||
<Detail label={i18n._(t`Verbosity`)} value={VERBOSITY[job.verbosity]} />
|
<Detail label={i18n._(t`Verbosity`)} value={VERBOSITY[job.verbosity]} />
|
||||||
<Detail label={i18n._(t`Environment`)} value={null} />
|
<Detail label={i18n._(t`Environment`)} value={job.custom_virtualenv} />
|
||||||
<Detail label={i18n._(t`Execution Node`)} value={job.exucution_node} />
|
<Detail label={i18n._(t`Execution Node`)} value={job.execution_node} />
|
||||||
{instanceGroup && (
|
{instanceGroup && (
|
||||||
<Detail
|
<Detail
|
||||||
label={i18n._(t`Instance Group`)}
|
label={i18n._(t`Instance Group`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user