From d53a2de0ba69bea6c7aefa87782ad249cfb4ea76 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 4 Jun 2016 18:53:41 -0700 Subject: web: completely move flow state to redux --- web/src/js/ducks/flows.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'web/src/js/ducks/flows.js') 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 -- cgit v1.2.3