mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Convert TokenMenuDropdown to an ES6 class (#7779)
This commit is contained in:
parent
be3ba68e4c
commit
3b1cd1286f
@ -1,13 +1,53 @@
|
||||
import PropTypes from 'prop-types'
|
||||
import React, { Component } from 'react'
|
||||
import { inherits } from 'util'
|
||||
import { connect } from 'react-redux'
|
||||
import * as actions from '../../../store/actions'
|
||||
import { createAccountLink as genAccountLink } from 'etherscan-link'
|
||||
import { Menu, Item, CloseArea } from './components/menu'
|
||||
|
||||
TokenMenuDropdown.contextTypes = {
|
||||
t: PropTypes.func,
|
||||
class TokenMenuDropdown extends Component {
|
||||
static contextTypes = {
|
||||
t: PropTypes.func,
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
showHideTokenConfirmationModal: PropTypes.func.isRequired,
|
||||
token: PropTypes.object.isRequired,
|
||||
network: PropTypes.number.isRequired,
|
||||
}
|
||||
|
||||
onClose = (e) => {
|
||||
e.stopPropagation()
|
||||
this.props.onClose()
|
||||
}
|
||||
|
||||
render () {
|
||||
const { showHideTokenConfirmationModal } = this.props
|
||||
|
||||
return (
|
||||
<Menu className="token-menu-dropdown" isShowing>
|
||||
<CloseArea onClick={this.onClose} />
|
||||
<Item
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
showHideTokenConfirmationModal(this.props.token)
|
||||
this.props.onClose()
|
||||
}}
|
||||
text={this.context.t('hideToken')}
|
||||
/>
|
||||
<Item
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
const url = genAccountLink(this.props.token.address, this.props.network)
|
||||
global.platform.openWindow({ url })
|
||||
this.props.onClose()
|
||||
}}
|
||||
text={this.context.t('viewOnEtherscan')}
|
||||
/>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown)
|
||||
@ -25,43 +65,3 @@ function mapDispatchToProps (dispatch) {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inherits(TokenMenuDropdown, Component)
|
||||
function TokenMenuDropdown () {
|
||||
Component.call(this)
|
||||
|
||||
this.onClose = this.onClose.bind(this)
|
||||
}
|
||||
|
||||
TokenMenuDropdown.prototype.onClose = function (e) {
|
||||
e.stopPropagation()
|
||||
this.props.onClose()
|
||||
}
|
||||
|
||||
TokenMenuDropdown.prototype.render = function TokenMenuDropdown () {
|
||||
const { showHideTokenConfirmationModal } = this.props
|
||||
|
||||
return (
|
||||
<Menu className="token-menu-dropdown" isShowing>
|
||||
<CloseArea onClick={this.onClose} />
|
||||
<Item
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
showHideTokenConfirmationModal(this.props.token)
|
||||
this.props.onClose()
|
||||
}}
|
||||
text={this.context.t('hideToken')}
|
||||
/>
|
||||
<Item
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
const url = genAccountLink(this.props.token.address, this.props.network)
|
||||
global.platform.openWindow({ url })
|
||||
this.props.onClose()
|
||||
}}
|
||||
text={this.context.t('viewOnEtherscan')}
|
||||
/>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user