diff --git a/src/components/Job/JobDetails.js b/src/components/Job/JobDetails.js index 206b8967d9e1a1231eb8be6a8008dd80f697849b..628cbb0589b6268f454d1458599696bad9dc46af 100644 --- a/src/components/Job/JobDetails.js +++ b/src/components/Job/JobDetails.js @@ -7,8 +7,8 @@ import { Container, Link as MuiLink } from "@mui/material"; -import { DeploymentStepper } from "../deployments/DeploymentStepper"; import { KeyValueTable, SimpleAccordion } from "@ess-ics/ce-ui-common"; +import { Stepper } from "@ess-ics/ce-ui-common"; import { JobBadge } from "./JobBadge"; import { DeploymentJobOutput } from "../deployments/DeploymentJobOutput"; import { Link as ReactRouterLink } from "react-router-dom"; @@ -18,6 +18,21 @@ import AccessControl from "../auth/AccessControl"; import { AWXJobDetails } from "../../api/DataTypes"; import AlertMessages from "../IOC/AlertMessages"; +const STATUS = { + queued: { + label: "Queued", + alertType: "info" + }, + running: { + label: "Running", + alertType: "info" + }, + successful: { + label: "Completed", + alertType: "success" + } +}; + function createAlert(operation, job) { const jobDetails = new AWXJobDetails(operation.type, job); const message = jobDetails.message(); @@ -38,11 +53,6 @@ export function JobDetails({ operation, job }) { const [alert, setAlert] = useState(createAlert(operation, job)); - const jobDetails = useMemo( - () => new AWXJobDetails(operation.type, job), - [operation, job] - ); - useEffect(() => { setAlert(createAlert(operation, job, finishedJob)); }, [finishedJob, operation, job]); @@ -116,6 +126,17 @@ export function JobDetails({ operation, job }) { : "-" }; + const normalizedStatus = job?.status?.toLowerCase(); + + const currentStep = Object.keys(STATUS).indexOf(normalizedStatus); + var activeStep = STATUS[normalizedStatus] ? currentStep + 1 : currentStep; + const jobFailed = job?.status?.toLowerCase() === "failed"; + + // to show the correct failed step for an already finished operation + if (jobFailed) { + activeStep = operation?.startTime ? 1 : 0; + } + return ( <Grid container @@ -155,12 +176,10 @@ export function JobDetails({ operation, job }) { <CardContent> <div> {job && ( - <DeploymentStepper - activeStep={["queued", "running", "successful"].indexOf( - job.status.toLowerCase() - )} - deploymentStart={operation.startDate} - jobDetails={jobDetails} + <Stepper + steps={Object.values(STATUS).map((it) => it.label)} + activeStep={activeStep} + isActiveStepFailed={jobFailed} /> )} </div>