@@ -34,6 +34,7 @@ import {
3434 CreateManagedControlPlaneResource ,
3535 CreateManagedControlPlaneType ,
3636 UpdateManagedControlPlaneResource ,
37+ replaceComponentsName ,
3738} from '../../../lib/api/types/crate/createManagedControlPlane.ts' ;
3839import {
3940 CHARGING_TARGET_LABEL ,
@@ -63,6 +64,16 @@ import { Infobox } from '../../Ui/Infobox/Infobox.tsx';
6364import styles from './CreateManagedControlPlaneWizardContainer.module.css' ;
6465import { useCreateManagedControlPlane as _useCreateManagedControlPlane } from '../../../hooks/useCreateManagedControlPlane.tsx' ;
6566
67+ // Remap MCP components keys from internal replaceName back to originalName using replaceComponentsName mapping
68+ const remapComponentsKeysToOriginalNames = ( components : MCPComponentsSpec = { } ) : MCPComponentsSpec => {
69+ const remappedEntries = Object . entries ( components ) . map ( ( [ key , value ] ) => {
70+ const mapping = replaceComponentsName . find ( ( m ) => m . replaceName === key ) ;
71+ const newKey = mapping ? mapping . originalName : key ;
72+ return [ newKey , value ] as const ;
73+ } ) ;
74+ return Object . fromEntries ( remappedEntries ) as MCPComponentsSpec ;
75+ } ;
76+
6677type CreateManagedControlPlaneWizardContainerProps = {
6778 isOpen : boolean ;
6879 setIsOpen : ( isOpen : boolean ) => void ;
@@ -384,8 +395,11 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
384395 // Prepare initial selections for components when editing or duplicating
385396 const initialSelection = useMemo ( ( ) => {
386397 if ( ! isEditMode && ! isDuplicateMode ) return undefined ;
398+
399+ const originalComponentsMap : MCPComponentsSpec = initialData ?. spec . components ?? { } ;
400+ const componentsMap = remapComponentsKeysToOriginalNames ( originalComponentsMap ) ;
401+
387402 const selection : Record < string , { isSelected : boolean ; version : string } > = { } ;
388- const componentsMap : MCPComponentsSpec = initialData ?. spec . components ?? { } ;
389403 ( Object . keys ( componentsMap ) as ( keyof MCPComponentsSpec ) [ ] ) . forEach ( ( key ) => {
390404 if ( key === 'apiServer' ) return ;
391405 const value = componentsMap [ key ] ;
0 commit comments