diff --git a/ui/src/reusable_ui/components/wizard/WizardProgressBar.tsx b/ui/src/reusable_ui/components/wizard/WizardProgressBar.tsx index 98eb51345..ab8b4097a 100644 --- a/ui/src/reusable_ui/components/wizard/WizardProgressBar.tsx +++ b/ui/src/reusable_ui/components/wizard/WizardProgressBar.tsx @@ -24,27 +24,32 @@ class WizardProgressBar extends PureComponent { private get WizardProgress(): JSX.Element { const {steps, currentStepIndex, handleJump} = this.props - const progressBar = steps.reduce((acc, step, i) => { + const progressBar = steps.reduce((acc, step, index) => { const {stepStatus} = step let currentStep = '' + const isCurrentStep = index === currentStepIndex + const isNotErrored = stepStatus !== StepStatus.Error + const isAtEndOfWizard = currentStepIndex === steps.length - 1 + const isCompleted = stepStatus === StepStatus.Complete + const isLastStep = index === steps.length - 1 + const previousIsComplete = + steps[index - 1] && steps[index - 1].stepStatus === StepStatus.Complete + // STEP STATUS - if (i === currentStepIndex && stepStatus !== StepStatus.Error) { + if (isCurrentStep && isNotErrored) { currentStep = 'circle-thick current' } - if ( - i === steps.length - 1 && - steps[i - 1].stepStatus === StepStatus.Complete - ) { + if (isLastStep && previousIsComplete) { currentStep = 'checkmark' } const stepEle = (
{step.title}
@@ -54,20 +59,20 @@ class WizardProgressBar extends PureComponent { // PROGRESS BAR CONNECTOR let connectorStatus = ConnectorState.None - if (i === currentStepIndex && stepStatus !== StepStatus.Error) { + if (isCurrentStep && isNotErrored) { connectorStatus = ConnectorState.Some } - if (i === steps.length - 1 || stepStatus === StepStatus.Complete) { + + if (isAtEndOfWizard || isLastStep || isCompleted) { connectorStatus = ConnectorState.Full } - const connectorEle = - i === steps.length - 1 ? null : ( - - ) + const connectorEle = isLastStep ? null : ( + + ) return [...acc, stepEle, connectorEle] }, [])