Skip to content

Commit d0dfd22

Browse files
committed
Update CreateManagedControlPlaneWizardContainer.tsx
1 parent 873b75c commit d0dfd22

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ import { IllustratedBanner } from '../../Ui/IllustratedBanner/IllustratedBanner.
4848
import { ManagedControlPlaneTemplate, noTemplateValue } from '../../../lib/api/types/templates/mcpTemplate.ts';
4949
import { stripIdpPrefix } from '../../../utils/stripIdpPrefix.ts';
5050
import { buildNameWithPrefixesAndSuffixes } from '../../../utils/buildNameWithPrefixesAndSuffixes.ts';
51-
import { ManagedControlPlaneInterface } from '../../../lib/api/types/mcpResource.ts';
51+
import {
52+
ManagedControlPlaneInterface,
53+
MCPComponentsSpec,
54+
MCPCrossplaneComponent,
55+
MCPVersionedComponent,
56+
MCPSubject,
57+
} from '../../../lib/api/types/mcpResource.ts';
5258

5359
type CreateManagedControlPlaneWizardContainerProps = {
5460
isOpen: boolean;
@@ -355,17 +361,21 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
355361
const initialSelection = useMemo(() => {
356362
if (!isEditMode) return undefined;
357363
const selection: Record<string, { isSelected: boolean; version: string }> = {};
358-
const componentsMap = (initialData?.spec.components ?? {}) as Record<string, any>;
359-
Object.keys(componentsMap).forEach((key) => {
360-
if (key === 'apiServer' || key === 'landscaper') return;
364+
const componentsMap: MCPComponentsSpec = initialData?.spec.components ?? {};
365+
(Object.keys(componentsMap) as (keyof MCPComponentsSpec)[]).forEach((key) => {
366+
if (key === 'apiServer') return;
361367
const value = componentsMap[key];
362368
if (key === 'crossplane') {
363-
selection[key] = { isSelected: true, version: value.version ?? '' };
364-
(value.providers ?? []).forEach((prov: { name: string; version: string }) => {
369+
const crossplane = (value as MCPCrossplaneComponent) ?? {};
370+
selection[key as string] = { isSelected: true, version: crossplane.version ?? '' };
371+
(crossplane.providers ?? []).forEach((prov) => {
365372
selection[prov.name] = { isSelected: true, version: prov.version ?? '' };
366373
});
367374
} else {
368-
selection[key] = { isSelected: true, version: value.version ?? '' };
375+
const versioned = value as MCPVersionedComponent | undefined;
376+
if (versioned) {
377+
selection[key as string] = { isSelected: true, version: versioned.version ?? '' };
378+
}
369379
}
370380
});
371381
return selection;
@@ -376,10 +386,10 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
376386
if (!isOpen || !isEditMode) return;
377387
const roleBindings = initialData?.spec?.authorization?.roleBindings ?? [];
378388
const members: Member[] = roleBindings.flatMap((rb) =>
379-
(rb.subjects ?? []).map((s: any) => ({
389+
(rb.subjects ?? []).map((s: MCPSubject) => ({
380390
kind: s.kind,
381391
name: s.kind === 'User' && s.name?.includes(':') ? s.name.split(':').slice(1).join(':') : s.name,
382-
roles: [rb.role],
392+
roles: [normalizeMemberRole(rb.role)],
383393
namespace: s.namespace,
384394
})),
385395
);

0 commit comments

Comments
 (0)