-
Notifications
You must be signed in to change notification settings - Fork 12
/
ServerConfigsChip.jsx
45 lines (42 loc) · 1.37 KB
/
ServerConfigsChip.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
import React from 'react';
import {
Chip, Tooltip, Menu
} from '@mui/material';
import {
ExpandLess as ExpandLessIcon,
ExpandMore as ExpandMoreIcon,
} from '@mui/icons-material';
import { getAppliedServerConfig } from '../../common/utils';
import ServerConfigList from './ServerConfigList';
const ServerConfigsChip = props => {
const anchorRef = React.useRef(null);
const [open, setOpen] = React.useState(false);
const applied = getAppliedServerConfig();
const icon = <img style={{marginLeft: '5px', width: '20px'}} src={applied.type === 'ocl' ? '/favicon.ico' : '/fhir.svg'} />
return (
<React.Fragment>
<Tooltip arrow title='Switch Server' placement='bottom'>
<Chip
icon={icon}
color='secondary'
variant='outlined'
label={`Server : ${applied.name}`}
deleteIcon={
open ? <ExpandLessIcon fontSize='inherit' /> : <ExpandMoreIcon fontSize='inherit' />
}
onDelete={() => setOpen(!open)}
onClick={() => setOpen(!open)}
ref={anchorRef}
{...props}
/>
</Tooltip>
{
open &&
<Menu open={open} anchorEl={anchorRef.current} onClose={() => setOpen(false)} style={{marginTop: '35px'}}>
<ServerConfigList onClose={() => setOpen(false)} />
</Menu>
}
</React.Fragment>
)
}
export default ServerConfigsChip;