umami/components/settings/DashboardSettingsButton.js

28 lines
822 B
JavaScript
Raw Normal View History

import React from 'react';
import { FormattedMessage } from 'react-intl';
import MenuButton from 'components/common/MenuButton';
import Gear from 'assets/gear.svg';
2022-03-04 04:45:49 +01:00
import useStore, { setDashboard, defaultDashboardConfig } from 'store/app';
const selector = state => state.dashboard;
export default function DashboardSettingsButton() {
const settings = useStore(selector);
const menuOptions = [
{
label: <FormattedMessage id="message.toggle-charts" defaultMessage="Toggle charts" />,
value: 'charts',
},
];
function handleSelect(value) {
if (value === 'charts') {
2022-03-04 04:45:49 +01:00
setDashboard({ ...defaultDashboardConfig, showCharts: !settings.showCharts });
}
//setDashboard(value);
}
return <MenuButton icon={<Gear />} options={menuOptions} onSelect={handleSelect} hideLabel />;
}