@@ -7,7 +7,8 @@ import * as yup from 'yup';
77import { Box , Link , WizardProps } from '@cloudscape-design/components' ;
88import { CardsProps } from '@cloudscape-design/components/cards' ;
99
10- import { Container , FormCodeEditor , FormField , FormInput , FormSelect , SpaceBetween , Wizard } from 'components' ;
10+ import type { ToggleProps } from 'components' ;
11+ import { Container , FormCodeEditor , FormField , FormInput , FormSelect , SpaceBetween , Toggle , Wizard } from 'components' ;
1112
1213import { useBreadcrumbs , useNotifications } from 'hooks' ;
1314import { getServerError } from 'libs' ;
@@ -18,6 +19,7 @@ import { OfferList } from 'pages/Offers/List';
1819import { convertMiBToGB , renderRange , round } from 'pages/Offers/List/helpers' ;
1920
2021import { getRunSpecFromYaml } from './helpers/getRunSpecFromYaml' ;
22+ import { useGenerateYaml } from './hooks/useGenerateYaml' ;
2123
2224import { IRunEnvironmentFormValues } from './types' ;
2325
@@ -161,6 +163,16 @@ export const CreateDevEnvironment: React.FC = () => {
161163 onNavigate ( { requestedStepIndex, reason } ) ;
162164 } ;
163165
166+ const toggleDocker : ToggleProps [ 'onChange' ] = ( { detail } ) => {
167+ setValue ( 'docker' , detail . checked ) ;
168+
169+ if ( detail . checked ) {
170+ setValue ( 'python' , '' ) ;
171+ } else {
172+ setValue ( 'image' , '' ) ;
173+ }
174+ } ;
175+
164176 const onChangeOffer : CardsProps < IGpu > [ 'onSelectionChange' ] = ( { detail } ) => {
165177 const newSelectedOffers = detail ?. selectedItems ?? [ ] ;
166178 setSelectedOffers ( newSelectedOffers ) ;
@@ -227,31 +239,13 @@ export const CreateDevEnvironment: React.FC = () => {
227239 }
228240 } ;
229241
230- useEffect ( ( ) => {
231- if ( ! formValues . offer || ! formValues . ide ) {
232- return ;
233- }
234-
235- setValue (
236- 'config_yaml' ,
237- `type: dev-environment
238- ${ `${
239- formValues . name
240- ? `name: ${ formValues . name }
241-
242- `
243- : ''
244- } `} ide: ${ formValues . ide }
242+ const yaml = useGenerateYaml ( { formValues } ) ;
245243
246- resources:
247- gpu: ${ formValues . offer . name } :${ round ( convertMiBToGB ( formValues . offer . memory_mib ) ) } GB:${ renderRange ( formValues . offer . count ) }
244+ console . log ( yaml ) ;
248245
249- backends: [${ formValues . offer . backends ?. join ( ', ' ) } ]
250-
251- spot_policy: auto
252- ` ,
253- ) ;
254- } , [ formValues . name , formValues . ide , formValues . offer ] ) ;
246+ useEffect ( ( ) => {
247+ setValue ( 'config_yaml' , yaml ) ;
248+ } , [ yaml ] ) ;
255249
256250 return (
257251 < form className = { cn ( { [ styles . wizardForm ] : activeStepIndex === 0 } ) } onSubmit = { handleSubmit ( onSubmit ) } >
@@ -304,6 +298,7 @@ spot_policy: auto
304298 name = "name"
305299 disabled = { loading }
306300 />
301+
307302 < FormSelect
308303 label = { t ( 'runs.dev_env.wizard.ide' ) }
309304 description = { t ( 'runs.dev_env.wizard.ide_description' ) }
@@ -312,6 +307,46 @@ spot_policy: auto
312307 options = { ideOptions }
313308 disabled = { loading }
314309 />
310+
311+ < Toggle checked = { formValues . docker } onChange = { toggleDocker } >
312+ { t ( 'runs.dev_env.wizard.docker' ) }
313+ </ Toggle >
314+
315+ < FormInput
316+ label = { t ( 'runs.dev_env.wizard.docker_image' ) }
317+ description = { t ( 'runs.dev_env.wizard.docker_image_description' ) }
318+ placeholder = { t ( 'runs.dev_env.wizard.docker_image_placeholder' ) }
319+ control = { control }
320+ name = "image"
321+ disabled = { loading || ! formValues . docker }
322+ />
323+
324+ < FormInput
325+ label = { t ( 'runs.dev_env.wizard.python' ) }
326+ description = { t ( 'runs.dev_env.wizard.python_description' ) }
327+ placeholder = { t ( 'runs.dev_env.wizard.python_placeholder' ) }
328+ control = { control }
329+ name = "python"
330+ disabled = { loading || formValues . docker }
331+ />
332+
333+ < FormInput
334+ label = { t ( 'runs.dev_env.wizard.repo' ) }
335+ description = { t ( 'runs.dev_env.wizard.repo_description' ) }
336+ placeholder = { t ( 'runs.dev_env.wizard.repo_placeholder' ) }
337+ control = { control }
338+ name = "repo"
339+ disabled = { loading }
340+ />
341+
342+ < FormInput
343+ label = { t ( 'runs.dev_env.wizard.repo_local_path' ) }
344+ description = { t ( 'runs.dev_env.wizard.repo_local_path_description' ) }
345+ placeholder = { t ( 'runs.dev_env.wizard.repo_local_path_placeholder' ) }
346+ control = { control }
347+ name = "repo_local_path"
348+ disabled = { loading }
349+ />
315350 </ SpaceBetween >
316351 </ Container >
317352 ) ,
0 commit comments