diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-06-06 08:58:50 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2016-06-06 08:58:50 +1200 |
commit | 2b19a33738b20181d7b6ff10a9ffbf6c51ac96c2 (patch) | |
tree | 0939fd997c33b5baaa821cb846a4dc721dc38357 /web/src/js/ducks/flows.js | |
parent | 08344ee38b1311b60afc906296f4720de748c945 (diff) | |
parent | d53a2de0ba69bea6c7aefa87782ad249cfb4ea76 (diff) | |
download | mitmproxy-2b19a33738b20181d7b6ff10a9ffbf6c51ac96c2.tar.gz mitmproxy-2b19a33738b20181d7b6ff10a9ffbf6c51ac96c2.tar.bz2 mitmproxy-2b19a33738b20181d7b6ff10a9ffbf6c51ac96c2.zip |
Merge pull request #1212 from mitmproxy/such-redux
web: completely move flow state to redux
Diffstat (limited to 'web/src/js/ducks/flows.js')
-rw-r--r-- | web/src/js/ducks/flows.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js index fb934489..fdbc42ee 100644 --- a/web/src/js/ducks/flows.js +++ b/web/src/js/ducks/flows.js @@ -1,6 +1,11 @@ import makeList from "./utils/list" +import Filt from "../filt/filt" +import {updateViewFilter, updateViewList} from "./utils/view" export const UPDATE_FLOWS = "UPDATE_FLOWS" +export const SET_FILTER = "SET_FLOW_FILTER" +export const SET_HIGHLIGHT = "SET_FLOW_HIGHLIGHT" +export const SELECT_FLOW = "SELECT_FLOW" const { reduceList, @@ -11,6 +16,14 @@ const { const defaultState = { all: reduceList(), + selected: [], + view: [], + filter: undefined, + highlight: undefined, +} + +function makeFilterFn(filter) { + return filter ? Filt.parse(filter) : () => true; } export default function reducer(state = defaultState, action) { @@ -20,10 +33,48 @@ export default function reducer(state = defaultState, action) { return { ...state, all, + view: updateViewList(state.view, state.all, all, action, makeFilterFn(action.filter)) + } + case SET_FILTER: + return { + ...state, + filter: action.filter, + view: updateViewFilter(state.all, makeFilterFn(action.filter)) + } + case SET_HIGHLIGHT: + return { + ...state, + highlight: action.highlight + } + case SELECT_FLOW: + return { + ...state, + selected: [action.flowId] } default: return state } } + +export function setFilter(filter) { + return { + type: SET_FILTER, + filter + } +} +export function setHighlight(highlight) { + return { + type: SET_HIGHLIGHT, + highlight + } +} +export function selectFlow(flowId) { + return { + type: SELECT_FLOW, + flowId + } +} + + export {updateList as updateFlows, fetchList as fetchFlows}
\ No newline at end of file |