1- import { AnalyticalTable , Icon , Popover , FlexBox , FlexBoxJustifyContent , Button } from '@ui5/webcomponents-react' ;
1+ import {
2+ AnalyticalTable ,
3+ Icon ,
4+ Popover ,
5+ FlexBox ,
6+ FlexBoxJustifyContent ,
7+ Button ,
8+ PopoverDomRef ,
9+ ButtonDomRef ,
10+ } from '@ui5/webcomponents-react' ;
211import { AnalyticalTableColumnDefinition } from '@ui5/webcomponents-react/wrappers' ;
312import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js' ;
413import '@ui5/webcomponents-icons/dist/copy' ;
5- import { JSX , useRef , useState } from 'react' ;
6- import { ControlPlaneStatusType , ReadyStatus } from '../../lib/api/types/crate/controlPlanes' ;
14+ import { JSX , useRef , useState , ReactNode } from 'react' ;
15+ import type { ButtonClickEventDetail } from '@ui5/webcomponents/dist/Button.js' ;
16+ import {
17+ ControlPlaneStatusType ,
18+ ReadyStatus ,
19+ ControlPlaneStatusCondition ,
20+ } from '../../lib/api/types/crate/controlPlanes' ;
721import ReactTimeAgo from 'react-time-ago' ;
822import { AnimatedHoverTextButton } from '../Helper/AnimatedHoverTextButton.tsx' ;
923import { useTranslation } from 'react-i18next' ;
1024import { useLink } from '../../lib/shared/useLink.ts' ;
1125import TooltipCell from '../Shared/TooltipCell.tsx' ;
12- export default function MCPHealthPopoverButton ( {
13- mcpStatus,
14- projectName,
15- workspaceName,
16- mcpName,
17- } : {
26+ import type { Ui5CustomEvent } from '@ui5/webcomponents-react-base' ;
27+
28+ interface CellData < T > {
29+ cell : {
30+ value : ReactNode ;
31+ } ;
32+ row : {
33+ original : T ;
34+ [ key : string ] : unknown ;
35+ } ;
36+ [ key : string ] : unknown ;
37+ }
38+
39+ type MCPHealthPopoverButtonProps = {
1840 mcpStatus : ControlPlaneStatusType | undefined ;
1941 projectName : string ;
2042 workspaceName : string ;
2143 mcpName : string ;
22- } ) {
23- const popoverRef = useRef ( null ) ;
44+ } ;
45+
46+ const MCPHealthPopoverButton = ( { mcpStatus, projectName, workspaceName, mcpName } : MCPHealthPopoverButtonProps ) => {
47+ const popoverRef = useRef < PopoverDomRef > ( null ) ;
2448 const [ open , setOpen ] = useState ( false ) ;
2549 const { githubIssuesSupportTicket } = useLink ( ) ;
26-
2750 const { t } = useTranslation ( ) ;
2851
29- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30- const handleOpenerClick = ( e : any ) => {
52+ const handleOpenerClick = ( event : Ui5CustomEvent < ButtonDomRef , ButtonClickEventDetail > ) => {
3153 if ( popoverRef . current ) {
32- // eslint-disable-next-line @typescript-eslint/no-explicit-any
33- const ref = popoverRef . current as any ;
34- ref . opener = e . target ;
54+ ( popoverRef . current as unknown as { opener : EventTarget | null } ) . opener = event . target ;
3555 setOpen ( ( prev ) => ! prev ) ;
3656 }
3757 } ;
3858
39- const getTicketTitle = ( ) => {
59+ const getTicketTitle = ( ) : string => {
4060 switch ( mcpStatus ?. status ) {
4161 case ReadyStatus . Ready :
4262 return t ( 'MCPHealthPopoverButton.supportTicketTitleReady' ) ;
@@ -49,13 +69,13 @@ export default function MCPHealthPopoverButton({
4969 }
5070 } ;
5171
52- const constructGithubIssuesLink = ( ) => {
72+ const constructGithubIssuesLink = ( ) : string => {
5373 const clusterDetails = `${ projectName } /${ workspaceName } /${ mcpName } ` ;
5474
5575 const statusDetails = mcpStatus ?. conditions
5676 ? `${ t ( 'MCPHealthPopoverButton.statusDetailsLabel' ) } : ${ mcpStatus . status } \n\n${ t ( 'MCPHealthPopoverButton.detailsLabel' ) } \n` +
57- mcpStatus ? .conditions
58- . map ( ( condition ) => {
77+ mcpStatus . conditions
78+ . map ( ( condition : ControlPlaneStatusCondition ) => {
5979 let text = `- ${ condition . type } : ${ condition . status } \n` ;
6080 if ( condition . reason ) text += ` - ${ t ( 'MCPHealthPopoverButton.reasonHeader' ) } : ${ condition . reason } \n` ;
6181 if ( condition . message ) text += ` - ${ t ( 'MCPHealthPopoverButton.messageHeader' ) } : ${ condition . message } \n` ;
@@ -79,8 +99,7 @@ export default function MCPHealthPopoverButton({
7999 Header : t ( 'MCPHealthPopoverButton.statusHeader' ) ,
80100 accessor : 'status' ,
81101 width : 50 ,
82- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83- Cell : ( instance : any ) => {
102+ Cell : ( instance : CellData < ControlPlaneStatusCondition > ) => {
84103 const isReady = instance . cell . value === 'True' ;
85104 return (
86105 < Icon
@@ -94,38 +113,33 @@ export default function MCPHealthPopoverButton({
94113 Header : t ( 'MCPHealthPopoverButton.typeHeader' ) ,
95114 accessor : 'type' ,
96115 width : 150 ,
97- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98- Cell : ( instance : any ) => {
116+ Cell : ( instance : CellData < ControlPlaneStatusCondition > ) => {
99117 return < TooltipCell > { instance . cell . value } </ TooltipCell > ;
100118 } ,
101119 } ,
102120 {
103121 Header : t ( 'MCPHealthPopoverButton.messageHeader' ) ,
104122 accessor : 'message' ,
105123 width : 350 ,
106- // eslint-disable-next-line @typescript-eslint/no-explicit-any
107- Cell : ( instance : any ) => {
124+ Cell : ( instance : CellData < ControlPlaneStatusCondition > ) => {
108125 return < TooltipCell > { instance . cell . value } </ TooltipCell > ;
109126 } ,
110127 } ,
111128 {
112129 Header : t ( 'MCPHealthPopoverButton.reasonHeader' ) ,
113130 accessor : 'reason' ,
114131 width : 100 ,
115- // eslint-disable-next-line @typescript-eslint/no-explicit-any
116- Cell : ( instance : any ) => {
132+ Cell : ( instance : CellData < ControlPlaneStatusCondition > ) => {
117133 return < TooltipCell > { instance . cell . value } </ TooltipCell > ;
118134 } ,
119135 } ,
120136 {
121137 Header : t ( 'MCPHealthPopoverButton.transitionHeader' ) ,
122138 accessor : 'lastTransitionTime' ,
123- width : 110 ,
124- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125- Cell : ( instance : any ) => {
139+ width : 125 ,
140+ Cell : ( instance : CellData < ControlPlaneStatusCondition > ) => {
126141 const rawDate = instance . cell . value ;
127- const date = new Date ( rawDate ) ;
128-
142+ const date = new Date ( rawDate as string ) ;
129143 return (
130144 < TooltipCell >
131145 < ReactTimeAgo date = { date } />
@@ -143,58 +157,50 @@ export default function MCPHealthPopoverButton({
143157 onClick = { handleOpenerClick }
144158 />
145159 < Popover ref = { popoverRef } open = { open } placement = { PopoverPlacement . Bottom } >
146- {
147- < StatusTable
148- status = { mcpStatus }
149- tableColumns = { statusTableColumns }
150- githubIssuesLink = { constructGithubIssuesLink ( ) }
151- />
152- }
160+ < StatusTable
161+ status = { mcpStatus }
162+ tableColumns = { statusTableColumns }
163+ githubIssuesLink = { constructGithubIssuesLink ( ) }
164+ />
153165 </ Popover >
154166 </ div >
155167 ) ;
156- }
168+ } ;
157169
158- function StatusTable ( {
159- status,
160- tableColumns,
161- githubIssuesLink,
162- } : {
170+ export default MCPHealthPopoverButton ;
171+
172+ type StatusTableProps = {
163173 status : ControlPlaneStatusType | undefined ;
164174 tableColumns : AnalyticalTableColumnDefinition [ ] ;
165175 githubIssuesLink : string ;
166- } ) {
176+ } ;
177+
178+ const StatusTable = ( { status, tableColumns, githubIssuesLink } : StatusTableProps ) => {
167179 const { t } = useTranslation ( ) ;
168180
181+ const sortedConditions = status ?. conditions ? [ ...status . conditions ] . sort ( ( a , b ) => ( a . type < b . type ? - 1 : 1 ) ) : [ ] ;
182+
169183 return (
170184 < div style = { { width : 770 } } >
171- < AnalyticalTable
172- scaleWidthMode = "Default"
173- columns = { tableColumns }
174- data = {
175- status ?. conditions ?. sort ( ( a , b ) => {
176- return a . type < b . type ? - 1 : 1 ;
177- } ) ?? [ ]
178- }
179- />
185+ < AnalyticalTable scaleWidthMode = "Default" columns = { tableColumns } data = { sortedConditions } />
180186 < FlexBox justifyContent = { FlexBoxJustifyContent . End } style = { { marginTop : '0.5rem' } } >
181187 < a href = { githubIssuesLink } target = "_blank" rel = "noreferrer" >
182188 < Button > { t ( 'MCPHealthPopoverButton.createSupportTicketButton' ) } </ Button >
183189 </ a >
184190 </ FlexBox >
185191 </ div >
186192 ) ;
187- }
193+ } ;
188194
189- function getIconForOverallStatus ( status : ReadyStatus | undefined ) : JSX . Element {
195+ const getIconForOverallStatus = ( status : ReadyStatus | undefined ) : JSX . Element => {
190196 switch ( status ) {
191197 case ReadyStatus . Ready :
192198 return < Icon style = { { color : 'green' } } name = "sap-icon://sys-enter" /> ;
193199 case ReadyStatus . NotReady :
194200 return < Icon style = { { color : 'red' } } name = "sap-icon://pending" /> ;
195201 case ReadyStatus . InDeletion :
196202 return < Icon style = { { color : 'orange' } } name = "sap-icon://delete" /> ;
197- case undefined :
203+ default :
198204 return < > </ > ;
199205 }
200- }
206+ } ;
0 commit comments