11import {
2- StepCounter ,
2+ BenchmarkCreatingPlaceholder ,
3+ BenchmarkReadyStep ,
34 Wizard ,
45 WizardClose ,
56 WizardContent ,
67 WizardFooter ,
78 WizardHeader ,
8- WizardNext ,
9- WizardPrevious ,
109 WizardStep ,
1110 WizardTitle ,
1211} from '@openops/components/ui' ;
12+ import { BenchmarkCreationResult } from '@openops/shared' ;
1313import { t } from 'i18next' ;
1414import { noop } from 'lodash-es' ;
1515import { useCallback , useState } from 'react' ;
@@ -20,11 +20,13 @@ import { CreateOrEditConnectionDialog } from '@/app/features/connections/compone
2020import { CloudProvider , getProviderByValue } from '../cloud-providers' ;
2121import { useBenchmarkWizardNavigation } from '../use-benchmark-wizard-navigation' ;
2222import { useProviderConnections } from '../use-provider-connections' ;
23+ import { BenchmarkWizardFooter } from './benchmark-wizard-footer' ;
2324import { DynamicBenchmarkStep } from './dynamic-benchmark-step/dynamic-benchmark-step' ;
2425import { InitialBenchmarkStep } from './initial-benchmark-step' ;
2526
2627interface BenchmarkWizardProps {
2728 onClose : ( ) => void ;
29+ onBenchmarkCreated ?: ( result : BenchmarkCreationResult ) => void ;
2830}
2931
3032interface ProviderConnectionDialogProps {
@@ -52,7 +54,10 @@ const ProviderConnectionDialog = ({
5254 </ DynamicFormValidationProvider >
5355) ;
5456
55- export const BenchmarkWizard = ( { onClose } : BenchmarkWizardProps ) => {
57+ export const BenchmarkWizard = ( {
58+ onClose,
59+ onBenchmarkCreated,
60+ } : BenchmarkWizardProps ) => {
5661 const [ connectingProvider , setConnectingProvider ] = useState < string | null > (
5762 null ,
5863 ) ;
@@ -66,13 +71,18 @@ export const BenchmarkWizard = ({ onClose }: BenchmarkWizardProps) => {
6671 currentStepResponse,
6772 currentSelections,
6873 setCurrentSelections,
74+ isCreatingBenchmark,
75+ benchmarkCreateResult,
6976 isNextDisabled,
7077 handleNextFromInitial,
7178 handleNextFromProviderStep,
7279 handlePrevious,
73- } = useBenchmarkWizardNavigation ( connectedProviders ) ;
80+ handleEditSetup,
81+ } = useBenchmarkWizardNavigation ( connectedProviders , onBenchmarkCreated ) ;
7482
7583 const connectingProviderConfig = getProviderByValue ( connectingProvider ) ;
84+ const selectedProviderConfig = getProviderByValue ( selectedProvider ?? null ) ;
85+ const providerName = selectedProviderConfig ?. name ?? '' ;
7686
7787 const handleConnectionSaved = async ( ) => {
7888 refetchConnections ( ) ;
@@ -103,49 +113,53 @@ export const BenchmarkWizard = ({ onClose }: BenchmarkWizardProps) => {
103113 </ WizardHeader >
104114
105115 < WizardContent className = "max-h-[358px]" >
106- < WizardStep value = "initial" key = "initial" >
107- < InitialBenchmarkStep
108- selectedProvider = { selectedProvider }
109- onProviderChange = { setSelectedProvider }
110- onConnect = { setConnectingProvider }
111- connectedProviders = { connectedProviders }
112- />
113- </ WizardStep >
114- < WizardStep value = "provider-step" key = "provider-step" >
115- { currentStepResponse && (
116- < DynamicBenchmarkStep
117- stepResponse = { currentStepResponse }
118- value = { currentSelections }
119- onValueChange = { setCurrentSelections }
120- />
121- ) }
122- </ WizardStep >
123- </ WizardContent >
124-
125- < WizardFooter >
126- { wizardPhase === 'provider-step' ? (
127- < >
128- < WizardPrevious onPrevious = { handlePrevious } />
129- { currentStepResponse && (
130- < StepCounter
131- current = { currentStepResponse . stepIndex }
132- total = { currentStepResponse . totalSteps }
133- />
134- ) }
135- < WizardNext
136- onNext = { handleNextFromProviderStep }
137- disabled = { isNextDisabled }
138- />
139- </ >
116+ { isCreatingBenchmark ? (
117+ < BenchmarkCreatingPlaceholder />
140118 ) : (
141119 < >
142- < div className = "flex-1" />
143- < WizardNext
144- onNext = { handleNextFromInitial }
145- disabled = { isNextDisabled }
146- />
120+ < WizardStep value = "initial" key = "initial" >
121+ < InitialBenchmarkStep
122+ selectedProvider = { selectedProvider }
123+ onProviderChange = { setSelectedProvider }
124+ onConnect = { setConnectingProvider }
125+ connectedProviders = { connectedProviders }
126+ />
127+ </ WizardStep >
128+ < WizardStep value = "provider-step" key = "provider-step" >
129+ { currentStepResponse && (
130+ < DynamicBenchmarkStep
131+ stepResponse = { currentStepResponse }
132+ value = { currentSelections }
133+ onValueChange = { setCurrentSelections }
134+ />
135+ ) }
136+ </ WizardStep >
137+ < WizardStep value = "benchmark-ready" key = "benchmark-ready" >
138+ { benchmarkCreateResult && (
139+ < BenchmarkReadyStep
140+ providerName = { providerName }
141+ result = { benchmarkCreateResult }
142+ runPhase = "idle"
143+ onViewRun = { noop }
144+ onResetRun = { noop }
145+ />
146+ ) }
147+ </ WizardStep >
147148 </ >
148149 ) }
150+ </ WizardContent >
151+
152+ < WizardFooter >
153+ < BenchmarkWizardFooter
154+ wizardPhase = { wizardPhase }
155+ currentStepResponse = { currentStepResponse }
156+ benchmarkCreationResult = { benchmarkCreateResult }
157+ isNextDisabled = { isNextDisabled }
158+ handleNextFromInitial = { handleNextFromInitial }
159+ handleNextFromProviderStep = { handleNextFromProviderStep }
160+ handlePrevious = { handlePrevious }
161+ handleEditSetup = { handleEditSetup }
162+ />
149163 </ WizardFooter >
150164 </ Wizard >
151165 </ div >
0 commit comments