Convert AccountDetailsDropdown to ES6 class (#7777)

feature/default_network_editable
Whymarrh Whitby 5 years ago committed by GitHub
parent 6947ff49e0
commit 7f47a42f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      ui/app/components/app/dropdowns/account-details-dropdown.js

@ -2,7 +2,6 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { compose } from 'recompose' import { compose } from 'recompose'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { inherits } from 'util'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import * as actions from '../../../store/actions' import * as actions from '../../../store/actions'
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../selectors/selectors' import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../selectors/selectors'
@ -10,13 +9,6 @@ import { CONNECTED_ROUTE } from '../../../helpers/constants/routes'
import genAccountLink from '../../../../lib/account-link.js' import genAccountLink from '../../../../lib/account-link.js'
import { Menu, Item, CloseArea } from './components/menu' import { Menu, Item, CloseArea } from './components/menu'
AccountDetailsDropdown.contextTypes = {
t: PropTypes.func,
metricsEvent: PropTypes.func,
}
export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(AccountDetailsDropdown)
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
selectedIdentity: getSelectedIdentity(state), selectedIdentity: getSelectedIdentity(state),
@ -40,19 +32,30 @@ function mapDispatchToProps (dispatch) {
} }
} }
inherits(AccountDetailsDropdown, Component) class AccountDetailsDropdown extends Component {
function AccountDetailsDropdown () { static contextTypes = {
Component.call(this) t: PropTypes.func,
metricsEvent: PropTypes.func,
}
this.onClose = this.onClose.bind(this) static propTypes = {
} selectedIdentity: PropTypes.object.isRequired,
network: PropTypes.number.isRequired,
keyrings: PropTypes.array.isRequired,
showAccountDetailModal: PropTypes.func.isRequired,
viewOnEtherscan: PropTypes.func.isRequired,
showRemoveAccountConfirmationModal: PropTypes.func.isRequired,
rpcPrefs: PropTypes.object.isRequired,
history: PropTypes.object.isRequired,
onClose: PropTypes.func.isRequired,
}
AccountDetailsDropdown.prototype.onClose = function (e) { onClose = (e) => {
e.stopPropagation() e.stopPropagation()
this.props.onClose() this.props.onClose()
} }
AccountDetailsDropdown.prototype.render = function AccountDetailsDropdown () { render () {
const { const {
selectedIdentity, selectedIdentity,
network, network,
@ -172,4 +175,7 @@ AccountDetailsDropdown.prototype.render = function AccountDetailsDropdown () {
} }
</Menu> </Menu>
) )
}
} }
export default compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(AccountDetailsDropdown)

Loading…
Cancel
Save