From d01e49c6d5e474700956a9b7f1171a4229bfa750 Mon Sep 17 00:00:00 2001
From: Jason <jason.daurus@gmail.com>
Date: Sun, 19 Jun 2016 02:53:15 +0800
Subject: [web] replace SetttingsActions.update with settings.updateSettings

---
 web/src/js/components/Header/MainMenu.jsx | 39 +++++++++++++++----------------
 1 file changed, 19 insertions(+), 20 deletions(-)

(limited to 'web/src/js/components/Header/MainMenu.jsx')

diff --git a/web/src/js/components/Header/MainMenu.jsx b/web/src/js/components/Header/MainMenu.jsx
index 7b0b542c..a466a980 100644
--- a/web/src/js/components/Header/MainMenu.jsx
+++ b/web/src/js/components/Header/MainMenu.jsx
@@ -1,8 +1,8 @@
 import React, { Component, PropTypes } from 'react'
+import { connect } from 'react-redux'
 import FilterInput from './FilterInput'
 import { Query } from '../../actions.js'
-import {setInterceptPattern} from "../../ducks/settings"
-import { connect } from 'react-redux'
+import { updateSettings } from '../../ducks/settings'
 
 class MainMenu extends Component {
 
@@ -10,14 +10,16 @@ class MainMenu extends Component {
     static route = 'flows'
 
     static propTypes = {
-        settings: React.PropTypes.object.isRequired,
+        query: PropTypes.object.isRequired,
+        settings: PropTypes.object.isRequired,
+        updateLocation: PropTypes.func.isRequired,
+        onSettingsChange: PropTypes.func.isRequired,
     }
 
     constructor(props, context) {
         super(props, context)
         this.onSearchChange = this.onSearchChange.bind(this)
         this.onHighlightChange = this.onHighlightChange.bind(this)
-        this.onInterceptChange = this.onInterceptChange.bind(this)
     }
 
     onSearchChange(val) {
@@ -28,16 +30,8 @@ class MainMenu extends Component {
         this.props.updateLocation(undefined, { [Query.HIGHLIGHT]: val })
     }
 
-    onInterceptChange(val) {
-        this.props.setInterceptPattern(val);
-    }
-
     render() {
-        const { query, settings } = this.props
-
-        const search = query[Query.SEARCH] || ''
-        const highlight = query[Query.HIGHLIGHT] || ''
-        const intercept = settings.intercept || ''
+        const { query, settings, onSettingsChange } = this.props
 
         return (
             <div>
@@ -47,7 +41,7 @@ class MainMenu extends Component {
                         placeholder="Search"
                         type="search"
                         color="black"
-                        value={search}
+                        value={query[Query.SEARCH] || ''}
                         onChange={this.onSearchChange}
                     />
                     <FilterInput
@@ -55,7 +49,7 @@ class MainMenu extends Component {
                         placeholder="Highlight"
                         type="tag"
                         color="hsl(48, 100%, 50%)"
-                        value={highlight}
+                        value={query[Query.HIGHLIGHT] || ''}
                         onChange={this.onHighlightChange}
                     />
                     <FilterInput
@@ -63,8 +57,8 @@ class MainMenu extends Component {
                         placeholder="Intercept"
                         type="pause"
                         color="hsl(208, 56%, 53%)"
-                        value={intercept}
-                        onChange={this.onInterceptChange}
+                        value={settings.intercept || ''}
+                        onChange={intercept => onSettingsChange({ intercept })}
                     />
                 </div>
                 <div className="clearfix"></div>
@@ -73,6 +67,11 @@ class MainMenu extends Component {
     }
 }
 
-export default connect(undefined, {
-    setInterceptPattern
-})(MainMenu);
+export default connect(
+    state => ({
+        settings: state.settings.settings,
+    }),
+    {
+        onSettingsChange: updateSettings,
+    }
+)(MainMenu);
-- 
cgit v1.2.3

