forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add/account recovery/step 5b to 6 (Automattic#13362)
* Wrap form components under `<form>` tag * Move `reset-password-confirm-form` one directory level up and integrate it into the AR flow. * Chain step 5b to step 6. * Fix `account-recovery/validate` data layer handler accordingly. * Update Account Recovery < New Password as a breadcrumb format. * Remove the unnecessary `primary` * Show more details of error accordingly * Break a long string into two lines.
- Loading branch information
Showing
11 changed files
with
152 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 24 additions & 7 deletions
31
client/account-recovery/components/account-recovery-error-message/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import { localize } from 'i18n-calypso'; | ||
import config from 'config'; | ||
|
||
const AccountRecoveryErrorMessage = ( props ) => ( | ||
<p className="account-recovery-error-message"> | ||
{ props.translate( | ||
class AccountRecoveryErrorMessage extends Component { | ||
getErrorMessage = () => { | ||
const { | ||
translate, | ||
error, | ||
} = this.props; | ||
|
||
switch ( error.name ) { | ||
case 'RestInvalidKeyError': | ||
return translate( "We've failed to validate with the given code. " + | ||
'Please double check if the code is correct.' ); | ||
} | ||
|
||
return translate( | ||
"We're having trouble connecting to our servers at the moment. " + | ||
'Please try again later. If the problem persists, please {{a}}contact us{{/a}}.', | ||
{ components: { | ||
a: <a href={ config( 'login_url' ) + '?action=recovery' } target="_blank" rel="noopener noreferrer" /> | ||
} } | ||
) } | ||
</p> | ||
); | ||
); | ||
} | ||
|
||
render = () => { | ||
const errorMsg = this.getErrorMessage(); | ||
|
||
return <p className="account-recovery-error-message__text">{ errorMsg }</p>; | ||
} | ||
} | ||
|
||
export default localize( AccountRecoveryErrorMessage ); |
2 changes: 1 addition & 1 deletion
2
client/account-recovery/components/account-recovery-error-message/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.account-recovery-error-message { | ||
.account-recovery-error-message__text { | ||
margin-bottom: 4px; | ||
color: $alert-red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
client/account-recovery/reset-password-confirm-form/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { Component } from 'react'; | ||
import { localize } from 'i18n-calypso'; | ||
import { identity } from 'lodash'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Card from 'components/card'; | ||
import FormPasswordInput from 'components/forms/form-password-input'; | ||
import FormLabel from 'components/forms/form-label'; | ||
import FormButton from 'components/forms/form-button'; | ||
import { STRONG_PASSWORD } from 'lib/url/support'; | ||
|
||
class ResetPasswordConfirmForm extends Component { | ||
submitNewPassword = ( event ) => { | ||
event.preventDefault(); | ||
} | ||
|
||
render() { | ||
const { translate } = this.props; | ||
|
||
return ( | ||
<Card> | ||
<h2 className="reset-password-confirm-form__title">{ translate( 'Reset your password' ) }</h2> | ||
<form onSubmit={ this.submitNewPassword }> | ||
<FormLabel className="reset-password-confirm-form__text-input-label" htmlFor="password"> | ||
{ translate( 'New password' ) } | ||
</FormLabel> | ||
<FormPasswordInput className="reset-password-confirm-form__password-input-field" id="password" autoFocus /> | ||
<FormButton className="reset-password-confirm-form__button generate-password-button" isPrimary={ false }> | ||
{ translate( 'Generate strong password' ) } | ||
</FormButton> | ||
<p className="reset-password-confirm-form__description"> | ||
{ translate( | ||
'{{a}}Great passwords{{/a}} use upper and lower case characters, numbers, ' + | ||
'and symbols like {{em}}%(symbols)s{{/em}}.', | ||
{ | ||
args: { | ||
symbols: '!/"$%&', | ||
}, | ||
components: { | ||
a: <a href={ STRONG_PASSWORD } target="_blank" rel="noopener noreferrer" />, | ||
em: <em />, | ||
} | ||
} | ||
) } | ||
</p> | ||
<FormButton className="reset-password-confirm-form__button submit" type="submit"> | ||
{ translate( 'Reset Password' ) } | ||
</FormButton> | ||
</form> | ||
</Card> | ||
); | ||
} | ||
} | ||
|
||
ResetPasswordConfirmForm.defaultProps = { | ||
translate: identity, | ||
}; | ||
|
||
export default localize( ResetPasswordConfirmForm ); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
client/account-recovery/reset-password/reset-password-confirm-form/index.jsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.