@@ -53,6 +53,13 @@ type CreateManagedControlPlaneWizardContainerProps = {
5353
5454type WizardStepType = 'metadata' | 'members' | 'summarize' | 'success' ;
5555
56+ const wizardStepOrder : WizardStepType [ ] = [
57+ 'metadata' ,
58+ 'members' ,
59+ 'summarize' ,
60+ 'success' ,
61+ ] ;
62+
5663export const CreateManagedControlPlaneWizardContainer : FC <
5764 CreateManagedControlPlaneWizardContainerProps
5865> = ( { isOpen, setIsOpen, projectName = '' , workspaceName = '' } ) => {
@@ -80,7 +87,6 @@ export const CreateManagedControlPlaneWizardContainer: FC<
8087 members : [ ] ,
8188 } ,
8289 mode : 'onChange' ,
83- reValidateMode : 'onChange' ,
8490 } ) ;
8591
8692 const nextButtonText = useMemo (
@@ -218,6 +224,13 @@ export const CreateManagedControlPlaneWizardContainer: FC<
218224 [ selectedStep , isValid ] ,
219225 ) ;
220226
227+ const onBackClick = useCallback ( ( ) => {
228+ const currentIndex = wizardStepOrder . indexOf ( selectedStep ) ;
229+ if ( currentIndex > 0 ) {
230+ setSelectedStep ( wizardStepOrder [ currentIndex - 1 ] ) ;
231+ }
232+ } , [ selectedStep ] ) ;
233+
221234 return (
222235 < Dialog
223236 stretch
@@ -229,19 +242,17 @@ export const CreateManagedControlPlaneWizardContainer: FC<
229242 design = "Footer"
230243 endContent = {
231244 < div style = { { display : 'flex' , alignItems : 'center' , gap : 8 } } >
232- { selectedStep !== 'success' && (
233- < Button design = "Negative" onClick = { resetFormAndClose } >
234- { t ( 'buttons.close' ) }
235- </ Button >
236- ) }
237- < Button
238- design = "Emphasized"
239- disabled = {
240- ( selectedStep === 'metadata' && ! isValid ) ||
241- ( selectedStep === 'summarize' && ! isValid )
242- }
243- onClick = { onNextClick }
244- >
245+ { selectedStep !== 'success' &&
246+ ( selectedStep === 'metadata' ? (
247+ < Button design = "Negative" onClick = { resetFormAndClose } >
248+ { t ( 'buttons.close' ) }
249+ </ Button >
250+ ) : (
251+ < Button design = "Negative" onClick = { onBackClick } >
252+ { t ( 'buttons.back' ) }
253+ </ Button >
254+ ) ) }
255+ < Button design = "Emphasized" onClick = { onNextClick } >
245256 { nextButtonText [ selectedStep ] }
246257 </ Button >
247258 </ div >
0 commit comments