aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/flows.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/ducks/flows.js')
-rw-r--r--web/src/js/ducks/flows.js51
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