2021-02-16 04:14:09 +00:00
|
|
|
import React, { useState } from 'react';
|
2020-09-06 00:27:01 +00:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2020-08-05 05:45:05 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import classNames from 'classnames';
|
2020-08-08 03:36:57 +00:00
|
|
|
import Link from 'components/common/Link';
|
2020-09-20 08:33:39 +00:00
|
|
|
import Icon from 'components/common/Icon';
|
|
|
|
|
import LanguageButton from 'components/settings/LanguageButton';
|
|
|
|
|
import ThemeButton from 'components/settings/ThemeButton';
|
2020-09-26 11:04:44 +00:00
|
|
|
import UpdateNotice from 'components/common/UpdateNotice';
|
2020-09-21 04:31:53 +00:00
|
|
|
import UserButton from 'components/settings/UserButton';
|
2020-08-07 05:03:02 +00:00
|
|
|
import Logo from 'assets/logo.svg';
|
2020-08-05 05:45:05 +00:00
|
|
|
import styles from './Header.module.css';
|
2020-07-24 02:56:55 +00:00
|
|
|
|
|
|
|
|
export default function Header() {
|
2020-08-05 05:45:05 +00:00
|
|
|
const user = useSelector(state => state.user);
|
2021-02-16 04:14:09 +00:00
|
|
|
const [active, setActive] = useState(false);
|
|
|
|
|
|
|
|
|
|
function handleClick() {
|
|
|
|
|
setActive(state => !state);
|
|
|
|
|
}
|
2020-08-05 05:45:05 +00:00
|
|
|
|
2020-07-24 02:56:55 +00:00
|
|
|
return (
|
2021-02-16 04:14:09 +00:00
|
|
|
<nav className="container">
|
2020-09-29 23:25:44 +00:00
|
|
|
{user?.is_admin && <UpdateNotice />}
|
2020-08-15 08:17:15 +00:00
|
|
|
<div className={classNames(styles.header, 'row align-items-center')}>
|
2021-02-16 04:14:09 +00:00
|
|
|
<div className={styles.nav}>
|
|
|
|
|
<div className="">
|
|
|
|
|
<div className={styles.title}>
|
|
|
|
|
<Icon icon={<Logo />} size="large" className={styles.logo} />
|
|
|
|
|
<Link href={user ? '/' : 'https://umami.is'}>umami</Link>
|
|
|
|
|
</div>
|
2020-08-07 05:03:02 +00:00
|
|
|
</div>
|
2021-02-16 04:14:09 +00:00
|
|
|
<button
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
role="button"
|
|
|
|
|
className={styles.burger}
|
|
|
|
|
aria-label="menu"
|
|
|
|
|
aria-expanded="false"
|
|
|
|
|
>
|
|
|
|
|
{active ? (
|
2021-03-01 04:37:59 +00:00
|
|
|
<div> X </div>
|
2021-02-16 04:14:09 +00:00
|
|
|
) : (
|
2021-03-01 04:37:59 +00:00
|
|
|
<>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
<span></span>
|
|
|
|
|
</>
|
2021-02-16 04:14:09 +00:00
|
|
|
)}
|
|
|
|
|
</button>
|
2020-09-20 09:54:38 +00:00
|
|
|
{user && (
|
2021-02-16 04:14:09 +00:00
|
|
|
<div className={styles.items}>
|
|
|
|
|
<div className={active ? classNames(styles.active) : ''}>
|
|
|
|
|
<Link href="/dashboard">
|
|
|
|
|
<FormattedMessage id="label.dashboard" defaultMessage="Dashboard" />
|
|
|
|
|
</Link>
|
|
|
|
|
<Link href="/realtime">
|
|
|
|
|
<FormattedMessage id="label.realtime" defaultMessage="Realtime" />
|
|
|
|
|
</Link>
|
|
|
|
|
<Link href="/settings">
|
|
|
|
|
<FormattedMessage id="label.settings" defaultMessage="Settings" />
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
2020-09-20 09:54:38 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
2021-02-16 04:14:09 +00:00
|
|
|
<div className={styles.items}>
|
|
|
|
|
<div className={active ? classNames(styles.active) : ''}>
|
|
|
|
|
<div className={styles.buttons}>
|
|
|
|
|
<ThemeButton />
|
|
|
|
|
<LanguageButton menuAlign="right" />
|
|
|
|
|
{user && <UserButton />}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-09-09 23:43:37 +00:00
|
|
|
</div>
|
2020-09-07 22:25:09 +00:00
|
|
|
</div>
|
2020-08-05 05:45:05 +00:00
|
|
|
</div>
|
2021-02-16 04:14:09 +00:00
|
|
|
</nav>
|
2020-07-24 02:56:55 +00:00
|
|
|
);
|
|
|
|
|
}
|