Skip to content

Commit b9cf6b4

Browse files
committed
fix
1 parent 8faf51f commit b9cf6b4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/Wizards/CreateManagedControlPlane/CreateManagedControlPlaneWizardContainer.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,16 @@ export const CreateManagedControlPlaneWizardContainer: FC<CreateManagedControlPl
486486
isLoading: componentsLoading,
487487
error: componentsError,
488488
templateDefaultsError,
489-
} = useComponentsSelectionData(selectedTemplate, initialSelection, isOnMcpPage, (name, value, options) =>
490-
setValue(name as any, value as any, options as any),
489+
} = useComponentsSelectionData(
490+
selectedTemplate,
491+
initialSelection,
492+
isOnMcpPage,
493+
(name, value, options) => setValue(name as any, value as any, options as any),
494+
(components) =>
495+
setInitialMcpDataWhenInEditMode((prev) => ({
496+
...prev,
497+
componentsList: components,
498+
})),
491499
);
492500
// Template application for components is handled inside the hook
493501

src/components/Wizards/CreateManagedControlPlane/useComponentsSelectionData.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const useComponentsSelectionData = (
1717
initialSelection: Record<string, { isSelected: boolean; version: string }> | undefined,
1818
isOnMcpPage: boolean,
1919
setValue: (name: 'componentsList', value: ComponentsListItem[], options?: { shouldValidate?: boolean }) => void,
20+
onComponentsInitialized?: (components: ComponentsListItem[]) => void,
2021
): ComponentsHookResult => {
2122
const { data, error, isLoading } = useApiResource(ListManagedComponents(), undefined, !!isOnMcpPage);
2223

@@ -56,6 +57,9 @@ export const useComponentsSelectionData = (
5657
.filter((component) => !removeComponents.find((item) => item === component.name));
5758

5859
setValue('componentsList', newComponentsList, { shouldValidate: false });
60+
if (onComponentsInitialized) {
61+
onComponentsInitialized(newComponentsList);
62+
}
5963
// eslint-disable-next-line react-hooks/exhaustive-deps
6064
}, [JSON.stringify(data?.items), selectedTemplate, initialSelection]);
6165

0 commit comments

Comments
 (0)