1- import { type FC , useEffect , useRef , useState } from 'react' ;
1+ import { type FC , useState } from 'react' ;
22
33import type { V1beta1Provider } from '@forklift-ui/types' ;
4- import { Wizard , type WizardProps , WizardStep , type WizardStepType } from '@patternfly/react-core' ;
5- import { TELEMETRY_EVENTS } from '@utils/analytics/constants' ;
6- import { useForkliftAnalytics } from '@utils/analytics/hooks/useForkliftAnalytics' ;
4+ import { Wizard , WizardStep } from '@patternfly/react-core' ;
75import { useForkliftTranslation } from '@utils/i18n' ;
86
9- import { useStepValidation } from './hooks/useStepValidation' ;
7+ import { useStepNavigation } from './hooks/useStepNavigation' ;
8+ import CustomScriptsStep from './steps/customization-scripts/CustomScriptsStep' ;
109import GeneralInformationStep from './steps/general-information/GeneralInformationStep' ;
1110import HooksStep from './steps/migration-hooks/HooksStep' ;
1211import MigrationTypeStep from './steps/migration-type/MigrationTypeStep' ;
@@ -19,7 +18,7 @@ import VirtualMachinesStepFooter from './steps/virtual-machines/VirtualMachinesS
1918import { hasLiveMigrationProviderType } from './utils/hasLiveMigrationProviderType' ;
2019import { hasPreviousStepErrors } from './utils/hasPreviousStepErrors' ;
2120import { hasWarmMigrationProviderType } from './utils/hasWarmMigrationProviderType' ;
22- import { firstStep , planStepNames , planStepOrder , PlanWizardStepId } from './constants' ;
21+ import { planStepNames , planStepOrder , PlanWizardStepId } from './constants' ;
2322import CreatePlanWizardFooter from './CreatePlanWizardFooter' ;
2423
2524type CreatePlanWizardInnerProps = {
@@ -36,56 +35,11 @@ const CreatePlanWizardInner: FC<CreatePlanWizardInnerProps> = ({
3635 sourceProvider,
3736} ) => {
3837 const { t } = useForkliftTranslation ( ) ;
39- const { trackEvent } = useForkliftAnalytics ( ) ;
40- const [ currentStep , setCurrentStep ] = useState < WizardStepType > ( firstStep ) ;
4138 const [ createPlanError , setCreatePlanError ] = useState < Error | undefined > ( ) ;
42- const { hasStepErrors, validateStep } = useStepValidation ( ) ;
43- const initialStepTracked = useRef ( false ) ;
39+ const { currentStep, handleStepChange, hasStepErrors } = useStepNavigation ( ) ;
4440
4541 const hasCreatePlanError = Boolean ( createPlanError ?. message ) ;
4642
47- // Track initial step visit when wizard loads
48- useEffect ( ( ) => {
49- if ( ! initialStepTracked . current ) {
50- initialStepTracked . current = true ;
51- trackEvent ( TELEMETRY_EVENTS . PLAN_WIZARD_STEP_VISITED , {
52- stepId : firstStep . id ,
53- } ) ;
54- }
55- } , [ trackEvent ] ) ;
56-
57- const handleStepChange : WizardProps [ 'onStepChange' ] = async ( _event , newStep ) => {
58- const currentStepId = currentStep . id as PlanWizardStepId ;
59- const newStepId = newStep . id as PlanWizardStepId ;
60- const newStepOrder = planStepOrder [ newStepId ] ;
61- const currentStepOrder = planStepOrder [ currentStepId ] ;
62-
63- if ( currentStepId === newStepId ) {
64- return ;
65- }
66-
67- // Allow backward navigation without validation
68- if ( newStepOrder <= currentStepOrder ) {
69- setCurrentStep ( newStep ) ;
70- trackEvent ( TELEMETRY_EVENTS . PLAN_WIZARD_STEP_VISITED , {
71- stepId : newStepId ,
72- } ) ;
73- return ;
74- }
75-
76- try {
77- const isCurrentStepValid = await validateStep ( currentStepId ) ;
78- if ( isCurrentStepValid ) {
79- setCurrentStep ( newStep ) ;
80- trackEvent ( TELEMETRY_EVENTS . PLAN_WIZARD_STEP_VISITED , {
81- stepId : newStepId ,
82- } ) ;
83- }
84- } catch {
85- // Stay on current step if validation throws
86- }
87- } ;
88-
8943 const handleSubmit = async ( ) => {
9044 setCreatePlanError ( undefined ) ;
9145 try {
@@ -163,6 +117,12 @@ const CreatePlanWizardInner: FC<CreatePlanWizardInnerProps> = ({
163117 >
164118 < OtherSettingsStep isLiveMigrationFeatureEnabled = { isLiveMigrationFeatureEnabled } />
165119 </ WizardStep > ,
120+ < WizardStep
121+ key = { PlanWizardStepId . CustomizationScripts }
122+ { ...getStepProps ( PlanWizardStepId . CustomizationScripts ) }
123+ >
124+ < CustomScriptsStep />
125+ </ WizardStep > ,
166126 < WizardStep key = { PlanWizardStepId . Hooks } { ...getStepProps ( PlanWizardStepId . Hooks ) } >
167127 < HooksStep />
168128 </ WizardStep > ,
0 commit comments