1- import { AnalyticalTable , Icon , Popover } from '@ui5/webcomponents-react' ;
1+ import {
2+ AnalyticalTable ,
3+ Icon ,
4+ Popover ,
5+ FlexBox ,
6+ FlexBoxJustifyContent ,
7+ Button ,
8+ } from '@ui5/webcomponents-react' ;
29import { AnalyticalTableColumnDefinition } from '@ui5/webcomponents-react/wrappers' ;
310import PopoverPlacement from '@ui5/webcomponents/dist/types/PopoverPlacement.js' ;
411import '@ui5/webcomponents-icons/dist/copy' ;
@@ -10,14 +17,21 @@ import {
1017import ReactTimeAgo from 'react-time-ago' ;
1118import { AnimatedHoverTextButton } from '../Helper/AnimatedHoverTextButton.tsx' ;
1219import { useTranslation } from 'react-i18next' ;
13-
20+ import { useFrontendConfig } from '../../context/FrontendConfigContext.tsx' ;
1421export default function MCPHealthPopoverButton ( {
1522 mcpStatus,
23+ projectName,
24+ workspaceName,
25+ mcpName,
1626} : {
1727 mcpStatus : ControlPlaneStatusType | undefined ;
28+ projectName : string ;
29+ workspaceName : string ;
30+ mcpName : string ;
1831} ) {
1932 const popoverRef = useRef ( null ) ;
2033 const [ open , setOpen ] = useState ( false ) ;
34+ const { links } = useFrontendConfig ( ) ;
2135
2236 const { t } = useTranslation ( ) ;
2337
@@ -31,6 +45,46 @@ export default function MCPHealthPopoverButton({
3145 }
3246 } ;
3347
48+ const getTicketTitle = ( ) => {
49+ switch ( mcpStatus ?. status ) {
50+ case ReadyStatus . Ready :
51+ return t ( 'MCPHealthPopoverButton.supportTicketTitleReady' ) ;
52+ case ReadyStatus . NotReady :
53+ return t ( 'MCPHealthPopoverButton.supportTicketTitleNotReady' ) ;
54+ case ReadyStatus . InDeletion :
55+ return t ( 'MCPHealthPopoverButton.supportTicketTitleDeletion' ) ;
56+ default :
57+ return t ( 'MCPHealthPopoverButton.supportTicketTitleIssues' ) ;
58+ }
59+ } ;
60+
61+ const constructGithubIssuesLink = ( ) => {
62+ const clusterDetails = `${ projectName } /${ workspaceName } /${ mcpName } ` ;
63+
64+ const statusDetails = mcpStatus ?. conditions
65+ ? `${ t ( 'MCPHealthPopoverButton.statusDetailsLabel' ) } : ${ mcpStatus . status } \n\n${ t ( 'MCPHealthPopoverButton.detailsLabel' ) } \n` +
66+ mcpStatus . conditions
67+ . map ( ( condition ) => {
68+ let text = `- ${ condition . type } : ${ condition . status } \n` ;
69+ if ( condition . reason )
70+ text += ` - ${ t ( 'MCPHealthPopoverButton.reasonHeader' ) } : ${ condition . reason } \n` ;
71+ if ( condition . message )
72+ text += ` - ${ t ( 'MCPHealthPopoverButton.messageHeader' ) } : ${ condition . message } \n` ;
73+ return text ;
74+ } )
75+ . join ( '' )
76+ : '' ;
77+
78+ const params = new URLSearchParams ( {
79+ template : '1-mcp_issue.yml' ,
80+ title : `[${ clusterDetails } ]: ${ getTicketTitle ( ) } ` ,
81+ 'cluster-link' : clusterDetails ,
82+ 'what-happened' : statusDetails ,
83+ } ) ;
84+
85+ return `${ links . COM_PAGE_SUPPORT_GITHUB_ISSUE } ?${ params } ` ;
86+ } ;
87+
3488 const statusTableColumns : AnalyticalTableColumnDefinition [ ] = [
3589 {
3690 Header : t ( 'MCPHealthPopoverButton.statusHeader' ) ,
@@ -77,7 +131,13 @@ export default function MCPHealthPopoverButton({
77131 onClick = { handleOpenerClick }
78132 />
79133 < Popover ref = { popoverRef } open = { open } placement = { PopoverPlacement . Bottom } >
80- { < StatusTable status = { mcpStatus } tableColumns = { statusTableColumns } /> }
134+ {
135+ < StatusTable
136+ status = { mcpStatus }
137+ tableColumns = { statusTableColumns }
138+ githubIssuesLink = { constructGithubIssuesLink ( ) }
139+ />
140+ }
81141 </ Popover >
82142 </ div >
83143 ) ;
@@ -86,10 +146,14 @@ export default function MCPHealthPopoverButton({
86146function StatusTable ( {
87147 status,
88148 tableColumns,
149+ githubIssuesLink,
89150} : {
90151 status : ControlPlaneStatusType | undefined ;
91152 tableColumns : AnalyticalTableColumnDefinition [ ] ;
153+ githubIssuesLink : string ;
92154} ) {
155+ const { t } = useTranslation ( ) ;
156+
93157 return (
94158 < div style = { { width : 600 } } >
95159 < AnalyticalTable
@@ -101,6 +165,16 @@ function StatusTable({
101165 } ) ?? [ ]
102166 }
103167 />
168+ < FlexBox
169+ justifyContent = { FlexBoxJustifyContent . End }
170+ style = { { marginTop : '0.5rem' } }
171+ >
172+ < a href = { githubIssuesLink } target = "_blank" rel = "noreferrer" >
173+ < Button >
174+ { t ( 'MCPHealthPopoverButton.createSupportTicketButton' ) }
175+ </ Button >
176+ </ a >
177+ </ FlexBox >
104178 </ div >
105179 ) ;
106180}
0 commit comments