mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
import React, {Component} from 'react'
|
|
|
|
export default class Selector extends Component {
|
|
state = {}
|
|
|
|
render () {
|
|
const {
|
|
states,
|
|
selectedKey,
|
|
actions,
|
|
store,
|
|
modifyBackgroundConnection,
|
|
backGroundConnectionModifiers,
|
|
} = this.props
|
|
const selected = this.state.selected || selectedKey
|
|
|
|
return (
|
|
<select
|
|
style={{ margin: '20px 20px 0px' }}
|
|
value={selected}
|
|
onChange={(event) => {
|
|
const selectedKey = event.target.value
|
|
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey]
|
|
modifyBackgroundConnection(backgroundConnectionModifier || {})
|
|
store.dispatch(actions.update(selectedKey))
|
|
this.setState({ selected: selectedKey })
|
|
}}
|
|
>
|
|
{Object.keys(states).map((stateName, index) => {
|
|
return (
|
|
<option key={index} value={stateName}>
|
|
{stateName}
|
|
</option>
|
|
)
|
|
})}
|
|
</select>
|
|
)
|
|
}
|
|
}
|
|
|
|
Selector.propTypes = {
|
|
states: PropTypes.object.isRequired,
|
|
selectedKey: PropTypes.string.isRequired,
|
|
actions: PropTypes.object.isRequired,
|
|
store: PropTypes.object.isRequired,
|
|
modifyBackgroundConnection: PropTypes.func.isRequired,
|
|
backGroundConnectionModifiers: PropTypes.object.isRequired,
|
|
}
|