@@ -13,7 +13,7 @@ import { ControlPlane as ControlPlaneResource } from '../../../lib/api/types/cra
1313import { useTranslation } from 'react-i18next' ;
1414import { McpContextProvider , WithinManagedControlPlane } from '../../../lib/shared/McpContext.tsx' ;
1515import MCPHealthPopoverButton from '../../../components/ControlPlane/MCPHealthPopoverButton.tsx' ;
16- import { useApiResource } from '../../../lib/api/useApiResource.ts' ;
16+ import { useApiResource , useProvidersConfigResource } from '../../../lib/api/useApiResource.ts' ;
1717
1818import { YamlViewButtonWithLoader } from '../../../components/Yaml/YamlViewButtonWithLoader.tsx' ;
1919import { AuthProviderMcp } from '../auth/AuthContextMcp.tsx' ;
@@ -29,6 +29,7 @@ import { ManagedResources } from '../../../components/ControlPlane/ManagedResour
2929import { Providers } from '../../../components/ControlPlane/Providers.tsx' ;
3030import { ProvidersConfig } from '../../../components/ControlPlane/ProvidersConfig.tsx' ;
3131import FluxList from '../../../components/ControlPlane/FluxList.tsx' ;
32+ import { resolveProviderType } from '../../../components/Graphs/graphUtils' ;
3233
3334// Utility function to flatten managed resources
3435const flattenManagedResources = ( managedResources : ManagedResourcesResponse ) : ManagedResourceItem [ ] => {
@@ -39,6 +40,51 @@ const flattenManagedResources = (managedResources: ManagedResourcesResponse): Ma
3940 . flatMap ( ( managedResource ) => managedResource . items || [ ] ) ;
4041} ;
4142
43+ // Utility function to calculate provider distribution with graph colors
44+ const calculateProviderDistribution = ( items : ManagedResourceItem [ ] , providerConfigs : any [ ] ) => {
45+ if ( ! items || items . length === 0 ) return { segments : [ ] , totalProviders : 0 } ;
46+
47+ // Graph color palette (same as in graphUtils.ts)
48+ const colors = [
49+ '#FFC933' , // MANGO 4
50+ '#FF8AF0' , // PINK 4
51+ '#FEADC8' , // RASPBERRY 4
52+ '#2CE0BF' , // TEAL 4
53+ '#FF8CB2' , // RED 4
54+ '#B894FF' , // INDIGO 4
55+ '#049F9A' , // TEAL 6
56+ '#FA4F96' , // RASPBERRY 6
57+ '#F31DED' , // PINK 6
58+ '#7858FF' , // INDIGO 6
59+ ] ;
60+
61+ // Count resources by provider type (same method as graph)
62+ const providerCounts : Record < string , number > = { } ;
63+
64+ items . forEach ( item => {
65+ const providerConfigName = item ?. spec ?. providerConfigRef ?. name ?? 'unknown' ;
66+ const providerType = resolveProviderType ( providerConfigName , providerConfigs ) ;
67+ providerCounts [ providerType ] = ( providerCounts [ providerType ] || 0 ) + 1 ;
68+ } ) ;
69+
70+ // Convert to segments with percentages and counts
71+ const total = items . length ;
72+ const segments = Object . entries ( providerCounts )
73+ . map ( ( [ provider , count ] , index ) => ( {
74+ percentage : Math . round ( ( count / total ) * 100 ) ,
75+ color : colors [ index % colors . length ] ,
76+ label : provider . replace ( 'provider-' , '' ) . toUpperCase ( ) ,
77+ count : count
78+ } ) )
79+ . filter ( segment => segment . percentage > 0 )
80+ . sort ( ( a , b ) => b . percentage - a . percentage ) ;
81+
82+ return {
83+ segments,
84+ totalProviders : segments . length
85+ } ;
86+ } ;
87+
4288export default function McpPage ( ) {
4389 const { projectName, workspaceName, controlPlaneName } = useParams ( ) ;
4490 const { t } = useTranslation ( ) ;
@@ -93,15 +139,26 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
93139 refreshInterval : resourcesInterval ,
94140 } ) ;
95141
142+ // Fetch provider configs for distribution calculation
143+ const { data : providerConfigsList } = useProvidersConfigResource ( {
144+ refreshInterval : 60000 ,
145+ } ) ;
146+
96147 // Flatten all managed resources once and pass to components
97148 const allItems = useMemo (
98149 ( ) => flattenManagedResources ( managedResources ?? ( [ ] as unknown as ManagedResourcesResponse ) ) ,
99150 [ managedResources ] ,
100151 ) ;
101152
153+ // Calculate provider distribution for crossplane card
154+ const providerDistribution = useMemo (
155+ ( ) => calculateProviderDistribution ( allItems , providerConfigsList || [ ] ) ,
156+ [ allItems , providerConfigsList ] ,
157+ ) ;
158+
102159 // Get hint configurations
103160 const crossplaneConfig = useCrossplaneHintConfig ( ) ;
104- const gitOpsConfig = useGitOpsHintConfig ( ) ;
161+ const gitOpsConfig = useGitOpsHintConfig ( ) ; // DEACTIVATED via enabled={false}
105162 const vaultConfig = useESOHintConfig ( ) ;
106163 const veleroConfig = useKyvernoHintConfig ( ) ;
107164
@@ -190,6 +247,8 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
190247 config = { crossplaneConfig }
191248 onClick = { expandedCard === 'crossplane' ? handleCollapseExpanded : handleCrossplaneExpand }
192249 size = "large"
250+ secondarySegments = { providerDistribution . segments }
251+ secondaryLabel = { `Providers ${ providerDistribution . totalProviders } ` }
193252 />
194253 { expandedCard === 'crossplane' && (
195254 < Button
@@ -209,7 +268,7 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
209268 </ BentoCard >
210269 ) }
211270
212- { /* GitOps component - shows when expanded */ }
271+ { /* GitOps component - shows when expanded - DEACTIVATED */ }
213272 { expandedCard === 'gitops' && (
214273 < BentoCard
215274 size = "large"
@@ -219,7 +278,7 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
219278 >
220279 < div style = { { position : 'relative' , height : '100%' } } >
221280 < ComponentCard
222- enabled = { ! ! mcp ?. spec ?. components ?. flux }
281+ enabled = { true }
223282 version = { mcp ?. spec ?. components ?. flux ?. version }
224283 allItems = { allItems }
225284 isLoading = { managedResourcesLoading }
@@ -260,15 +319,15 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
260319 { /* Right side cards - hide when any component is expanded */ }
261320 { ! expandedCard && (
262321 < >
263- { /* Right side: First medium component (GitOps) */ }
322+ { /* Right side: First medium component (GitOps) - DEACTIVATED */ }
264323 < BentoCard
265324 size = "medium"
266325 gridColumn = "9 / 13"
267326 gridRow = "1 / 3"
268- className = { isExpanding ? styles . hidingCard : '' }
327+ className = { isExpanding ? styles . hidingCard : styles . disabledCard }
269328 >
270329 < ComponentCard
271- enabled = { ! ! mcp ?. spec ?. components ?. flux }
330+ enabled = { true }
272331 version = { mcp ?. spec ?. components ?. flux ?. version }
273332 allItems = { allItems }
274333 isLoading = { managedResourcesLoading }
@@ -279,15 +338,15 @@ function McpPageContent({ mcp, controlPlaneName }: { mcp: any; controlPlaneName:
279338 />
280339 </ BentoCard >
281340
282- { /* Right side: Second medium component (GitOps copy) */ }
341+ { /* Right side: Second medium component (GitOps copy) - DEACTIVATED */ }
283342 < BentoCard
284343 size = "medium"
285344 gridColumn = "9 / 13"
286345 gridRow = "3 / 5"
287- className = { isExpanding ? styles . hidingCard : '' }
346+ className = { isExpanding ? styles . hidingCard : styles . disabledCard }
288347 >
289348 < ComponentCard
290- enabled = { ! ! mcp ?. spec ?. components ?. flux }
349+ enabled = { false }
291350 version = { mcp ?. spec ?. components ?. flux ?. version }
292351 allItems = { allItems }
293352 isLoading = { managedResourcesLoading }
0 commit comments