Skip to content

Commit

Permalink
fix(Eth): if no legacy account show only 'Export Private Key'
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed May 1, 2018
1 parent 1495d10 commit 925e9c7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import { isNil } from 'ramda'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { actions } from 'data'
import Menu from './template.js'
import { getLegacyAccountAddress } from './selectors'

class MenuContainer extends React.Component {
constructor (props) {
Expand All @@ -15,12 +17,19 @@ class MenuContainer extends React.Component {
}

render () {
return <Menu onShowPrivateKey={this.onShowPrivateKey} />
const { legacyAccountAddress } = this.props
const hasLegacyAccount = !isNil(legacyAccountAddress.data)

return <Menu onShowPrivateKey={this.onShowPrivateKey} hasLegacyAccount={hasLegacyAccount} />
}
}

const mapStateToProps = (state) => ({
legacyAccountAddress: getLegacyAccountAddress(state)
})

const mapDispatchToProps = (dispatch) => ({
modalActions: bindActionCreators(actions.modals, dispatch)
})

export default connect(undefined, mapDispatchToProps)(MenuContainer)
export default connect(mapStateToProps, mapDispatchToProps)(MenuContainer)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { selectors } from 'data'

export const getLegacyAccountAddress = selectors.core.kvStore.ethereum.getLegacyAccountAddress
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ const OptionItem = ({ id, defaultMessage, onClick }) => (
)

const PrivateKeys = () => (
<Link weight={200} size='small'>
<Link weight={300} size='12px'>
<FormattedMessage id='scenes.transactions.ether.privatekeys' defaultMessage='Private Keys' />
</Link>
)

const Menu = (props) => {
const { onShowPrivateKey } = props
const { hasLegacyAccount, onShowPrivateKey } = props
return (
<Wrapper>
<Container>
Expand All @@ -79,15 +79,17 @@ const Menu = (props) => {
</Status>
<MenuRight>
<PrivateKeysWrapper>
<ComponentDropdown
down
forceSelected
color={'gray-5'}
selectedComponent={<PrivateKeys />}
components={[
<OptionItem id='scenes.transactions.ether.export.privatekey' defaultMessage='Export Private Key' onClick={() => onShowPrivateKey(false)} />,
<OptionItem id='scenes.transactions.ether.export.archived' defaultMessage='Export Archived Private Key' onClick={() => onShowPrivateKey(true)} />
].filter(x => x)} />
{
hasLegacyAccount ? <ComponentDropdown
down
forceSelected
color={'gray-5'}
selectedComponent={<PrivateKeys />}
components={[
<OptionItem id='scenes.transactions.ether.export.privatekey' defaultMessage='Export Private Key' onClick={() => onShowPrivateKey(false)} />,
<OptionItem id='scenes.transactions.ether.export.archived' defaultMessage='Export Archived Private Key' onClick={() => onShowPrivateKey(true)} />
].filter(x => x)} /> : <Link size={'12px'} weight={300} onClick={() => onShowPrivateKey(false)}><FormattedMessage id='scenes.transactions.ether.export.privatekey' defaultMessage='Export Private Key' /></Link>
}
</PrivateKeysWrapper>
<Search>
<Field name='search' component={TextBox} />
Expand Down

0 comments on commit 925e9c7

Please sign in to comment.