11import { Card , CardHeader , ProgressIndicator , Button } from '@ui5/webcomponents-react' ;
22import { RadarChart } from '@ui5/webcomponents-react-charts' ;
33import { useTranslation } from 'react-i18next' ;
4+ import cx from 'clsx' ;
45import { APIError } from '../../lib/api/error' ;
5- import { getDisabledCardStyle } from './Hints' ;
6+ import { styles } from './Hints' ;
67import { ManagedResourceItem , Condition } from '../../lib/shared/types' ;
78import React from 'react' ;
89
@@ -25,8 +26,6 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
2526} ) => {
2627 const { t } = useTranslation ( ) ;
2728
28- const cardStyle = enabled ? { } : getDisabledCardStyle ( ) ;
29-
3029 // Aggregate healthiness by resource type
3130 const resourceTypeHealth : Record < string , number > = { } ;
3231 const resourceTypeTotal : Record < string , number > = { } ;
@@ -41,11 +40,26 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
4140 }
4241 } ) ;
4342
44- // Prepare radar chart dataset: each resource type is a dimension, value is percent healthy
45- const radarDataset = Object . keys ( resourceTypeTotal ) . map ( type => ( {
46- type,
47- health : `${ Math . round ( ( ( resourceTypeHealth [ type ] || 0 ) / resourceTypeTotal [ type ] ) * 100 ) } %`
48- } ) ) ;
43+ // Prepare radar chart dataset: each resource type is a dimension, values are counts for healthy and creating
44+ const radarDataset = Object . keys ( resourceTypeTotal ) . map ( type => {
45+ const total = resourceTypeTotal [ type ] ;
46+ const healthy = resourceTypeHealth [ type ] || 0 ;
47+
48+ // Count creating resources (no conditions yet or unknown status)
49+ const creating = allItems . filter ( ( item : ManagedResourceItem ) => {
50+ if ( item . kind !== type ) return false ;
51+ const conditions = item . status ?. conditions || [ ] ;
52+ const hasReadyCondition = conditions . some ( ( c : Condition ) => c . type === 'Ready' ) ;
53+ const hasSyncedCondition = conditions . some ( ( c : Condition ) => c . type === 'Synced' ) ;
54+ return ! hasReadyCondition || ! hasSyncedCondition ;
55+ } ) . length ;
56+
57+ return {
58+ type,
59+ healthy : Math . round ( ( healthy / total ) * 100 ) ,
60+ creating : Math . round ( ( creating / total ) * 100 )
61+ } ;
62+ } ) ;
4963
5064 // Progress bar logic (unchanged)
5165 const healthyCount = allItems . filter ( ( item : ManagedResourceItem ) => {
@@ -88,19 +102,23 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
88102 }
89103 titleText = { t ( 'Hints.CrossplaneHint.title' ) }
90104 subtitleText = { t ( 'Hints.CrossplaneHint.subtitle' ) }
91- interactive = { true }
105+ interactive = { enabled }
92106 />
93107 }
94- style = { cardStyle }
95- onClick = { ( ) => {
108+ className = { cx ( {
109+ [ styles [ 'disabled' ] ] : ! enabled ,
110+ } ) }
111+ onClick = { enabled ? ( ) => {
96112 const el = document . querySelector ( '.crossplane-table-element' ) ;
97113 if ( el ) {
98114 el . scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
99115 }
100- } }
101- onMouseEnter = { ( ) => setHovered ( true ) }
102- onMouseLeave = { ( ) => setHovered ( false ) }
116+ } : undefined }
117+ onMouseEnter = { enabled ? ( ) => setHovered ( true ) : undefined }
118+ onMouseLeave = { enabled ? ( ) => setHovered ( false ) : undefined }
103119 >
120+ { /* Disabled overlay */ }
121+ { ! enabled && < div className = { styles . disabledOverlay } /> }
104122
105123 < div style = { { display : 'flex' , flexDirection : 'column' , alignItems : 'center' , padding : '1rem 0' } } >
106124 { isLoading ? (
@@ -138,19 +156,36 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
138156 />
139157 ) }
140158 </ div >
141- { /* Minimal RadarChart for resource healthiness, only show on hover */ }
142- { hovered && ! isLoading && ! error && radarDataset . length > 0 && (
143- < div style = { { width : 260 , height : 260 , display : 'flex' , justifyContent : 'center' , alignItems : 'center' , margin : '1rem 0' , overflow : 'visible' } } >
159+ { /* RadarChart for resource healthiness, only show on hover when enabled */ }
160+ { enabled && hovered && ! isLoading && ! error && radarDataset . length > 0 && (
161+ < div style = { {
162+ width : '100%' ,
163+ height : 300 ,
164+ display : 'flex' ,
165+ justifyContent : 'center' ,
166+ alignItems : 'center' ,
167+ margin : '1rem 0' ,
168+ overflow : 'visible'
169+ } } >
144170 < RadarChart
145171 dataset = { radarDataset }
146172 dimensions = { [ { accessor : 'type' } ] }
147- measures = { [ {
148- accessor : 'health' ,
149- color : 'green' ,
150- hideDataLabel : true ,
151- } ] }
152- style = { { width : 220 , height : 220 } }
153- noLegend = { true }
173+ measures = { [
174+ {
175+ accessor : 'healthy' ,
176+ color : '#28a745' ,
177+ hideDataLabel : true ,
178+ label : 'Healthy (%)'
179+ } ,
180+ {
181+ accessor : 'creating' ,
182+ color : '#fd7e14' ,
183+ hideDataLabel : true ,
184+ label : 'Creating (%)'
185+ }
186+ ] }
187+ style = { { width : '100%' , height : '100%' , minWidth : 280 , minHeight : 280 } }
188+ noLegend = { false }
154189 />
155190 </ div >
156191 ) }
0 commit comments