Fix UnauthorizedModal and Navbar
This commit is contained in:
parent
e3faadac3d
commit
f218496b82
2 changed files with 9 additions and 8 deletions
|
@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import { remoteInteraction } from 'soapbox/actions/interactions';
|
import { remoteInteraction } from 'soapbox/actions/interactions';
|
||||||
import { Button, Modal, Stack, Text } from 'soapbox/components/ui';
|
import { Button, Modal, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useAppSelector, useAppDispatch, useFeatures, useInstance } from 'soapbox/hooks';
|
import { useAppSelector, useAppDispatch, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks';
|
||||||
import toast from 'soapbox/toast';
|
import toast from 'soapbox/toast';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -30,6 +30,7 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const instance = useInstance();
|
const instance = useInstance();
|
||||||
|
const { isOpen } = useRegistrationStatus();
|
||||||
|
|
||||||
const username = useAppSelector(state => state.accounts.get(accountId)?.display_name);
|
const username = useAppSelector(state => state.accounts.get(accountId)?.display_name);
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
|
@ -97,10 +98,10 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
||||||
<Modal
|
<Modal
|
||||||
title={header}
|
title={header}
|
||||||
onClose={onClickClose}
|
onClose={onClickClose}
|
||||||
confirmationAction={instance.registrations ? onLogin : undefined}
|
confirmationAction={onLogin}
|
||||||
confirmationText={<FormattedMessage id='account.login' defaultMessage='Log in' />}
|
confirmationText={<FormattedMessage id='account.login' defaultMessage='Log in' />}
|
||||||
secondaryAction={onRegister}
|
secondaryAction={isOpen ? onRegister : undefined}
|
||||||
secondaryText={<FormattedMessage id='account.register' defaultMessage='Sign up' />}
|
secondaryText={isOpen ? <FormattedMessage id='account.register' defaultMessage='Sign up' /> : undefined}
|
||||||
>
|
>
|
||||||
<div className='remote-interaction-modal__content'>
|
<div className='remote-interaction-modal__content'>
|
||||||
<form className='simple_form remote-interaction-modal__fields' onSubmit={onSubmit}>
|
<form className='simple_form remote-interaction-modal__fields' onSubmit={onSubmit}>
|
||||||
|
@ -121,7 +122,7 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
||||||
<FormattedMessage id='remote_interaction.divider' defaultMessage='or' />
|
<FormattedMessage id='remote_interaction.divider' defaultMessage='or' />
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
{instance.registrations && (
|
{isOpen && (
|
||||||
<Text size='lg' weight='medium'>
|
<Text size='lg' weight='medium'>
|
||||||
<FormattedMessage id='unauthorized_modal.title' defaultMessage='Sign up for {site_title}' values={{ site_title: instance.title }} />
|
<FormattedMessage id='unauthorized_modal.title' defaultMessage='Sign up for {site_title}' values={{ site_title: instance.title }} />
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -141,8 +142,8 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
||||||
onClose={onClickClose}
|
onClose={onClickClose}
|
||||||
confirmationAction={onLogin}
|
confirmationAction={onLogin}
|
||||||
confirmationText={<FormattedMessage id='account.login' defaultMessage='Log in' />}
|
confirmationText={<FormattedMessage id='account.login' defaultMessage='Log in' />}
|
||||||
secondaryAction={onRegister}
|
secondaryAction={isOpen ? onRegister : undefined}
|
||||||
secondaryText={<FormattedMessage id='account.register' defaultMessage='Sign up' />}
|
secondaryText={isOpen ? <FormattedMessage id='account.register' defaultMessage='Sign up' /> : undefined}
|
||||||
>
|
>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Text>
|
<Text>
|
||||||
|
|
|
@ -148,7 +148,7 @@ const Navbar = () => {
|
||||||
<FormattedMessage id='account.login' defaultMessage='Log In' />
|
<FormattedMessage id='account.login' defaultMessage='Log In' />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{!isOpen && (
|
{isOpen && (
|
||||||
<Button theme='primary' to='/signup' size='sm'>
|
<Button theme='primary' to='/signup' size='sm'>
|
||||||
<FormattedMessage id='account.register' defaultMessage='Sign up' />
|
<FormattedMessage id='account.register' defaultMessage='Sign up' />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Reference in a new issue