1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 05:12:18 +01:00
metamask-extension/ui/app/components/dropdowns/token-menu-dropdown.js

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-09-29 12:10:50 +02:00
const Component = require('react').Component
const PropTypes = require('prop-types')
2017-09-29 12:10:50 +02:00
const h = require('react-hyperscript')
const inherits = require('util').inherits
const connect = require('react-redux').connect
2017-09-29 21:03:29 +02:00
const actions = require('../../actions')
2018-03-15 00:31:45 +01:00
2017-09-29 21:03:29 +02:00
TokenMenuDropdown.contextTypes = {
t: PropTypes.func,
}
2017-09-29 21:03:29 +02:00
module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)
2017-09-29 21:03:29 +02:00
function mapDispatchToProps (dispatch) {
return {
showHideTokenConfirmationModal: (token) => {
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
2017-11-02 13:15:59 +01:00
},
2017-09-29 21:03:29 +02:00
}
}
2017-09-29 12:10:50 +02:00
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 () {
2017-09-29 21:03:29 +02:00
const { showHideTokenConfirmationModal } = this.props
2017-09-29 12:10:50 +02:00
return h('div.token-menu-dropdown', {}, [
h('div.token-menu-dropdown__close-area', {
onClick: this.onClose,
}),
h('div.token-menu-dropdown__container', {}, [
h('div.token-menu-dropdown__options', {}, [
2017-11-02 13:15:59 +01:00
2017-09-29 12:10:50 +02:00
h('div.token-menu-dropdown__option', {
onClick: (e) => {
e.stopPropagation()
2017-09-29 21:03:29 +02:00
showHideTokenConfirmationModal(this.props.token)
this.props.onClose()
2017-09-29 12:10:50 +02:00
},
}, this.context.t('hideToken')),
2017-09-29 12:10:50 +02:00
]),
]),
])
}