feat: step titles are now clickable

Signed-off-by: Federico Morreale <frc.morreale@gmail.com>
This commit is contained in:
Federico Morreale
2023-11-13 18:34:00 +01:00
parent 294ab689d4
commit e516bf4da8
2 changed files with 20 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Step titles in the Stepper are now clickable and redirect the user to the corresponding step, as an alternative to using the back buttons.
@@ -191,11 +191,21 @@ export const Stepper = (stepperProps: StepperProps) => {
<>
{isValidating && <LinearProgress variant="indeterminate" />}
<MuiStepper activeStep={activeStep} alternativeLabel variant="elevation">
{steps.map((step, index) => (
<MuiStep key={index}>
<MuiStepLabel>{step.title}</MuiStepLabel>
</MuiStep>
))}
{steps.map((step, index) => {
const isAllowedTitleClick = activeStep > index;
return (
<MuiStep key={step.title}>
<MuiStepLabel
style={{ cursor: isAllowedTitleClick ? 'pointer' : 'text' }}
onClick={() => {
if (isAllowedTitleClick) setActiveStep(index);
}}
>
{step.title}
</MuiStepLabel>
</MuiStep>
);
})}
<MuiStep>
<MuiStepLabel>Review</MuiStepLabel>
</MuiStep>