2023-01-19 00:05:39 +01:00
|
|
|
import { useState } from 'react';
|
2023-01-28 06:53:13 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
2023-01-31 06:44:07 +01:00
|
|
|
import { Icon, Text } from 'react-basics';
|
2023-01-19 00:05:39 +01:00
|
|
|
import classNames from 'classnames';
|
2023-01-31 06:44:07 +01:00
|
|
|
import Icons from 'components/icons';
|
2023-02-04 17:59:52 +01:00
|
|
|
import ThemeButton from 'components/input/ThemeButton';
|
|
|
|
import LanguageButton from 'components/input/LanguageButton';
|
|
|
|
import LogoutButton from 'components/input/LogoutButton';
|
2023-01-28 06:53:13 +01:00
|
|
|
import { labels } from 'components/messages';
|
2023-01-31 06:44:07 +01:00
|
|
|
import useUser from 'hooks/useUser';
|
2023-01-19 00:05:39 +01:00
|
|
|
import NavGroup from './NavGroup';
|
|
|
|
import styles from './NavBar.module.css';
|
|
|
|
|
|
|
|
export default function NavBar() {
|
2023-01-31 06:44:07 +01:00
|
|
|
const { user } = useUser();
|
2023-01-28 06:53:13 +01:00
|
|
|
const { formatMessage } = useIntl();
|
2023-01-19 00:05:39 +01:00
|
|
|
const [minimized, setMinimized] = useState(false);
|
2023-01-28 06:53:13 +01:00
|
|
|
const tooltipPosition = minimized ? 'right' : 'top';
|
|
|
|
|
|
|
|
const analytics = [
|
2023-01-31 06:44:07 +01:00
|
|
|
{ label: formatMessage(labels.dashboard), url: '/dashboard', icon: <Icons.Dashboard /> },
|
|
|
|
{ label: formatMessage(labels.realtime), url: '/realtime', icon: <Icons.Clock /> },
|
2023-01-28 06:53:13 +01:00
|
|
|
{ label: formatMessage(labels.queries), url: '/queries', icon: <Icons.Search /> },
|
|
|
|
];
|
|
|
|
|
|
|
|
const settings = [
|
2023-01-31 06:44:07 +01:00
|
|
|
{ label: formatMessage(labels.websites), url: '/settings/websites', icon: <Icons.Globe /> },
|
|
|
|
user?.isAdmin && {
|
|
|
|
label: formatMessage(labels.users),
|
|
|
|
url: '/settings/users',
|
|
|
|
icon: <Icons.User />,
|
|
|
|
},
|
|
|
|
{ label: formatMessage(labels.teams), url: '/settings/teams', icon: <Icons.Users /> },
|
|
|
|
{ label: formatMessage(labels.profile), url: '/settings/profile', icon: <Icons.Profile /> },
|
|
|
|
].filter(n => n);
|
2023-01-19 00:05:39 +01:00
|
|
|
|
|
|
|
const handleMinimize = () => setMinimized(state => !state);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classNames(styles.navbar, { [styles.minimized]: minimized })}>
|
|
|
|
<div className={styles.header} onClick={handleMinimize}>
|
|
|
|
<Icon size="lg">
|
2023-01-31 06:44:07 +01:00
|
|
|
<Icons.Logo />
|
2023-01-19 00:05:39 +01:00
|
|
|
</Icon>
|
|
|
|
<Text className={styles.text}>umami</Text>
|
|
|
|
<Icon size="sm" rotate={minimized ? -90 : 90} className={styles.icon}>
|
2023-01-28 06:53:13 +01:00
|
|
|
<Icons.ChevronDown />
|
2023-01-19 00:05:39 +01:00
|
|
|
</Icon>
|
|
|
|
</div>
|
2023-01-28 06:53:13 +01:00
|
|
|
<NavGroup title={formatMessage(labels.analytics)} items={analytics} minimized={minimized} />
|
|
|
|
<NavGroup title={formatMessage(labels.settings)} items={settings} minimized={minimized} />
|
2023-01-19 00:05:39 +01:00
|
|
|
<div className={styles.footer}>
|
2023-01-21 02:12:53 +01:00
|
|
|
<div className={styles.buttons}>
|
2023-01-28 06:53:13 +01:00
|
|
|
<ThemeButton tooltipPosition={tooltipPosition} />
|
|
|
|
<LanguageButton tooltipPosition={tooltipPosition} />
|
|
|
|
<LogoutButton tooltipPosition={tooltipPosition} />
|
2023-01-21 02:12:53 +01:00
|
|
|
</div>
|
2023-01-19 00:05:39 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|