From 3cd32270891cc8213b8cce48f95ac0606d808eeb Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Wed, 12 Mar 2025 10:21:23 +0100 Subject: [PATCH] Make the logic for moving between steps clearer --- .../Wizard/ProvisioningWizard.tsx | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/public/app/features/provisioning/Wizard/ProvisioningWizard.tsx b/public/app/features/provisioning/Wizard/ProvisioningWizard.tsx index 4b83b2c37bd..9e840540e9f 100644 --- a/public/app/features/provisioning/Wizard/ProvisioningWizard.tsx +++ b/public/app/features/provisioning/Wizard/ProvisioningWizard.tsx @@ -69,33 +69,39 @@ export function ProvisioningWizard() { }; const handleNext = async () => { - // Call verify if must const currentStepIndex = availableSteps.findIndex((s) => s.id === activeStep); const isLastStep = currentStepIndex === availableSteps.length - 1; - if (currentStepIndex < availableSteps.length - 1) { - if (activeStep === 'connection') { - // Validate repository form data before proceeding - const isValid = await methods.trigger('repository'); - if (!isValid) { - return; - } - } - // If we're on the bootstrap step, determine the next step based on the migration flag - if (activeStep === 'bootstrap') { - setActiveStep(requiresMigration ? 'migrate' : 'pull'); + if (activeStep === 'connection') { + // Validate repository form data before proceeding + const isValid = await methods.trigger('repository'); + if (!isValid) { return; } + } - // If we're on the last step, mark it as completed - if (isLastStep) { - setCompletedSteps((prev) => [...prev, activeStep]); - } - setActiveStep(availableSteps[currentStepIndex + 1].id); - setStepSuccess(false); - } else if (isLastStep) { + // If we're on the bootstrap step, determine the next step based on the migration flag + if (activeStep === 'bootstrap') { + const nextStep = requiresMigration ? 'migrate' : 'pull'; + setActiveStep(nextStep); + return; + } + + // Only navigate to provisioning URL if we're on the actual last step and it's completed + if (isLastStep && stepSuccess) { settingsQuery.refetch(); navigate(PROVISIONING_URL); + return; + } + + // For all other cases, proceed to next step + if (currentStepIndex < availableSteps.length - 1) { + setActiveStep(availableSteps[currentStepIndex + 1].id); + setStepSuccess(false); + // Update completed steps only if the current step was successful + if (stepSuccess) { + setCompletedSteps((prev) => [...prev, activeStep]); + } } };