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 all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -29,6 +29,7 @@ import {
GET_USER_SUBSCRIPTION_DATA_FAIL,
GET_USER_SUBSCRIPTION_DATA_SUCCESS
} from './AccountConstants';
import { SET_TOAST } from '../hub/Views/AppView/AppViewConstants';
import { CLEAR_THEME } from '../panel/constants/constants';

export const getUserSettings = () => dispatch => (
@@ -172,10 +173,19 @@ export const resetPassword = email => dispatch => (
.then((res) => {
const { errors } = res;
if (errors) {
// Panel toast message
dispatch({
type: RESET_PASSWORD_FAIL,
payload: { errors },
});
// Hub toast message
dispatch({
type: SET_TOAST,
data: {
toastMessage: t('banner_email_not_in_system_message'),
toastClass: 'alert',
},
});
return false;
}
dispatch({ type: RESET_PASSWORD_SUCCESS });
@@ -54,6 +54,7 @@ html, body, #root {
@import './partials/_hub_svgs';
@import './partials/_shared_components_svgs';
@import './partials/_fonts';
@import './partials/_loader';

// Imports from ../hub directory
@import '../hub/Views/SideNavigationView/SideNavigationView.scss';
@@ -76,6 +76,7 @@ html body {
@import './partials/_stats';
@import './partials/_stats_graph';
@import './partials/_modal_exit_button';
@import './partials/_loader';

// Imports from ../shared-components directory
@import '../shared-components/Modal/Modal.scss';
@@ -93,86 +93,6 @@ p.warning {
}
}

.button {
.loader {
display: none;
}
&.loading {
pointer-events: none;
.loader {
display: inline-block;
height: 12px;
width: 12px;
}
.title {
display: none;
}
}
}

.loader {
font-size: 10px;
text-indent: -9999em;
width: 10rem;
height: 10rem;
border-radius: 50%;
background: #ffffff;
background: -moz-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -webkit-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -o-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
position: relative;
-webkit-animation: load3 1.4s infinite linear;
animation: load3 1.4s infinite linear;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.loader:before {
width: 50%;
height: 50%;
background: #ffffff;
border-radius: 100% 0 0 0;
position: absolute;
top: 0;
left: 0;
content: '';
}
.loader:after {
background: #00AEF0;
width: 75%;
height: 75%;
border-radius: 50%;
content: '';
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
@-webkit-keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

/* FORGOT PASSWORD PANEL */
#forgot-password-panel{
margin-top: 75px;
@@ -0,0 +1,79 @@
.button {
.loader {
display: none;
}
&.loading {
pointer-events: none;
.loader {
display: inline-block;
height: 12px;
width: 12px;
}
.title {
display: none;
}
}
}
.loader {
font-size: 10px;
text-indent: -9999em;
width: 10rem;
height: 10rem;
border-radius: 50%;
background: #ffffff;
background: -moz-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -webkit-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -o-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: -ms-linear-gradient(left, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
position: relative;
-webkit-animation: load3 1.4s infinite linear;
animation: load3 1.4s infinite linear;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
.loader:before {
width: 50%;
height: 50%;
background: #ffffff;
border-radius: 100% 0 0 0;
position: absolute;
top: 0;
left: 0;
content: '';
}
.loader:after {
background: #00AEF0;
width: 75%;
height: 75%;
border-radius: 50%;
content: '';
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
@-webkit-keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes load3 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}

@@ -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.