-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(component): clean up security center menus
- Loading branch information
Showing
48 changed files
with
462 additions
and
534 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
63 changes: 63 additions & 0 deletions
63
packages/blockchain-wallet-v4-frontend/src/scenes/SecurityCenter/Basic/index.js
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,63 @@ | ||
import React from 'react' | ||
import { withRouter } from 'react-router-dom' | ||
import { bindActionCreators } from 'redux' | ||
import { connect } from 'react-redux' | ||
import { pathOr } from 'ramda' | ||
|
||
import { actions, selectors } from 'data' | ||
import BasicSettings from './template' | ||
|
||
class SecurityCenterContainer extends React.PureComponent { | ||
state = { | ||
editing: false, | ||
enabling: false, | ||
changeEmail: pathOr(false, ['location', 'state', 'changeEmail'], this.props) | ||
} | ||
|
||
componentWillUnmount () { | ||
this.onClose() | ||
} | ||
|
||
handleEnable = step => { | ||
this.setState({ enabling: step }) | ||
} | ||
|
||
onClose = () => { | ||
if (this.state.enabling === 'recovery') { | ||
this.props.settingsActions.removeRecoveryPhrase() | ||
} | ||
this.setState({ enabling: false }) | ||
} | ||
|
||
render () { | ||
return ( | ||
<BasicSettings | ||
progress={1} | ||
data={this.props} | ||
editing={this.state.editing} | ||
enabling={this.state.enabling} | ||
handleEnable={this.handleEnable} | ||
onClose={this.onClose} | ||
changeEmail={this.state.changeEmail} | ||
isMnemonicVerified={this.props.isMnemonicVerified} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
authType: selectors.core.settings.getAuthType(state), | ||
emailVerified: selectors.core.settings.getEmailVerified(state), | ||
isMnemonicVerified: selectors.core.wallet.isMnemonicVerified(state) | ||
}) | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
settingsActions: bindActionCreators(actions.modules.settings, dispatch) | ||
}) | ||
|
||
export default withRouter( | ||
connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(SecurityCenterContainer) | ||
) |
87 changes: 87 additions & 0 deletions
87
packages/blockchain-wallet-v4-frontend/src/scenes/SecurityCenter/Basic/template.js
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,87 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { Icon } from 'blockchain-info-components' | ||
|
||
import EmailAddress from './EmailAddress' | ||
import TwoStepVerification from './TwoStepVerification' | ||
import WalletRecoveryPhrase from './WalletRecoveryPhrase' | ||
|
||
const BodyContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
width: 100%; | ||
& > * { | ||
margin-top: 20px; | ||
} | ||
` | ||
const IconContainer = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-bottom: 15px; | ||
` | ||
|
||
const SecurityCenter = props => { | ||
const { handleEnable, enabling, changeEmail, onClose } = props | ||
|
||
const renderSteps = () => { | ||
if (enabling === 'email') { | ||
return ( | ||
<BodyContainer> | ||
<EmailAddress alone={1} goBackOnSuccess={onClose} /> | ||
</BodyContainer> | ||
) | ||
} | ||
if (enabling === '2fa') { | ||
return ( | ||
<BodyContainer> | ||
<TwoStepVerification alone={1} goBackOnSuccess={onClose} /> | ||
</BodyContainer> | ||
) | ||
} | ||
if (enabling === 'recovery') { | ||
return ( | ||
<BodyContainer> | ||
<WalletRecoveryPhrase alone={1} goBackOnSuccess={onClose} /> | ||
</BodyContainer> | ||
) | ||
} | ||
return ( | ||
<BodyContainer> | ||
<EmailAddress | ||
handleEnable={() => handleEnable('email')} | ||
goBackOnSuccess={onClose} | ||
changeEmail={changeEmail} | ||
/> | ||
<TwoStepVerification | ||
handleEnable={() => handleEnable('2fa')} | ||
goBackOnSuccess={onClose} | ||
/> | ||
<WalletRecoveryPhrase | ||
handleEnable={() => handleEnable('recovery')} | ||
goBackOnSuccess={onClose} | ||
/> | ||
</BodyContainer> | ||
) | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
{enabling && ( | ||
<IconContainer> | ||
<Icon | ||
name='close' | ||
size='20px' | ||
weight={300} | ||
color='gray-5' | ||
cursor | ||
onClick={onClose} | ||
/> | ||
</IconContainer> | ||
)} | ||
{renderSteps()} | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
export default SecurityCenter |
66 changes: 66 additions & 0 deletions
66
packages/blockchain-wallet-v4-frontend/src/scenes/SecurityCenter/Menu/index.js
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,66 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import styled from 'styled-components' | ||
|
||
import { Text } from 'blockchain-info-components' | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
background-color: ${props => props.theme['white-blue']}; | ||
width: 100%; | ||
height: 50px; | ||
border-bottom: 1px solid #eaeaea; | ||
padding: 0 30px; | ||
` | ||
const TabList = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
div:first-of-type { | ||
margin-right: 25px; | ||
} | ||
` | ||
const Tab = styled(Text)` | ||
cursor: pointer; | ||
border-bottom: ${props => (props.active ? '1px solid black' : null)}; | ||
opacity: ${props => (props.active ? 1 : 0.3)}; | ||
text-transform: uppercase; | ||
` | ||
|
||
class MenuContainer extends React.PureComponent { | ||
render () { | ||
const { activeTab, setActiveTab } = this.props | ||
|
||
return ( | ||
<Wrapper> | ||
<TabList> | ||
<Tab | ||
active={activeTab === 'basic'} | ||
onClick={() => { | ||
setActiveTab('basic') | ||
}} | ||
> | ||
<FormattedMessage | ||
id='scenes.securitycenter.menu.basic' | ||
defaultMessage='Basic' | ||
/> | ||
</Tab> | ||
<Tab | ||
active={activeTab === 'advanced'} | ||
onClick={() => { | ||
setActiveTab('advanced') | ||
}} | ||
> | ||
<FormattedMessage | ||
id='scenes.securitycenter.menu.advanced' | ||
defaultMessage='Advanced' | ||
/> | ||
</Tab> | ||
</TabList> | ||
</Wrapper> | ||
) | ||
} | ||
} | ||
|
||
export default MenuContainer |
Oops, something went wrong.