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
@@ -29,6 +43,37 @@ export default function MCPHealthPopoverButton({
2943 }
3044 } ;
3145
46+ const handleCopyStatusClick = ( ) => {
47+ const clusterDetails = `${ projectName } /${ workspaceName } /${ mcpName } ` ;
48+
49+ const statusDetails = mcpStatus ?. conditions
50+ ? `${ t ( 'MCPHealthPopoverButton.statusDetailsLabel' ) } : ${ mcpStatus . status } \n\n${ t ( 'MCPHealthPopoverButton.detailsLabel' ) } \n` +
51+ mcpStatus . conditions
52+ . map ( ( condition ) => {
53+ let text = `- ${ condition . type } : ${ condition . status } \n` ;
54+ if ( condition . reason )
55+ text += ` - ${ t ( 'MCPHealthPopoverButton.reasonHeader' ) } : ${ condition . reason } \n` ;
56+ if ( condition . message )
57+ text += ` - ${ t ( 'MCPHealthPopoverButton.messageHeader' ) } : ${ condition . message } \n` ;
58+ return text ;
59+ } )
60+ . join ( '' )
61+ : '' ;
62+
63+ const params = new URLSearchParams ( {
64+ template : t ( 'MCPHealthPopoverButton.templateId' ) ,
65+ title : `[${ clusterDetails } ]: ${
66+ mcpStatus ?. status === ReadyStatus . NotReady
67+ ? t ( 'MCPHealthPopoverButton.supportTicketTitle' )
68+ : t ( 'MCPHealthPopoverButton.supportTicketIssues' )
69+ } `,
70+ 'cluster-link' : clusterDetails ,
71+ 'what-happened' : statusDetails ,
72+ } ) ;
73+
74+ window . open ( `${ links . COM_PAGE_SUPPORT_ISSUE } ?${ params } ` , '_blank' ) ;
75+ } ;
76+
3277 const statusTableColumns : AnalyticalTableColumnDefinition [ ] = [
3378 {
3479 Header : t ( 'MCPHealthPopoverButton.statusHeader' ) ,
@@ -73,7 +118,13 @@ export default function MCPHealthPopoverButton({
73118 onClick = { handleOpenerClick }
74119 />
75120 < Popover ref = { popoverRef } open = { open } placement = { PopoverPlacement . Bottom } >
76- { < StatusTable status = { mcpStatus } tableColumns = { statusTableColumns } /> }
121+ {
122+ < StatusTable
123+ status = { mcpStatus }
124+ tableColumns = { statusTableColumns }
125+ onCopyClick = { handleCopyStatusClick }
126+ />
127+ }
77128 </ Popover >
78129 </ div >
79130 ) ;
@@ -82,10 +133,16 @@ export default function MCPHealthPopoverButton({
82133function StatusTable ( {
83134 status,
84135 tableColumns,
136+ onCopyClick,
85137} : {
86138 status : ControlPlaneStatusType | undefined ;
87139 tableColumns : AnalyticalTableColumnDefinition [ ] ;
140+ onCopyClick : ( ) => void ;
88141} ) {
142+ const showSupportButton =
143+ status ?. status === ReadyStatus . NotReady ||
144+ status ?. status === ReadyStatus . InDeletion ;
145+
89146 return (
90147 < div style = { { width : 600 } } >
91148 < AnalyticalTable
@@ -97,6 +154,14 @@ function StatusTable({
97154 } ) ?? [ ]
98155 }
99156 />
157+ { showSupportButton && (
158+ < FlexBox
159+ justifyContent = { FlexBoxJustifyContent . End }
160+ style = { { marginTop : '0.5rem' } }
161+ >
162+ < Button onClick = { onCopyClick } > Create Support Ticket</ Button >
163+ </ FlexBox >
164+ ) }
100165 </ div >
101166 ) ;
102167}
0 commit comments