import React, { Component, PropTypes } from 'react' import { connect } from 'react-redux' import FilterInput from './FilterInput' import { Query } from '../../actions.js' import { update as updateSettings } from '../../ducks/settings' import { updateQuery, setSelectedInput } from '../../ducks/ui' class MainMenu extends Component { static title = 'Start' static route = 'flows' static propTypes = { query: PropTypes.object.isRequired, settings: PropTypes.object.isRequired, updateSettings: PropTypes.func.isRequired, updateQuery: PropTypes.func.isRequired, } constructor(props, context) { super(props, context) this.onSearchChange = this.onSearchChange.bind(this) this.onHighlightChange = this.onHighlightChange.bind(this) } componentWillReceiveProps(nextProps) { if(this.refs[nextProps.selectedInput]) { this.refs[nextProps.selectedInput].select() } this.props.setSelectedInput(undefined) } onSearchChange(val) { this.props.updateQuery({ [Query.SEARCH]: val }) } onHighlightChange(val) { this.props.updateQuery({ [Query.HIGHLIGHT]: val }) } render() { const { query, settings, updateSettings } = this.props return (
updateSettings({ intercept })} />
) } } export default connect( state => ({ settings: state.settings.settings, selectedInput: state.ui.selectedInput }), { updateSettings, updateQuery, setSelectedInput }, null, { withRef: true, } )(MainMenu);