2021-12-20 13:29:51 +01:00
|
|
|
// @flow
|
2021-12-21 13:42:28 +01:00
|
|
|
import 'scss/component/_header.scss';
|
|
|
|
|
2022-03-09 19:05:37 +01:00
|
|
|
import { ENABLE_UI_NOTIFICATIONS, ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
2021-12-20 13:29:51 +01:00
|
|
|
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';
|
2021-12-20 13:32:32 +01:00
|
|
|
import NotificationHeaderButton from 'component/headerNotificationButton';
|
2021-12-20 13:29:51 +01:00
|
|
|
import React from 'react';
|
2021-12-20 13:38:12 +01:00
|
|
|
import Tooltip from 'component/common/tooltip';
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
type HeaderMenuButtonProps = {
|
|
|
|
activeChannelStakedLevel: number,
|
|
|
|
authenticated: boolean,
|
|
|
|
automaticDarkModeEnabled: boolean,
|
|
|
|
currentTheme: string,
|
|
|
|
user: ?User,
|
|
|
|
handleThemeToggle: (boolean, string) => void,
|
2022-03-09 19:05:37 +01:00
|
|
|
doOpenModal: (string, {}) => void,
|
|
|
|
odyseeMembership: string,
|
2021-12-20 13:29:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
|
2022-03-09 19:05:37 +01:00
|
|
|
const { authenticated, automaticDarkModeEnabled, currentTheme, user, handleThemeToggle, odyseeMembership } = props;
|
|
|
|
|
|
|
|
const isOnMembershipPage = window.location.pathname === `/$/${PAGES.ODYSEE_MEMBERSHIP}`;
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
2022-03-09 19:05:37 +01:00
|
|
|
const livestreamEnabled = Boolean(ENABLE_NO_SOURCE_CLAIMS && user && !user.odysee_live_disabled);
|
2021-12-20 13:29:51 +01:00
|
|
|
|
2022-04-27 14:54:02 +02:00
|
|
|
const uploadProps = { requiresAuth: !authenticated };
|
|
|
|
|
2021-12-20 13:29:51 +01:00
|
|
|
return (
|
|
|
|
<div className="header__buttons">
|
2022-04-27 14:54:02 +02:00
|
|
|
<Menu>
|
|
|
|
<Tooltip title={__('Publish a file, or create a channel')}>
|
|
|
|
<MenuButton className="header__navigationItem--icon">
|
|
|
|
<Icon size={18} icon={ICONS.PUBLISH} aria-hidden />
|
|
|
|
</MenuButton>
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<MenuList className="menu__list--header">
|
|
|
|
<HeaderMenuLink {...uploadProps} page={PAGES.UPLOAD} icon={ICONS.PUBLISH} name={__('Upload')} />
|
|
|
|
<HeaderMenuLink {...uploadProps} page={PAGES.CHANNEL_NEW} icon={ICONS.CHANNEL} name={__('New Channel')} />
|
|
|
|
<HeaderMenuLink
|
|
|
|
{...uploadProps}
|
|
|
|
page={PAGES.YOUTUBE_SYNC}
|
|
|
|
icon={ICONS.YOUTUBE}
|
|
|
|
name={__('Sync YouTube Channel')}
|
|
|
|
/>
|
|
|
|
{livestreamEnabled && (
|
|
|
|
<HeaderMenuLink {...uploadProps} page={PAGES.LIVESTREAM} icon={ICONS.VIDEO} name={__('Go Live')} />
|
|
|
|
)}
|
|
|
|
</MenuList>
|
|
|
|
</Menu>
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
{notificationsEnabled && <NotificationHeaderButton />}
|
|
|
|
|
|
|
|
<Menu>
|
2021-12-20 13:38:12 +01:00
|
|
|
<Tooltip title={__('Settings')}>
|
2021-12-21 13:42:28 +01:00
|
|
|
<MenuButton className="header__navigationItem--icon">
|
2021-12-20 13:38:12 +01:00
|
|
|
<Icon size={18} icon={ICONS.SETTINGS} aria-hidden />
|
|
|
|
</MenuButton>
|
|
|
|
</Tooltip>
|
2021-12-20 13:29:51 +01:00
|
|
|
|
|
|
|
<MenuList className="menu__list--header">
|
|
|
|
<HeaderMenuLink page={PAGES.SETTINGS} icon={ICONS.SETTINGS} name={__('Settings')} />
|
2022-03-09 19:05:37 +01:00
|
|
|
{/* don't show upgrade button if on membership page or already have a membership */}
|
|
|
|
{!isOnMembershipPage && !odyseeMembership && (
|
|
|
|
<HeaderMenuLink page={PAGES.ODYSEE_MEMBERSHIP} icon={ICONS.UPGRADE} name={__('Odysee Premium')} />
|
|
|
|
)}
|
2021-12-20 13:29:51 +01:00
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|