2022-01-26 20:54:58 +01:00
|
|
|
// @flow
|
2022-01-27 03:14:36 +01:00
|
|
|
// import 'scss/component/_header.scss'; // ody codesplits this; no.
|
|
|
|
|
2022-01-26 20:54:58 +01:00
|
|
|
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
|
|
|
import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import HeaderMenuLink from 'component/common/header-menu-link';
|
|
|
|
import Icon from 'component/common/icon';
|
2022-01-27 03:14:36 +01:00
|
|
|
import NotificationHeaderButton from 'component/headerNotificationButton';
|
2022-01-26 20:54:58 +01:00
|
|
|
import React from 'react';
|
2022-01-27 03:14:36 +01:00
|
|
|
import Tooltip from 'component/common/tooltip';
|
2022-01-26 20:54:58 +01:00
|
|
|
|
|
|
|
type HeaderMenuButtonProps = {
|
|
|
|
authenticated: boolean,
|
|
|
|
automaticDarkModeEnabled: boolean,
|
|
|
|
currentTheme: string,
|
|
|
|
user: ?User,
|
|
|
|
handleThemeToggle: (boolean, string) => void,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
|
|
|
|
const { automaticDarkModeEnabled, currentTheme, user, handleThemeToggle } = props;
|
|
|
|
|
|
|
|
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="header__buttons">
|
|
|
|
<Menu>
|
2022-01-27 03:14:36 +01:00
|
|
|
<Tooltip title={__('Publish a file, or create a channel')}>
|
|
|
|
<MenuButton className="header__navigationItem--icon">
|
|
|
|
<Icon size={18} icon={ICONS.PUBLISH} aria-hidden />
|
|
|
|
</MenuButton>
|
|
|
|
</Tooltip>
|
2022-01-26 20:54:58 +01:00
|
|
|
|
|
|
|
<MenuList className="menu__list--header">
|
|
|
|
<HeaderMenuLink page={PAGES.UPLOAD} icon={ICONS.PUBLISH} name={__('Upload')} />
|
|
|
|
<HeaderMenuLink page={PAGES.CHANNEL_NEW} icon={ICONS.CHANNEL} name={__('New Channel')} />
|
|
|
|
</MenuList>
|
|
|
|
</Menu>
|
|
|
|
|
|
|
|
{notificationsEnabled && <NotificationHeaderButton />}
|
|
|
|
|
|
|
|
<Menu>
|
2022-01-27 03:14:36 +01:00
|
|
|
<Tooltip title={__('Settings')}>
|
|
|
|
<MenuButton className="header__navigationItem--icon">
|
|
|
|
<Icon size={18} icon={ICONS.SETTINGS} aria-hidden />
|
|
|
|
</MenuButton>
|
|
|
|
</Tooltip>
|
2022-01-26 20:54:58 +01:00
|
|
|
|
|
|
|
<MenuList className="menu__list--header">
|
|
|
|
<HeaderMenuLink page={PAGES.SETTINGS} icon={ICONS.SETTINGS} name={__('Settings')} />
|
|
|
|
<HeaderMenuLink page={PAGES.HELP} icon={ICONS.HELP} name={__('Help')} />
|
|
|
|
|
|
|
|
<MenuItem className="menu__link" onSelect={() => handleThemeToggle(automaticDarkModeEnabled, currentTheme)}>
|
|
|
|
<Icon icon={currentTheme === 'light' ? ICONS.DARK : ICONS.LIGHT} />
|
|
|
|
{currentTheme === 'light' ? __('Dark') : __('Light')}
|
|
|
|
</MenuItem>
|
|
|
|
</MenuList>
|
|
|
|
</Menu>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|