@@ -18,6 +18,7 @@ export interface ComponentsSelectionProps {
1818 managedControlPlaneTemplate ?: ManagedControlPlaneTemplate ;
1919 initialSelection ?: Record < string , { isSelected : boolean ; version : string } > ;
2020 isOnMcpPage ?: boolean ;
21+ initializedComponents : React . RefObject < boolean > ;
2122}
2223
2324/**
@@ -46,14 +47,15 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
4647 initialSelection,
4748 isOnMcpPage,
4849 setInitialComponentsList,
50+ initializedComponents,
4951} ) => {
5052 const {
5153 data : availableManagedComponentsListData ,
5254 error,
5355 isLoading,
5456 } = useApiResource ( ListManagedComponents ( ) , undefined , ! ! isOnMcpPage ) ;
5557 const { t } = useTranslation ( ) ;
56- const initialized = useRef ( false ) ;
58+
5759 const [ templateDefaultsError , setTemplateDefaultsError ] = useState < string | null > ( null ) ;
5860 const defaultComponents = useMemo < TemplateDefaultComponent [ ] > (
5961 ( ) => managedControlPlaneTemplate ?. spec ?. spec ?. components ?. defaultComponents ?? [ ] ,
@@ -62,7 +64,7 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
6264
6365 useEffect ( ( ) => {
6466 if (
65- initialized . current ||
67+ initializedComponents . current ||
6668 ! availableManagedComponentsListData ?. items ||
6769 availableManagedComponentsListData . items . length === 0
6870 ) {
@@ -98,7 +100,7 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
98100 . filter ( ( component ) => ! removeComponents . find ( ( item ) => item === component . name ) ) ;
99101 setInitialComponentsList ( newComponentsList ) ;
100102 setComponentsList ( newComponentsList ) ;
101- initialized . current = true ;
103+ initializedComponents . current = true ;
102104 } , [ setComponentsList , defaultComponents , initialSelection , availableManagedComponentsListData ?. items ] ) ;
103105
104106 useEffect ( ( ) => {
@@ -126,7 +128,7 @@ export const ComponentsSelectionContainer: React.FC<ComponentsSelectionProps> =
126128 } , [ availableManagedComponentsListData , defaultComponents ] ) ;
127129
128130 useEffect ( ( ) => {
129- if ( ! initialized . current ) return ;
131+ if ( ! initializedComponents . current ) return ;
130132 if ( ! defaultComponents ?. length ) return ;
131133 if ( ! componentsList ?. length ) return ;
132134 // If initialSelection is provided, do not auto-apply template defaults
0 commit comments