Skip to content

Commit c83982e

Browse files
Merge pull request #142 from mercedes-benz/VULCAN-941/GrayedOutButton
fix: addressed review comments for api extension changes
2 parents 9bb0502 + 3b1f247 commit c83982e

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

src/chart/table/TableChart.tsx

+44-32
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
performActionOnElement,
1818
} from '../../extensions/advancedcharts/Utils';
1919
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';
2121
import { ThemeProvider, createTheme } from '@mui/material/styles';
2222
import Button from '@mui/material/Button';
2323
import { extensionEnabled } from '../../utils/ReportUtils';
@@ -333,7 +333,7 @@ export const NeoTableChart = (props: ChartProps) => {
333333
throw new Error(`Unsupported method: ${method}`);
334334
}
335335

336-
props.updateReportSetting('apiSpec', { ...props.settings.apiSpec, response });
336+
props.updateReportSetting('apiSpec', { ...props.settings?.apiSpec, response });
337337
} catch (error) {
338338
// Handle errors here
339339
console.error('API call error:', error);
@@ -342,40 +342,52 @@ export const NeoTableChart = (props: ChartProps) => {
342342
}
343343
};
344344

345+
const handleResetApiResponse = () => {
346+
props.updateReportSetting('apiSpec', { ...props.settings?.apiSpec, response: null });
347+
};
348+
345349
const apiCallButton = () => (
346350
<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+
>
352361
{isApiLoading ? 'Loading...' : props.settings?.viewResponseButtonName || 'view response'}
353362
</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+
)}
379391
</Stack>
380392
);
381393

0 commit comments

Comments
 (0)