1616 * under the License.
1717 */
1818
19- import React from 'react' ;
19+ import React , { useState } from 'react' ;
2020import API from 'AppData/api' ;
2121import { FormattedMessage , useIntl } from 'react-intl' ;
2222import { Link as RouterLink } from 'react-router-dom' ;
@@ -27,7 +27,10 @@ import AddEdit from 'AppComponents/GatewayEnvironments/AddEditGWEnvironment';
2727import { useAppContext } from 'AppComponents/Shared/AppContext' ;
2828import Button from '@mui/material/Button' ;
2929import EditIcon from '@mui/icons-material/Edit' ;
30+ import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted' ;
31+ import IconButton from '@mui/material/IconButton' ;
3032import Permission from './Permission' ;
33+ import ListGatewayInstances from './ListGatewayInstances' ;
3134
3235/**
3336 * API call to get Gateway labels
@@ -53,6 +56,23 @@ export default function ListGWEnviornments() {
5356 const intl = useIntl ( ) ;
5457 let columProps ;
5558 const { settings } = useAppContext ( ) ;
59+ // Dialog state for Live Gateways
60+ const [ liveGatewaysOpen , setLiveGatewaysOpen ] = useState ( false ) ;
61+ const [ selectedEnvId , setSelectedEnvId ] = useState ( null ) ;
62+ const [ selectedEnvName , setSelectedEnvName ] = useState ( '' ) ;
63+
64+ const handleOpenLiveGateways = ( envId , envName ) => {
65+ setSelectedEnvId ( envId ) ;
66+ setSelectedEnvName ( envName ) ;
67+ setLiveGatewaysOpen ( true ) ;
68+ } ;
69+
70+ const handleCloseLiveGateways = ( ) => {
71+ setLiveGatewaysOpen ( false ) ;
72+ setSelectedEnvId ( null ) ;
73+ setSelectedEnvName ( '' ) ;
74+ } ;
75+
5676 const isGatewayTypeAvailable = settings . gatewayTypes . length >= 2 ;
5777 if ( isGatewayTypeAvailable ) {
5878 columProps = [
@@ -139,6 +159,33 @@ export default function ListGWEnviornments() {
139159 } ,
140160 } ,
141161 } ,
162+ ...( settings . isGatewayNotificationEnabled ? [
163+ {
164+ name : 'gatewayInstances' ,
165+ label : intl . formatMessage ( {
166+ id : 'AdminPages.Gateways.table.header.gatewayInstances' ,
167+ defaultMessage : 'Gateway Instances' ,
168+ } ) ,
169+ options : {
170+ sort : false ,
171+ customBodyRender : ( value , tableMeta ) => {
172+ if ( typeof tableMeta . rowData === 'object' ) {
173+ const envId = tableMeta . rowData [ 8 ] ; // 'id' is the last column
174+ const envName = tableMeta . rowData [ 1 ] ; // 'displayName'
175+ return (
176+ < IconButton
177+ onClick = { ( ) => handleOpenLiveGateways ( envId , envName ) }
178+ >
179+ < FormatListBulletedIcon aria-label = 'gateway-instances-list-icon' />
180+ </ IconButton >
181+ ) ;
182+ } else {
183+ return < div /> ;
184+ }
185+ } ,
186+ } ,
187+ } ,
188+ ] : [ ] ) ,
142189 { name : 'id' , options : { display : false } } ,
143190 ] ;
144191 } else {
@@ -216,6 +263,33 @@ export default function ListGWEnviornments() {
216263 } ,
217264 } ,
218265 } ,
266+ ...( settings . isGatewayNotificationEnabled ? [
267+ {
268+ name : 'gatewayInstances' ,
269+ label : intl . formatMessage ( {
270+ id : 'AdminPages.Gateways.table.header.gatewayInstances' ,
271+ defaultMessage : 'Gateway Instances' ,
272+ } ) ,
273+ options : {
274+ sort : false ,
275+ customBodyRender : ( value , tableMeta ) => {
276+ if ( typeof tableMeta . rowData === 'object' ) {
277+ const envId = tableMeta . rowData [ 8 ] ; // 'id' is the last column
278+ const envName = tableMeta . rowData [ 1 ] ; // 'displayName'
279+ return (
280+ < IconButton
281+ onClick = { ( ) => handleOpenLiveGateways ( envId , envName ) }
282+ >
283+ < FormatListBulletedIcon aria-label = 'gateway-instances-list-icon' />
284+ </ IconButton >
285+ ) ;
286+ } else {
287+ return < div /> ;
288+ }
289+ } ,
290+ } ,
291+ } ,
292+ ] : [ ] ) ,
219293 { name : 'id' , options : { display : false } } ,
220294 ] ;
221295 }
@@ -284,21 +358,29 @@ export default function ListGWEnviornments() {
284358 } ;
285359
286360 return (
287- < ListBase
288- columProps = { columProps }
289- pageProps = { pageProps }
290- addButtonProps = { addButtonProps }
291- searchProps = { searchProps }
292- emptyBoxProps = { emptyBoxProps }
293- apiCall = { apiCall }
294- EditComponent = { AddEdit }
295- addButtonOverride = { addCreateButton ( ) }
296- editComponentProps = { {
297- icon : < EditIcon /> ,
298- title : 'Edit Gateway Label' ,
299- routeTo : '/settings/environments/' ,
300- } }
301- DeleteComponent = { Delete }
302- />
361+ < >
362+ < ListBase
363+ columProps = { columProps }
364+ pageProps = { pageProps }
365+ addButtonProps = { addButtonProps }
366+ searchProps = { searchProps }
367+ emptyBoxProps = { emptyBoxProps }
368+ apiCall = { apiCall }
369+ EditComponent = { AddEdit }
370+ addButtonOverride = { addCreateButton ( ) }
371+ editComponentProps = { {
372+ icon : < EditIcon /> ,
373+ title : 'Edit Gateway Label' ,
374+ routeTo : '/settings/environments/' ,
375+ } }
376+ DeleteComponent = { Delete }
377+ />
378+ < ListGatewayInstances
379+ open = { liveGatewaysOpen }
380+ onClose = { handleCloseLiveGateways }
381+ environmentId = { selectedEnvId }
382+ environmentName = { selectedEnvName }
383+ />
384+ </ >
303385 ) ;
304386}
0 commit comments