From bd28f04a5cf199ebea3e9d49c61e73a859dc4c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 21 Oct 2025 10:48:35 +0200 Subject: [PATCH 1/4] Update createManagedControlPlane.ts --- .../types/crate/createManagedControlPlane.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/api/types/crate/createManagedControlPlane.ts b/src/lib/api/types/crate/createManagedControlPlane.ts index 315a5fa4..39872774 100644 --- a/src/lib/api/types/crate/createManagedControlPlane.ts +++ b/src/lib/api/types/crate/createManagedControlPlane.ts @@ -58,12 +58,11 @@ export interface CreateManagedControlPlaneType { } // rename is used to make creation of MCP working properly -const replaceComponentsName: Record = { - 'sap-btp-service-operator': 'btpServiceOperator', - 'external-secrets': 'externalSecretsOperator', -}; - -export const removeComponents = ['cert-manager']; +type ReplaceComponentName = { originalName: string; replaceName: string }; +const replaceComponentsName: ReplaceComponentName[] = [ + { originalName: 'sap-btp-service-operator', replaceName: 'btpServiceOperator' }, + { originalName: 'external-secrets', replaceName: 'externalSecretsOperator' }, +]; export const CreateManagedControlPlane = ( name: string, @@ -83,12 +82,13 @@ export const CreateManagedControlPlane = ( (component) => component.isSelected && !component.name.includes('provider') && !component.name.includes('crossplane'), ) - .map((component) => ({ - ...component, - name: Object.prototype.hasOwnProperty.call(replaceComponentsName, component.name) - ? replaceComponentsName[component.name] - : component.name, - })) + .map((component) => { + const mapping = replaceComponentsName.find((m) => m.originalName === component.name); + return { + ...component, + name: mapping ? mapping.replaceName : component.name, + }; + }) .reduce((acc, item) => { acc[item.name] = { version: item.selectedVersion }; return acc; From 9c746d1ea259b7169d9c8573347f0318faff995d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 21 Oct 2025 11:45:24 +0200 Subject: [PATCH 2/4] fix --- .../ComponentsSelectionContainer.tsx | 17 +++++++++++------ .../types/crate/createManagedControlPlane.ts | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx index 9d6a3435..68ea4aa6 100644 --- a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx +++ b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { ComponentsSelection } from './ComponentsSelection.tsx'; import IllustratedError from '../Shared/IllustratedError.tsx'; import Loading from '../Shared/Loading.tsx'; -import { ComponentsListItem } from '../../lib/api/types/crate/createManagedControlPlane.ts'; +import { ComponentsListItem, replaceComponentsName } from '../../lib/api/types/crate/createManagedControlPlane.ts'; import { useTranslation } from 'react-i18next'; export interface ComponentsSelectionProps { @@ -19,11 +19,16 @@ export interface ComponentsSelectionProps { */ export const getSelectedComponents = (components: ComponentsListItem[]) => { const isCrossplaneSelected = components.some(({ name, isSelected }) => name === 'crossplane' && isSelected); - return components.filter((component) => { - if (!component.isSelected) return false; - if (component.name?.includes('provider') && !isCrossplaneSelected) return false; - return true; - }); + + return components + .filter(({ isSelected, name }) => isSelected && (isCrossplaneSelected || !name?.includes('provider'))) + .map((component) => { + const mapping = replaceComponentsName.find((m) => m.replaceName === component.name); + return { + ...component, + name: mapping ? mapping.originalName : component.name, + }; + }); }; export const ComponentsSelectionContainer: React.FC = ({ diff --git a/src/lib/api/types/crate/createManagedControlPlane.ts b/src/lib/api/types/crate/createManagedControlPlane.ts index 39872774..d17717b0 100644 --- a/src/lib/api/types/crate/createManagedControlPlane.ts +++ b/src/lib/api/types/crate/createManagedControlPlane.ts @@ -58,8 +58,7 @@ export interface CreateManagedControlPlaneType { } // rename is used to make creation of MCP working properly -type ReplaceComponentName = { originalName: string; replaceName: string }; -const replaceComponentsName: ReplaceComponentName[] = [ +export const replaceComponentsName: { originalName: string; replaceName: string }[] = [ { originalName: 'sap-btp-service-operator', replaceName: 'btpServiceOperator' }, { originalName: 'external-secrets', replaceName: 'externalSecretsOperator' }, ]; From 6bb3a05032a6126932db26a953b4d4290585154c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 21 Oct 2025 14:08:49 +0200 Subject: [PATCH 3/4] fix --- .../ComponentsSelectionContainer.tsx | 5 +++-- .../CreateManagedControlPlaneWizardContainer.tsx | 16 +++++++++++++++- .../api/types/crate/createManagedControlPlane.ts | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx index 68ea4aa6..afc97045 100644 --- a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx +++ b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx @@ -2,7 +2,8 @@ import React from 'react'; import { ComponentsSelection } from './ComponentsSelection.tsx'; import IllustratedError from '../Shared/IllustratedError.tsx'; import Loading from '../Shared/Loading.tsx'; -import { ComponentsListItem, replaceComponentsName } from '../../lib/api/types/crate/createManagedControlPlane.ts'; +import type { ComponentsListItem } from '../../lib/api/types/crate/createManagedControlPlane.ts'; +import * as mcp from '../../lib/api/types/crate/createManagedControlPlane.ts'; import { useTranslation } from 'react-i18next'; export interface ComponentsSelectionProps { @@ -23,7 +24,7 @@ export const getSelectedComponents = (components: ComponentsListItem[]) => { return components .filter(({ isSelected, name }) => isSelected && (isCrossplaneSelected || !name?.includes('provider'))) .map((component) => { - const mapping = replaceComponentsName.find((m) => m.replaceName === component.name); + const mapping = mcp.replaceComponentsName.find((m) => m.replaceName === component.name); return { ...component, name: mapping ? mapping.originalName : component.name, diff --git a/src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx b/src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx index dbcc2057..9a8615f7 100644 --- a/src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx +++ b/src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx @@ -34,6 +34,7 @@ import { CreateManagedControlPlaneResource, CreateManagedControlPlaneType, UpdateManagedControlPlaneResource, + replaceComponentsName, } from '../../../lib/api/types/crate/createManagedControlPlane.ts'; import { CHARGING_TARGET_LABEL, @@ -62,6 +63,16 @@ import { useComponentsSelectionData } from './useComponentsSelectionData.ts'; import { Infobox } from '../../Ui/Infobox/Infobox.tsx'; import styles from './CreateManagedControlPlaneWizardContainer.module.css'; +// Remap MCP components keys from internal replaceName back to originalName using replaceComponentsName mapping +const remapComponentsKeysToOriginalNames = (components: MCPComponentsSpec = {}): MCPComponentsSpec => { + const remappedEntries = Object.entries(components).map(([key, value]) => { + const mapping = replaceComponentsName.find((m) => m.replaceName === key); + const newKey = mapping ? mapping.originalName : key; + return [newKey, value] as const; + }); + return Object.fromEntries(remappedEntries) as MCPComponentsSpec; +}; + type CreateManagedControlPlaneWizardContainerProps = { isOpen: boolean; setIsOpen: (isOpen: boolean) => void; @@ -378,8 +389,11 @@ export const CreateManagedControlPlaneWizardContainer: FC { if (!isEditMode && !isDuplicateMode) return undefined; + + const originalComponentsMap: MCPComponentsSpec = initialData?.spec.components ?? {}; + const componentsMap = remapComponentsKeysToOriginalNames(originalComponentsMap); + const selection: Record = {}; - const componentsMap: MCPComponentsSpec = initialData?.spec.components ?? {}; (Object.keys(componentsMap) as (keyof MCPComponentsSpec)[]).forEach((key) => { if (key === 'apiServer') return; const value = componentsMap[key]; diff --git a/src/lib/api/types/crate/createManagedControlPlane.ts b/src/lib/api/types/crate/createManagedControlPlane.ts index d17717b0..7d6e29d6 100644 --- a/src/lib/api/types/crate/createManagedControlPlane.ts +++ b/src/lib/api/types/crate/createManagedControlPlane.ts @@ -57,6 +57,8 @@ export interface CreateManagedControlPlaneType { spec: Spec; } +export const removeComponents = ['cert-manager']; + // rename is used to make creation of MCP working properly export const replaceComponentsName: { originalName: string; replaceName: string }[] = [ { originalName: 'sap-btp-service-operator', replaceName: 'btpServiceOperator' }, From 7edd3b1548b1333d423057746ed0a66b51e4f9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Goral?= Date: Tue, 21 Oct 2025 14:10:01 +0200 Subject: [PATCH 4/4] Update ComponentsSelectionContainer.tsx --- .../ComponentsSelection/ComponentsSelectionContainer.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx index afc97045..68ea4aa6 100644 --- a/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx +++ b/src/components/ComponentsSelection/ComponentsSelectionContainer.tsx @@ -2,8 +2,7 @@ import React from 'react'; import { ComponentsSelection } from './ComponentsSelection.tsx'; import IllustratedError from '../Shared/IllustratedError.tsx'; import Loading from '../Shared/Loading.tsx'; -import type { ComponentsListItem } from '../../lib/api/types/crate/createManagedControlPlane.ts'; -import * as mcp from '../../lib/api/types/crate/createManagedControlPlane.ts'; +import { ComponentsListItem, replaceComponentsName } from '../../lib/api/types/crate/createManagedControlPlane.ts'; import { useTranslation } from 'react-i18next'; export interface ComponentsSelectionProps { @@ -24,7 +23,7 @@ export const getSelectedComponents = (components: ComponentsListItem[]) => { return components .filter(({ isSelected, name }) => isSelected && (isCrossplaneSelected || !name?.includes('provider'))) .map((component) => { - const mapping = mcp.replaceComponentsName.find((m) => m.replaceName === component.name); + const mapping = replaceComponentsName.find((m) => m.replaceName === component.name); return { ...component, name: mapping ? mapping.originalName : component.name,