From d3f24ae59f687c76fe6876c9a2f5fc0160fe4700 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 23 Apr 2020 17:35:59 -0400 Subject: [PATCH 1/3] Cancel button brings you back to log in page --- .../ForgotPassword/ForgotPassword.jsx | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/app/shared-components/ForgotPassword/ForgotPassword.jsx b/app/shared-components/ForgotPassword/ForgotPassword.jsx index 1c4fe6621..059b75de8 100644 --- a/app/shared-components/ForgotPassword/ForgotPassword.jsx +++ b/app/shared-components/ForgotPassword/ForgotPassword.jsx @@ -47,6 +47,8 @@ class ForgotPassword extends React.Component { this.setState({ loading: true }, () => { const { email } = this.state; const { locale } = this.props; + const isInPanel = locale === 'panel'; + const isInHub = locale === 'hub'; // validate the email and password if (!validateEmail(email)) { @@ -60,20 +62,24 @@ class ForgotPassword extends React.Component { this.props.actions.resetPassword(email) .then((success) => { this.setState({ loading: false }); - if (success && locale === 'hub') { - this.props.history.push('/log-in'); + if (success && isInHub) { + this.navigateToLogIn(); this.props.actions.setToast({ toastMessage: t('banner_check_your_email_title'), toastClass: 'success', }); - } else if (success && locale === 'panel') { + } else if (success && isInPanel) { this.props.history.push('/login'); } }); }); } + navigateToLogIn = () => { + this.props.history.push('/log-in'); + } + /** * Render Forgot Password panel. * @return {ReactComponent} ReactComponent instance @@ -81,24 +87,26 @@ class ForgotPassword extends React.Component { render() { const { email, loading, emailError } = this.state; const { locale } = this.props; + const isInPanel = locale === 'panel'; + const isInHub = locale === 'hub'; const buttonClasses = ClassNames('button ghostery-button', { loading }); const ContainerClassNames = ClassNames('', { - 'forgot-password-panel': locale === 'panel', - ForgotPasswordView: locale === 'hub', + 'forgot-password-panel': isInPanel, + ForgotPasswordView: isInHub, }); const MessageClassNames = ClassNames('', { - 'forgot-password-message': locale === 'panel', - ForgotPasswordMessage: locale === 'hub', + 'forgot-password-message': isInPanel, + ForgotPasswordMessage: isInHub, }); const EmailClassNames = ClassNames('', { - 'forgot-input-email': locale === 'panel', - ForgotPasswordMessage: locale === 'hub', + 'forgot-input-email': isInPanel, + ForgotPasswordMessage: isInHub, }); const ButtonsContainerClassNames = ClassNames('row', { - 'buttons-container': locale === 'panel', - ForgotPasswordButtonsContainer: locale === 'hub', + 'buttons-container': isInPanel, + ForgotPasswordButtonsContainer: isInHub, }); return (
@@ -123,9 +131,16 @@ class ForgotPassword extends React.Component {
- - { t('button_cancel') } - + {isInPanel && ( + + {t('button_cancel')} + + )} + {isInHub && ( +
+ {t('button_cancel')} +
+ )}