@@ -127,12 +127,13 @@ export default function WorkloadsCreateEditPage({
127127 handleSubmit,
128128 watch,
129129 setValue,
130+ reset,
130131 formState : { errors } ,
131132 } = methods
132133
133134 // Fetch catalog info only when creating (no workloadName)
134135 useEffect ( ( ) => {
135- if ( workloadName ) return
136+ if ( workloadName ) reset ( mergedDefaultValues )
136137
137138 getWorkloadCatalog ( { body : { url : '' , sub : user . sub , teamId } } ) . then ( ( res : any ) => {
138139 const { url, catalog } : { url : string ; catalog : any [ ] } = res . data
@@ -161,6 +162,10 @@ export default function WorkloadsCreateEditPage({
161162 typeof valuesData === 'string' ? valuesData : YAML . stringify ( valuesData ?? { } ) ,
162163 )
163164
165+ useEffect ( ( ) => {
166+ if ( workload ) console . log ( 'halo raw values' , workload )
167+ } , [ workload ] )
168+
164169 useEffect ( ( ) => {
165170 setWorkloadValuesYaml ( typeof valuesData === 'string' ? valuesData : YAML . stringify ( valuesData ?? { } ) )
166171 } , [ workloadData , valuesData ] )
@@ -175,14 +180,18 @@ export default function WorkloadsCreateEditPage({
175180 const mutating = isLoadingDWL || isCreating || isUpdating
176181 if ( ! mutating && isSuccessDWL ) return < Redirect to = { `/teams/${ teamId } /workloads` } />
177182
178- const icon = workloadData ?. icon || '/logos/akamai_logo.svg'
183+ const icon = workloadData ?. spec ?. icon || catalogItem . icon
184+ const headerName = workloadData ?. metadata ?. name || catalogItem . name
185+ const headerPath = workloadData ?. spec ?. path || catalogItem . path
179186
180187 // ---- Auto image updater state ----
181188 type AutoUpdaterType = 'disabled' | 'digest' | 'semver'
182189 const watchedStrategyType = watch ( 'spec.imageUpdateStrategy.type' ) as AutoUpdaterType | undefined
190+ // eslint-disable-next-line react-hooks/rules-of-hooks
183191 const [ autoUpdaterType , setAutoUpdaterType ] = useState < AutoUpdaterType > ( 'disabled' )
184192
185193 // initialise local state from form values
194+ // eslint-disable-next-line react-hooks/rules-of-hooks
186195 useEffect ( ( ) => {
187196 if ( watchedStrategyType ) setAutoUpdaterType ( watchedStrategyType )
188197 } , [ watchedStrategyType ] )
@@ -321,12 +330,12 @@ export default function WorkloadsCreateEditPage({
321330 </ Box >
322331 < Box >
323332 < Typography variant = 'h6' >
324- { workloadData ?. name ? `${ workloadData . name } (${ workloadData . path } )` : workloadData ?. path }
333+ { headerName && headerPath ? `${ headerName } (${ headerPath } )` : headerName ?? headerPath }
325334 </ Typography >
326335 </ Box >
327- { workloadData ?. url && workloadData ?. path && (
336+ { workloadData ?. spec ?. url && workloadData ?. spec ?. path && (
328337 < Box sx = { { ml : 'auto' } } >
329- < DocsLink href = { getDocsLink ( workloadData . url as string , workloadData . path as string ) } />
338+ < DocsLink href = { getDocsLink ( workloadData . spec . url as string , workloadData . spec . path as string ) } />
330339 </ Box >
331340 ) }
332341 </ Box >
@@ -356,7 +365,7 @@ export default function WorkloadsCreateEditPage({
356365 value = { autoUpdaterType }
357366 onChange = { handleAutoUpdaterChange }
358367 />
359- { autoUpdaterType === 'digest' && (
368+ { /* { autoUpdaterType === 'digest' && (
360369 <Box sx={{ mt: 3, maxWidth: 480 }}>
361370 <TextField
362371 label='Version'
@@ -377,7 +386,7 @@ export default function WorkloadsCreateEditPage({
377386 {...methods.register('spec.imageUpdateStrategy.semver.versionConstraint' as const)}
378387 />
379388 </Box>
380- ) }
389+ )} */ }
381390 { /* {autoUpdaterType === 'disabled' && (
382391 <Box sx={{ mt: 3, maxWidth: 480 }}>
383392 <TextField label='Version' width='large' noMarginTop placeholder='latest, feat, dev' disabled />
0 commit comments