aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/dropdowns/token-menu-dropdown.js
blob: b70d0b8933b304585011a4ad7792bea4924df200 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const Component = require('react').Component
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const inherits = require('util').inherits
const connect = require('react-redux').connect
const actions = require('../../actions')


TokenMenuDropdown.contextTypes = {
  t: PropTypes.func,
}

module.exports = connect(null, mapDispatchToProps)(TokenMenuDropdown)


function mapDispatchToProps (dispatch) {
  return {
    showHideTokenConfirmationModal: (token) => {
      dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token }))
    },
  }
}


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 () {
  const { showHideTokenConfirmationModal } = this.props

  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', {}, [

        h('div.token-menu-dropdown__option', {
          onClick: (e) => {
            e.stopPropagation()
            showHideTokenConfirmationModal(this.props.token)
            this.props.onClose()
          },
        }, this.context.t('hideToken')),

      ]),
    ]),
  ])
}