@@ -100,10 +100,11 @@ export default function TableRowCreator(props) {
100100 case 'message_count' :
101101 return < TableCell > { data . nodes . map ( node => < StringCell data = { node . details . size === '-1' ? "Not Supported" : node . details . size } /> ) } </ TableCell >
102102
103- // Message Processors
103+ // Message Processors and inbound endpoints
104+ // isDisabled : Add filter to disable the switch based on different criteria (pageId, protocol, etc.)
104105 case 'status' :
105- return < TableCell > { data . nodes . map ( node => < SwitchStatusCell pageId = { pageId } artifactName = { node . details . name }
106- nodeId = { node . nodeId } status = { node . details . status === 'active' ? true : false } retrieveData = { retrieveData } isDisabled = { pageId === 'inbound-endpoints' ? ( node . details . protocol === 'file' ? false : true ) : false } /> ) } </ TableCell >
106+ return < TableCell > { data . nodes . map ( node => < SwitchStatusCell pageId = { pageId } artifactName = { node . details . name }
107+ nodeId = { node . nodeId } status = { node . details . status === 'active' ? true : false } retrieveData = { retrieveData } isDisabled = { false } /> ) } </ TableCell >
107108
108109 // Apis
109110 case 'url' :
@@ -240,11 +241,25 @@ function StatusIcon(props) {
240241}
241242
242243function SwitchStatusCell ( props ) {
243- const { pageId, artifactName, nodeId, status, retrieveData, isDisabled} = props ;
244+ const { pageId, artifactName, nodeId, status, retrieveData, isDisabled } = props ;
244245 var isActive = status ;
245246 const globalGroupId = useSelector ( state => state . groupId ) ;
246247 const shouldBeDisabled = ! AuthManager . hasEditPermission ( ) || isDisabled ;
247248
249+ const [ errorDialog , setErrorDialog ] = React . useState ( {
250+ open : false ,
251+ title : '' ,
252+ message : ''
253+ } ) ;
254+
255+ const handleErrorDialogClose = ( ) => {
256+ setErrorDialog ( {
257+ open : false ,
258+ title : '' ,
259+ message : ''
260+ } ) ;
261+ } ;
262+
248263 const changeState = ( ) => {
249264 isActive = ! isActive
250265 updateArtifact ( )
@@ -261,10 +276,34 @@ function SwitchStatusCell(props) {
261276 if ( response . data . status === 'success' ) {
262277 retrieveData ( '' , true ) ;
263278 }
279+ } ) . catch ( error => {
280+ const serverMessage = error ?. response ?. data ?. message || error ?. message || 'Unknown error' ;
281+ console . error ( 'updateArtifact error:' , serverMessage ) ;
282+ setErrorDialog ( {
283+ open : true ,
284+ title : 'Server Error' ,
285+ message : serverMessage
286+ } ) ;
264287 } ) ;
265288 }
266289
267- return < tr > < td > < Switch checked = { isActive } onChange = { changeState } height = { 16 } width = { 36 } disabled = { shouldBeDisabled } /> </ td > </ tr >
290+ return < >
291+ < tr > < td > < Switch checked = { isActive } onChange = { changeState } height = { 16 } width = { 36 } disabled = { shouldBeDisabled } /> </ td > </ tr >
292+ < Dialog open = { errorDialog . open } onClose = { handleErrorDialogClose }
293+ aria-labelledby = "alert-dialog-title" aria-describedby = "alert-dialog-description" >
294+ < DialogTitle id = "alert-dialog-title" > { errorDialog . title } </ DialogTitle >
295+ < DialogContent dividers >
296+ < DialogContentText id = "alert-dialog-description" >
297+ { errorDialog . message }
298+ </ DialogContentText >
299+ </ DialogContent >
300+ < DialogActions >
301+ < Button onClick = { handleErrorDialogClose } variant = "contained" autoFocus >
302+ OK
303+ </ Button >
304+ </ DialogActions >
305+ </ Dialog >
306+ </ >
268307}
269308
270309function LogConfigLevelDropDown ( props ) {
0 commit comments