mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Fix/splash (#534)
* fix: use correct env id * fix: extract to constant * fix: fetch user when logging in
This commit is contained in:
parent
e767d5370a
commit
7a5eea2aab
@ -36,12 +36,12 @@ const App = ({ location, user, fetchUiBootstrap }: IAppProps) => {
|
|||||||
}, [user.authDetails?.type]);
|
}, [user.authDetails?.type]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (splash?.environments === undefined) return;
|
if (splash?.environment === undefined) return;
|
||||||
if (!splash?.environments && !isUnauthorized()) {
|
if (!splash?.environment && !isUnauthorized()) {
|
||||||
setShowSplash(true);
|
setShowSplash(true);
|
||||||
}
|
}
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
}, [splash.environments]);
|
}, [splash.environment]);
|
||||||
|
|
||||||
const renderMainLayoutRoutes = () => {
|
const renderMainLayoutRoutes = () => {
|
||||||
return routes.filter(route => route.layout === 'main').map(renderRoute);
|
return routes.filter(route => route.layout === 'main').map(renderRoute);
|
||||||
|
@ -46,7 +46,7 @@ const BreadcrumbNav = () => {
|
|||||||
styles.breadcrumbNavParagraph
|
styles.breadcrumbNavParagraph
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{path.substring(0,30)}
|
{path.substring(0, 30)}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ const BreadcrumbNav = () => {
|
|||||||
className={styles.breadcrumbLink}
|
className={styles.breadcrumbLink}
|
||||||
to={link}
|
to={link}
|
||||||
>
|
>
|
||||||
{path.substring(0,30)}
|
{path.substring(0, 30)}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -11,12 +11,14 @@ interface IEnvironmentSplashProps {
|
|||||||
onFinish: (status: boolean) => void;
|
onFinish: (status: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ENVIRONMENT_SPLASH_ID = 'environment';
|
||||||
|
|
||||||
const EnvironmentSplash = ({ onFinish }: IEnvironmentSplashProps) => {
|
const EnvironmentSplash = ({ onFinish }: IEnvironmentSplashProps) => {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const { setSplashSeen } = useSplashApi();
|
const { setSplashSeen } = useSplashApi();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSplashSeen('environments');
|
setSplashSeen(ENVIRONMENT_SPLASH_ID);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Button, TextField } from '@material-ui/core';
|
import { Button, TextField } from '@material-ui/core';
|
||||||
|
import useUser from '../../../hooks/api/getters/useUser/useUser';
|
||||||
|
|
||||||
import styles from './DemoAuth.module.scss';
|
import styles from './DemoAuth.module.scss';
|
||||||
|
|
||||||
@ -10,12 +11,17 @@ import { LOGIN_BUTTON, LOGIN_EMAIL_ID } from '../../../testIds';
|
|||||||
const DemoAuth = ({ demoLogin, history, authDetails }) => {
|
const DemoAuth = ({ demoLogin, history, authDetails }) => {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
|
|
||||||
|
const { refetch } = useUser();
|
||||||
|
|
||||||
const handleSubmit = evt => {
|
const handleSubmit = evt => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const user = { email };
|
const user = { email };
|
||||||
const path = evt.target.action;
|
const path = evt.target.action;
|
||||||
|
|
||||||
demoLogin(path, user).then(() => history.push(`/`));
|
demoLogin(path, user).then(() => {
|
||||||
|
refetch();
|
||||||
|
history.push(`/`);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = e => {
|
const handleChange = e => {
|
||||||
|
@ -9,10 +9,12 @@ import useQueryParams from '../../../hooks/useQueryParams';
|
|||||||
import AuthOptions from '../common/AuthOptions/AuthOptions';
|
import AuthOptions from '../common/AuthOptions/AuthOptions';
|
||||||
import DividerText from '../../common/DividerText/DividerText';
|
import DividerText from '../../common/DividerText/DividerText';
|
||||||
import ConditionallyRender from '../../common/ConditionallyRender';
|
import ConditionallyRender from '../../common/ConditionallyRender';
|
||||||
|
import useUser from '../../../hooks/api/getters/useUser/useUser';
|
||||||
|
|
||||||
const HostedAuth = ({ authDetails, passwordLogin }) => {
|
const HostedAuth = ({ authDetails, passwordLogin }) => {
|
||||||
const commonStyles = useCommonStyles();
|
const commonStyles = useCommonStyles();
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
const { refetch } = useUser();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const params = useQueryParams();
|
const params = useQueryParams();
|
||||||
const [username, setUsername] = useState(params.get('email') || '');
|
const [username, setUsername] = useState(params.get('email') || '');
|
||||||
@ -47,6 +49,7 @@ const HostedAuth = ({ authDetails, passwordLogin }) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await passwordLogin(path, user);
|
await passwordLogin(path, user);
|
||||||
|
refetch();
|
||||||
history.push(`/`);
|
history.push(`/`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 404 || error.statusCode === 400) {
|
if (error.statusCode === 404 || error.statusCode === 400) {
|
||||||
|
@ -15,11 +15,13 @@ import {
|
|||||||
LOGIN_PASSWORD_ID,
|
LOGIN_PASSWORD_ID,
|
||||||
LOGIN_EMAIL_ID,
|
LOGIN_EMAIL_ID,
|
||||||
} from '../../../testIds';
|
} from '../../../testIds';
|
||||||
|
import useUser from '../../../hooks/api/getters/useUser/useUser';
|
||||||
|
|
||||||
const PasswordAuth = ({ authDetails, passwordLogin }) => {
|
const PasswordAuth = ({ authDetails, passwordLogin }) => {
|
||||||
const commonStyles = useCommonStyles();
|
const commonStyles = useCommonStyles();
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const { refetch } = useUser();
|
||||||
const params = useQueryParams();
|
const params = useQueryParams();
|
||||||
const [username, setUsername] = useState(params.get('email') || '');
|
const [username, setUsername] = useState(params.get('email') || '');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
@ -53,7 +55,7 @@ const PasswordAuth = ({ authDetails, passwordLogin }) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await passwordLogin(path, user);
|
await passwordLogin(path, user);
|
||||||
|
refetch();
|
||||||
history.push(`/`);
|
history.push(`/`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.statusCode === 404 || error.statusCode === 400) {
|
if (error.statusCode === 404 || error.statusCode === 400) {
|
||||||
|
@ -3,16 +3,21 @@ import PropTypes from 'prop-types';
|
|||||||
import { Button, TextField } from '@material-ui/core';
|
import { Button, TextField } from '@material-ui/core';
|
||||||
|
|
||||||
import styles from './SimpleAuth.module.scss';
|
import styles from './SimpleAuth.module.scss';
|
||||||
|
import useUser from '../../../hooks/api/getters/useUser/useUser';
|
||||||
|
|
||||||
const SimpleAuth = ({ insecureLogin, history, authDetails }) => {
|
const SimpleAuth = ({ insecureLogin, history, authDetails }) => {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
|
const { refetch } = useUser();
|
||||||
|
|
||||||
const handleSubmit = evt => {
|
const handleSubmit = evt => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const user = { email };
|
const user = { email };
|
||||||
const path = evt.target.action;
|
const path = evt.target.action;
|
||||||
|
|
||||||
insecureLogin(path, user).then(() => history.push(`/`));
|
insecureLogin(path, user).then(() => {
|
||||||
|
refetch();
|
||||||
|
history.push(`/`);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = e => {
|
const handleChange = e => {
|
||||||
|
@ -14,7 +14,6 @@ const StandaloneBanner: FC<IStandaloneBannerProps> = ({ title, children }) => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
const smallScreen = useMediaQuery(theme.breakpoints.down('sm'));
|
const smallScreen = useMediaQuery(theme.breakpoints.down('sm'));
|
||||||
console.log(smallScreen);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Gradient
|
<Gradient
|
||||||
|
Loading…
Reference in New Issue
Block a user