mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import { Menu, Icon, Text, PopupTrigger, Popup, Item, Button } from 'react-basics';
|
|
import Icons from 'components/icons';
|
|
import { saveDashboard } from 'store/dashboard';
|
|
import useMessages from 'hooks/useMessages';
|
|
|
|
export default function DashboardSettingsButton() {
|
|
const { formatMessage, labels } = useMessages();
|
|
|
|
const menuOptions = [
|
|
{
|
|
label: formatMessage(labels.toggleCharts),
|
|
value: 'charts',
|
|
},
|
|
{
|
|
label: formatMessage(labels.editDashboard),
|
|
value: 'order',
|
|
},
|
|
];
|
|
|
|
function handleSelect(value) {
|
|
if (value === 'charts') {
|
|
saveDashboard(state => ({ showCharts: !state.showCharts }));
|
|
}
|
|
if (value === 'order') {
|
|
saveDashboard({ editing: true });
|
|
}
|
|
}
|
|
|
|
return (
|
|
<PopupTrigger>
|
|
<Button>
|
|
<Icon>
|
|
<Icons.Edit />
|
|
</Icon>
|
|
<Text>{formatMessage(labels.edit)}</Text>
|
|
</Button>
|
|
<Popup alignment="end">
|
|
<Menu variant="popup" items={menuOptions} onSelect={handleSelect}>
|
|
{({ label, value }) => <Item key={value}>{label}</Item>}
|
|
</Menu>
|
|
</Popup>
|
|
</PopupTrigger>
|
|
);
|
|
}
|