Show upload menu for no-auth but redirect to sign up

This commit is contained in:
Rafael 2022-04-27 09:54:02 -03:00 committed by Thomas Zarebczan
parent b693925fe5
commit 0e8b7d6b4a
2 changed files with 38 additions and 18 deletions

View file

@ -1,17 +1,30 @@
// @flow
import * as PAGES from 'constants/pages';
import React from 'react';
import { Link } from 'react-router-dom';
import { MenuLink } from '@reach/menu-button';
import { Link, useHistory } from 'react-router-dom';
import { MenuLink, MenuItem } from '@reach/menu-button';
import Icon from 'component/common/icon';
type Props = {
icon: string,
name: string,
page: string,
requiresAuth?: boolean,
};
export default function HeaderMenuLink(props: Props) {
const { icon, name, page } = props;
const { icon, name, page, requiresAuth } = props;
const { push } = useHistory();
if (requiresAuth) {
return (
<MenuItem className="menu__link" onSelect={() => push(`/$/${PAGES.AUTH}`)}>
<Icon aria-hidden icon={icon} />
{name}
</MenuItem>
);
}
return (
<MenuLink className="menu__link" as={Link} to={`/$/${page}`}>

View file

@ -30,24 +30,31 @@ export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
const livestreamEnabled = Boolean(ENABLE_NO_SOURCE_CLAIMS && user && !user.odysee_live_disabled);
const uploadProps = { requiresAuth: !authenticated };
return (
<div className="header__buttons">
{authenticated && (
<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>
<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 page={PAGES.UPLOAD} icon={ICONS.PUBLISH} name={__('Upload')} />
<HeaderMenuLink page={PAGES.CHANNEL_NEW} icon={ICONS.CHANNEL} name={__('New Channel')} />
<HeaderMenuLink page={PAGES.YOUTUBE_SYNC} icon={ICONS.YOUTUBE} name={__('Sync YouTube Channel')} />
{livestreamEnabled && <HeaderMenuLink page={PAGES.LIVESTREAM} icon={ICONS.VIDEO} name={__('Go Live')} />}
</MenuList>
</Menu>
)}
<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>
{notificationsEnabled && <NotificationHeaderButton />}