-
Notifications
You must be signed in to change notification settings - Fork 12
/
CustomAttributesPopup.jsx
56 lines (53 loc) · 1.79 KB
/
CustomAttributesPopup.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import {
Chip, Dialog, DialogTitle, DialogContent, DialogActions, Button
} from '@mui/material';
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
import { isEmpty } from 'lodash';
import CustomAttributes from './CustomAttributes'
import CustomAttributesFormatted from './CustomAttributesFormatted'
const CustomAttributesPopup = ({attributes, color}) => {
const [raw, setRaw] = React.useState(false);
const [open, setOpen] = React.useState(false);
const handleClose = () => setOpen(false)
const onOpen = () => setOpen(true)
return (
<React.Fragment>
{
isEmpty(attributes) ?
<span>None</span> :
<span>
<Chip
label="Show"
onClick={onOpen}
color="primary"
variant="outlined"
size="small"
deleteIcon={<ArrowRightIcon fontSize="inherit" style={color ? {color: color} : {}} /> }
onDelete={onOpen}
style={color ? {border: 'none', color: color} : {border: 'none'}}
/>
<Dialog onClose={handleClose} open={open} fullWidth maxWidth="md">
<DialogTitle>Custom Attributes</DialogTitle>
<DialogContent>
{
raw ?
<CustomAttributes attributes={attributes} /> :
<CustomAttributesFormatted attributes={attributes} />
}
</DialogContent>
<DialogActions>
<Button color="primary" onClick={() => setRaw(!raw) }>
{ raw ? 'Formatted' : 'Raw' }
</Button>
<Button onClick={handleClose}>
Close
</Button>
</DialogActions>
</Dialog>
</span>
}
</React.Fragment>
)
}
export default CustomAttributesPopup;