@@ -37,8 +37,6 @@ import {
3737 CHARGING_TARGET_LABEL ,
3838 CHARGING_TARGET_TYPE_LABEL ,
3939 DISPLAY_NAME_ANNOTATION ,
40- PROJECT_NAME_LABEL ,
41- WORKSPACE_LABEL ,
4240} from '../../../lib/api/types/shared/keyNames.ts' ;
4341import { OnCreatePayload } from '../../Dialogs/CreateProjectWorkspaceDialog.tsx' ;
4442import { idpPrefix } from '../../../utils/idpPrefix.ts' ;
@@ -50,6 +48,7 @@ import { IllustratedBanner } from '../../Ui/IllustratedBanner/IllustratedBanner.
5048import { ManagedControlPlaneTemplate , noTemplateValue } from '../../../lib/api/types/templates/mcpTemplate.ts' ;
5149import { stripIdpPrefix } from '../../../utils/stripIdpPrefix.ts' ;
5250import { buildNameWithPrefixesAndSuffixes } from '../../../utils/buildNameWithPrefixesAndSuffixes.ts' ;
51+ import { ManagedControlPlaneInterface } from './mcp_type.ts' ;
5352
5453type CreateManagedControlPlaneWizardContainerProps = {
5554 isOpen : boolean ;
@@ -58,7 +57,7 @@ type CreateManagedControlPlaneWizardContainerProps = {
5857 workspaceName ?: string ;
5958 isEditMode : boolean ;
6059 initialTemplateName ?: string ;
61- initialData ?: any ;
60+ initialData ?: ManagedControlPlaneInterface ;
6261} ;
6362
6463type WizardStepType = 'metadata' | 'members' | 'componentSelection' | 'summarize' | 'success' ;
@@ -195,7 +194,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
195194 CreateManagedControlPlaneResource ( projectName , workspaceName ) ,
196195 ) ;
197196 const { trigger : triggerUpdate } = useApiResourceMutation < CreateManagedControlPlaneType > (
198- UpdateManagedControlPlaneResource ( projectName , workspaceName , initialData ?. metadata ?. name ) ,
197+ UpdateManagedControlPlaneResource ( projectName , workspaceName , initialData ?. metadata ?. name ?? '' ) ,
199198 ) ;
200199 const componentsList = watch ( 'componentsList' ) ;
201200
@@ -214,7 +213,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
214213 if ( isEditMode ) {
215214 await triggerUpdate (
216215 CreateManagedControlPlane (
217- initialData . metadata . name ,
216+ initialData ? .metadata ? .name ?? '' ,
218217 `${ projectName } --ws-${ workspaceName } ` ,
219218 {
220219 displayName,
@@ -354,10 +353,10 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
354353 const initialSelection = useMemo ( ( ) => {
355354 if ( ! isEditMode ) return undefined ;
356355 const selection : Record < string , { isSelected : boolean ; version : string } > = { } ;
357- const components = initialData . spec . components as any ;
358- Object . keys ( components ) . forEach ( ( key ) => {
356+ const components = initialData ? .spec . components ;
357+ Object . keys ( components ?? { } ) . forEach ( ( key ) => {
359358 if ( key === 'apiServer' || key === 'landscaper' ) return ;
360- const value = components [ key ] ;
359+ const value = components ?. [ key ] ;
361360 if ( key === 'crossplane' ) {
362361 selection [ key ] = { isSelected : true , version : value . version ?? '' } ;
363362 ( value . providers ?? [ ] ) . forEach ( ( prov : { name : string ; version : string } ) => {
@@ -373,7 +372,7 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
373372 // Prefill form when editing
374373 useEffect ( ( ) => {
375374 if ( ! isOpen || ! isEditMode ) return ;
376- const roleBindings = initialData . spec . authorization . roleBindings ?? [ ] ;
375+ const roleBindings = initialData ? .spec ? .authorization ? .roleBindings ?? [ ] ;
377376 const members : Member [ ] = roleBindings . flatMap ( ( rb ) =>
378377 ( rb . subjects ?? [ ] ) . map ( ( s : any ) => ( {
379378 kind : s . kind ,
@@ -382,11 +381,11 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
382381 namespace : s . namespace ,
383382 } ) ) ,
384383 ) ;
385- const labels = ( initialData . metadata . labels as unknown as Record < string , string > ) ?? { } ;
386- const annotations = ( initialData . metadata . annotations as unknown as Record < string , string > ) ?? { } ;
384+ const labels = ( initialData ? .metadata . labels as unknown as Record < string , string > ) ?? { } ;
385+ const annotations = ( initialData ? .metadata . annotations as unknown as Record < string , string > ) ?? { } ;
387386
388387 reset ( {
389- name : initialData . metadata . name ,
388+ name : initialData ? .metadata . name ,
390389 displayName : annotations ?. [ DISPLAY_NAME_ANNOTATION ] ?? '' ,
391390 chargingTarget : labels ?. [ CHARGING_TARGET_LABEL ] ?? '' ,
392391 chargingTargetType : labels ?. [ CHARGING_TARGET_TYPE_LABEL ] ?? '' ,
0 commit comments