Merge pull request #990 from automatisch/disable-conditional-features
feat: disable non-cloud features
This commit is contained in:
@@ -7,6 +7,7 @@ import Typography from '@mui/material/Typography';
|
|||||||
import LoadingButton from '@mui/lab/LoadingButton';
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
|
|
||||||
import useAuthentication from 'hooks/useAuthentication';
|
import useAuthentication from 'hooks/useAuthentication';
|
||||||
|
import useCloud from 'hooks/useCloud';
|
||||||
import * as URLS from 'config/urls';
|
import * as URLS from 'config/urls';
|
||||||
import { LOGIN } from 'graphql/mutations/login';
|
import { LOGIN } from 'graphql/mutations/login';
|
||||||
import Form from 'components/Form';
|
import Form from 'components/Form';
|
||||||
@@ -14,6 +15,7 @@ import TextField from 'components/TextField';
|
|||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
|
|
||||||
function LoginForm() {
|
function LoginForm() {
|
||||||
|
const isCloud = useCloud();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const authentication = useAuthentication();
|
const authentication = useAuthentication();
|
||||||
@@ -76,13 +78,13 @@ function LoginForm() {
|
|||||||
sx={{ mb: 1 }}
|
sx={{ mb: 1 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Link
|
{isCloud &&<Link
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
to={URLS.FORGOT_PASSWORD}
|
to={URLS.FORGOT_PASSWORD}
|
||||||
underline="none"
|
underline="none"
|
||||||
>
|
>
|
||||||
{formatMessage('loginForm.forgotPasswordText')}
|
{formatMessage('loginForm.forgotPasswordText')}
|
||||||
</Link>
|
</Link>}
|
||||||
|
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -96,13 +98,13 @@ function LoginForm() {
|
|||||||
{formatMessage('loginForm.submit')}
|
{formatMessage('loginForm.submit')}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
|
|
||||||
<Typography variant="body1" align="center" mt={3}>
|
{isCloud && <Typography variant="body1" align="center" mt={3}>
|
||||||
{formatMessage('loginForm.noAccount')}
|
{formatMessage('loginForm.noAccount')}
|
||||||
|
|
||||||
<Link component={RouterLink} to={URLS.SIGNUP} underline="none">
|
<Link component={RouterLink} to={URLS.SIGNUP} underline="none">
|
||||||
{formatMessage('loginForm.signUp')}
|
{formatMessage('loginForm.signUp')}
|
||||||
</Link>
|
</Link>
|
||||||
</Typography>
|
</Typography>}
|
||||||
</Form>
|
</Form>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
|
@@ -1,7 +1,20 @@
|
|||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import useAutomatischInfo from './useAutomatischInfo';
|
import useAutomatischInfo from './useAutomatischInfo';
|
||||||
|
|
||||||
export default function useCloud(): boolean {
|
type UseCloudOptions = {
|
||||||
|
redirect?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useCloud(options?: UseCloudOptions): boolean {
|
||||||
|
const redirect = options?.redirect || false;
|
||||||
|
|
||||||
const { isCloud } = useAutomatischInfo();
|
const { isCloud } = useAutomatischInfo();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
if (isCloud === false && redirect) {
|
||||||
|
navigate('/');
|
||||||
|
}
|
||||||
|
|
||||||
return isCloud;
|
return isCloud;
|
||||||
}
|
}
|
||||||
|
@@ -12,21 +12,23 @@ import routes from 'routes';
|
|||||||
import reportWebVitals from './reportWebVitals';
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<SnackbarProvider>
|
<Router>
|
||||||
<AuthenticationProvider>
|
<SnackbarProvider>
|
||||||
<ApolloProvider>
|
<AuthenticationProvider>
|
||||||
<AutomatischInfoProvider>
|
<ApolloProvider>
|
||||||
<IntlProvider>
|
<AutomatischInfoProvider>
|
||||||
<ThemeProvider>
|
<IntlProvider>
|
||||||
<Router>{routes}</Router>
|
<ThemeProvider>
|
||||||
|
{routes}
|
||||||
|
|
||||||
<LiveChat />
|
<LiveChat />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
</AutomatischInfoProvider>
|
</AutomatischInfoProvider>
|
||||||
</ApolloProvider>
|
</ApolloProvider>
|
||||||
</AuthenticationProvider>
|
</AuthenticationProvider>
|
||||||
</SnackbarProvider>,
|
</SnackbarProvider>
|
||||||
|
</Router>,
|
||||||
document.getElementById('root')
|
document.getElementById('root')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,9 +1,13 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
|
import useCloud from 'hooks/useCloud';
|
||||||
import Container from 'components/Container';
|
import Container from 'components/Container';
|
||||||
import ForgotPasswordForm from 'components/ForgotPasswordForm/index.ee';
|
import ForgotPasswordForm from 'components/ForgotPasswordForm/index.ee';
|
||||||
|
|
||||||
export default function ForgotPassword(): React.ReactElement {
|
export default function ForgotPassword(): React.ReactElement {
|
||||||
|
useCloud({ redirect: true });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
||||||
<Container maxWidth="sm">
|
<Container maxWidth="sm">
|
||||||
|
@@ -1,9 +1,13 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
|
import useCloud from 'hooks/useCloud';
|
||||||
import Container from 'components/Container';
|
import Container from 'components/Container';
|
||||||
import ResetPasswordForm from 'components/ResetPasswordForm/index.ee';
|
import ResetPasswordForm from 'components/ResetPasswordForm/index.ee';
|
||||||
|
|
||||||
export default function ResetPassword(): React.ReactElement {
|
export default function ResetPassword(): React.ReactElement {
|
||||||
|
useCloud({ redirect: true });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
||||||
<Container maxWidth="sm">
|
<Container maxWidth="sm">
|
||||||
|
@@ -1,9 +1,13 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
|
import useCloud from 'hooks/useCloud';
|
||||||
import Container from 'components/Container';
|
import Container from 'components/Container';
|
||||||
import SignUpForm from 'components/SignUpForm/index.ee';
|
import SignUpForm from 'components/SignUpForm/index.ee';
|
||||||
|
|
||||||
export default function Login(): React.ReactElement {
|
export default function SignUp(): React.ReactElement {
|
||||||
|
useCloud({ redirect: true });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
<Box sx={{ display: 'flex', flex: 1, alignItems: 'center' }}>
|
||||||
<Container maxWidth="sm">
|
<Container maxWidth="sm">
|
||||||
|
Reference in New Issue
Block a user