1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/development/selector.js

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-07-01 03:22:48 +02:00
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
module.exports = NewComponent
inherits(NewComponent, Component)
function NewComponent () {
Component.call(this)
}
NewComponent.prototype.render = function () {
const props = this.props
2018-07-03 00:49:33 +02:00
const {
states,
selectedKey,
actions,
store,
modifyBackgroundConnection,
backGroundConnectionModifiers,
} = props
2016-07-01 03:22:48 +02:00
const state = this.state || {}
const selected = state.selected || selectedKey
return h('select', {
2016-07-01 08:50:20 +02:00
style: {
margin: '20px 20px 0px',
},
2016-07-01 03:22:48 +02:00
value: selected,
2018-07-03 00:49:33 +02:00
onChange: (event) => {
2016-07-01 03:22:48 +02:00
const selectedKey = event.target.value
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey]
modifyBackgroundConnection(backgroundConnectionModifier || {})
2016-07-01 03:22:48 +02:00
store.dispatch(actions.update(selectedKey))
this.setState({ selected: selectedKey })
},
}, Object.keys(states).map((stateName) => {
return h('option', { value: stateName }, stateName)
}))
}