-
Notifications
You must be signed in to change notification settings - Fork 2k
2FA Setup: Use vertical nav instead of radio buttons #103286
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
Open
rcrdortiz
wants to merge
1
commit into
trunk
Choose a base branch
from
dotcom-13063-2fa-setup-use-vertical-nav-instead-of-radio-buttons
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,107 +1,56 @@ | ||
import { FormLabel, Gridicon } from '@automattic/components'; | ||
import debugFactory from 'debug'; | ||
import { localize } from 'i18n-calypso'; | ||
import PropTypes from 'prop-types'; | ||
import { Component } from 'react'; | ||
import FormButton from 'calypso/components/forms/form-button'; | ||
import FormFieldset from 'calypso/components/forms/form-fieldset'; | ||
import FormRadio from 'calypso/components/forms/form-radio'; | ||
import FormSettingExplanation from 'calypso/components/forms/form-setting-explanation'; | ||
import { CompactCard } from '@automattic/components'; | ||
import { useTranslate } from 'i18n-calypso'; | ||
import { useCallback } from 'react'; | ||
import VerticalNavItemEnhanced from 'calypso/components/vertical-nav/item/enhanced'; | ||
import { gaRecordEvent } from 'calypso/lib/analytics/ga'; | ||
import { APP_BASED_2FA_SETUP, SMS_BASED_2FA_SETUP } from 'calypso/me/security-2fa-setup'; | ||
|
||
import './style.scss'; | ||
|
||
const debug = debugFactory( 'calypso:me:security:2fa-initial-setup' ); | ||
|
||
class Security2faInitialSetup extends Component { | ||
static displayName = 'Security2faInitialSetup'; | ||
|
||
static propTypes = { | ||
onSuccess: PropTypes.func.isRequired, | ||
}; | ||
|
||
state = { | ||
authMethod: 'app-based', | ||
}; | ||
|
||
componentDidMount() { | ||
debug( this.constructor.displayName + ' React component is mounted.' ); | ||
} | ||
|
||
componentWillUnmount() { | ||
debug( this.constructor.displayName + ' React component will unmount.' ); | ||
} | ||
|
||
setAuth = ( event ) => this.setState( { authMethod: event.currentTarget.value } ); | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<p> | ||
{ this.props.translate( | ||
'Two-Step Authentication adds an extra layer ' + | ||
'of security to your account. Once enabled, logging in to ' + | ||
'WordPress.com will require you to enter a unique passcode ' + | ||
'generated by an app on your mobile device or sent via text ' + | ||
'message, in addition to your username and password.' | ||
) } | ||
</p> | ||
|
||
<FormFieldset> | ||
<FormRadio | ||
id="app-auth" | ||
name="auth_method" | ||
value="app-based" | ||
defaultChecked | ||
onChange={ this.setAuth } | ||
/> | ||
<FormLabel htmlFor="app-auth"> | ||
<Gridicon icon="phone" /> | ||
<span className="security-2fa-initial-setup__item-title"> | ||
{ this.props.translate( 'Set up using an app', { | ||
comment: 'A label used during Two-Step setup.', | ||
} ) } | ||
</span> | ||
</FormLabel> | ||
<FormSettingExplanation> | ||
{ this.props.translate( | ||
'Use an application on your phone to get two-step authentication codes when you login.' | ||
) } | ||
</FormSettingExplanation> | ||
</FormFieldset> | ||
<FormFieldset> | ||
<FormRadio | ||
id="sms-auth" | ||
name="auth_method" | ||
value="sms-settings" | ||
onChange={ this.setAuth } | ||
/> | ||
<FormLabel htmlFor="sms-auth"> | ||
<Gridicon icon="chat" /> | ||
<span className="security-2fa-initial-setup__item-title"> | ||
{ this.props.translate( 'Set up using SMS', { | ||
comment: 'A label used during Two-Step setup.', | ||
} ) } | ||
</span> | ||
</FormLabel> | ||
<FormSettingExplanation> | ||
{ this.props.translate( | ||
'WordPress.com will send you an SMS with a two-step authentication code when you log in.' | ||
) } | ||
</FormSettingExplanation> | ||
</FormFieldset> | ||
|
||
<FormButton | ||
onClick={ ( event ) => { | ||
gaRecordEvent( 'Me', 'Clicked On 2fa Get Started Button' ); | ||
this.props.onSuccess( event, this.state.authMethod ); | ||
} } | ||
> | ||
{ this.props.translate( 'Get Started' ) } | ||
</FormButton> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default localize( Security2faInitialSetup ); | ||
const Security2faInitialSetup = ( { onSuccess } ) => { | ||
const translate = useTranslate(); | ||
|
||
const handleClick = useCallback( | ||
( event, authMethod ) => { | ||
gaRecordEvent( 'Me', 'Clicked On 2fa Get Started Button' ); | ||
onSuccess( event, authMethod ); | ||
}, | ||
[ onSuccess ] | ||
); | ||
|
||
return ( | ||
<> | ||
<CompactCard> | ||
{ translate( | ||
'Two-Step Authentication adds an extra layer ' + | ||
'of security to your account. Once enabled, logging in to ' + | ||
'WordPress.com will require you to enter a unique passcode ' + | ||
'generated by an app on your mobile device or sent via text ' + | ||
'message, in addition to your username and password.' | ||
) } | ||
</CompactCard> | ||
|
||
<VerticalNavItemEnhanced | ||
className="security-initial-setup-nav-item" | ||
gridicon="phone" | ||
onClick={ ( event ) => handleClick( event, APP_BASED_2FA_SETUP ) } | ||
text={ translate( 'Set up using an app' ) } | ||
description={ translate( | ||
'Use an application on your phone to get two-step authentication codes when you login.' | ||
) } | ||
/> | ||
|
||
<VerticalNavItemEnhanced | ||
className="security-initial-setup-nav-item" | ||
gridicon="comment" | ||
onClick={ ( event ) => handleClick( event, SMS_BASED_2FA_SETUP ) } | ||
text={ translate( 'Set up using SMS' ) } | ||
description={ translate( | ||
'WordPress.com will send you an SMS with a two-step authentication code when you log in.' | ||
) } | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default Security2faInitialSetup; |
This file contains hidden or 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,5 +1,13 @@ | ||
.security-2fa-initial-setup__item-title { | ||
margin-left: 5px; | ||
font-size: $font-body; | ||
vertical-align: top; | ||
.security-2fa-setup__steps-container { | ||
.security-2fa-initial-setup__item-title { | ||
margin-left: 5px; | ||
font-size: $font-body; | ||
vertical-align: top; | ||
} | ||
|
||
.security-initial-setup-nav-item { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
|
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We distribute the
Card
component to avoid boxes within boxes.