@@ -17,7 +17,7 @@ import {
17
17
performActionOnElement ,
18
18
} from '../../extensions/advancedcharts/Utils' ;
19
19
import { IconButton } from '@neo4j-ndl/react' ;
20
- import { CloudArrowDownIconOutline , XMarkIconOutline } from '@neo4j-ndl/react/icons' ;
20
+ import { CloudArrowDownIconOutline , ArrowPathIconOutline , XMarkIconOutline } from '@neo4j-ndl/react/icons' ;
21
21
import { ThemeProvider , createTheme } from '@mui/material/styles' ;
22
22
import Button from '@mui/material/Button' ;
23
23
import { extensionEnabled } from '../../utils/ReportUtils' ;
@@ -333,7 +333,7 @@ export const NeoTableChart = (props: ChartProps) => {
333
333
throw new Error ( `Unsupported method: ${ method } ` ) ;
334
334
}
335
335
336
- props . updateReportSetting ( 'apiSpec' , { ...props . settings . apiSpec , response } ) ;
336
+ props . updateReportSetting ( 'apiSpec' , { ...props . settings ? .apiSpec , response } ) ;
337
337
} catch ( error ) {
338
338
// Handle errors here
339
339
console . error ( 'API call error:' , error ) ;
@@ -342,40 +342,52 @@ export const NeoTableChart = (props: ChartProps) => {
342
342
}
343
343
} ;
344
344
345
+ const handleResetApiResponse = ( ) => {
346
+ props . updateReportSetting ( 'apiSpec' , { ...props . settings ?. apiSpec , response : null } ) ;
347
+ } ;
348
+
345
349
const apiCallButton = ( ) => (
346
350
< Stack direction = 'row' spacing = { 2 } justifyContent = 'flex-end' marginRight = { 2 } >
347
- < ButtonGroup color = 'primary' variant = 'outlined' aria-label = 'button group' >
348
- < Button size = 'small' onClick = { handleApiCall } disabled = { isApiLoading } >
349
- { isApiLoading ? 'Loading...' : props . settings ?. sendRequestButtonName || 'send' }
350
- </ Button >
351
- < Button size = 'small' onClick = { handlePopHoverClick } disabled = { ! props . settings . apiSpec . response } >
351
+ < Button variant = 'outlined' size = 'small' onClick = { handleApiCall } disabled = { isApiLoading } >
352
+ { isApiLoading ? 'Loading...' : props . settings ?. sendRequestButtonName || 'send' }
353
+ </ Button >
354
+ { props . settings ?. apiSpec . response && (
355
+ < Button
356
+ size = 'small'
357
+ variant = 'outlined'
358
+ onClick = { handlePopHoverClick }
359
+ disabled = { ! props . settings ?. apiSpec . response }
360
+ >
352
361
{ isApiLoading ? 'Loading...' : props . settings ?. viewResponseButtonName || 'view response' }
353
362
</ Button >
354
- { props . settings . apiSpec . response ? (
355
- < Popover
356
- id = { id }
357
- open = { open }
358
- anchorEl = { anchorEl }
359
- onClose = { handlePopHoverClose }
360
- anchorOrigin = { {
361
- vertical : 'bottom' ,
362
- horizontal : 'left' ,
363
- } }
364
- transformOrigin = { {
365
- vertical : 'top' ,
366
- horizontal : 'left' ,
367
- } }
368
- >
369
- < Typography sx = { { p : 2 } } >
370
- < a href = { props . settings ?. apiSpec . response . data } target = '_blank' >
371
- { props . settings ?. apiSpec . response . data }
372
- </ a >
373
- </ Typography >
374
- </ Popover >
375
- ) : (
376
- < > </ >
377
- ) }
378
- </ ButtonGroup >
363
+ ) }
364
+ < IconButton clean = { true } grouped = { true } aria-label = { 'Reset' } onClick = { handleResetApiResponse } >
365
+ < ArrowPathIconOutline aria-label = { 'Reset' } />
366
+ </ IconButton >
367
+ { props . settings ?. apiSpec . response ? (
368
+ < Popover
369
+ id = { id }
370
+ open = { open }
371
+ anchorEl = { anchorEl }
372
+ onClose = { handlePopHoverClose }
373
+ anchorOrigin = { {
374
+ vertical : 'bottom' ,
375
+ horizontal : 'left' ,
376
+ } }
377
+ transformOrigin = { {
378
+ vertical : 'top' ,
379
+ horizontal : 'left' ,
380
+ } }
381
+ >
382
+ < Typography sx = { { p : 2 } } >
383
+ < a href = { props . settings ?. apiSpec . response . data } target = '_blank' >
384
+ { props . settings ?. apiSpec . response . data }
385
+ </ a >
386
+ </ Typography >
387
+ </ Popover >
388
+ ) : (
389
+ < > </ >
390
+ ) }
379
391
</ Stack >
380
392
) ;
381
393
0 commit comments