Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH 1960 & GH-2028 ForgotPassword Hub Error Message and Loading Icon Fix #533

Merged
merged 4 commits into from Apr 26, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Next
Cancel button brings you back to log in page
  • Loading branch information
benstrumeyer committed Apr 23, 2020
commit d3f24ae59f687c76fe6876c9a2f5fc0160fe4700
@@ -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,45 +62,51 @@ 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
*/
render() {
const { email, loading, emailError } = this.state;
const { locale } = this.props;
const isInPanel = locale === 'panel';
const isInHub = locale === 'hub';
Comment on lines 89 to +91

This comment has been minimized.

@Eden12345

Eden12345 Apr 24, 2020
Contributor

I know this wasn't added in this PR either, just wanted to point out that it's a rather confusing choice semantically to use "locale" for the variable name for which view we're in when we also have locales for translations.

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 (
<div id={ContainerClassNames}>
@@ -123,9 +131,16 @@ class ForgotPassword extends React.Component {
</div>
<div className={ButtonsContainerClassNames}>
<div className="small-6 columns text-center">
<Link to="/login" id="forgot-password-cancel" className="cancel button hollow">
{ t('button_cancel') }
</Link>
{isInPanel && (
<Link to="/login" id="forgot-password-cancel" className="cancel button hollow">
{t('button_cancel')}
</Link>
)}
{isInHub && (
<div id="forgot-password-cancel" className="cancel button hollow" onClick={this.navigateToLogIn}>
{t('button_cancel')}
</div>
)}
</div>
<div className="small-6 columns text-center">
<button type="submit" id="send-button" className={buttonClasses}>
ProTip! Use n and p to navigate between commits in a pull request.