|
|
@ -1,13 +1,53 @@ |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import PropTypes from 'prop-types' |
|
|
|
import React, { Component } from 'react' |
|
|
|
import React, { Component } from 'react' |
|
|
|
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 { createAccountLink as genAccountLink } from 'etherscan-link' |
|
|
|
import { createAccountLink as genAccountLink } from 'etherscan-link' |
|
|
|
import { Menu, Item, CloseArea } from './components/menu' |
|
|
|
import { Menu, Item, CloseArea } from './components/menu' |
|
|
|
|
|
|
|
|
|
|
|
TokenMenuDropdown.contextTypes = { |
|
|
|
class TokenMenuDropdown extends Component { |
|
|
|
t: PropTypes.func, |
|
|
|
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) |
|
|
|
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> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|