aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/eventLog.js
blob: 5bae252a04e9629f5fe1178460db8441bc3c61f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const TOGGLE_FILTER = 'TOGGLE_EVENTLOG_FILTER'
const TOGGLE_VISIBILITY = 'TOGGLE_EVENTLOG_VISIBILITY'


const defaultState = {
    visible: false,
    filter: {
        "debug": false,
        "info": true,
        "web": true
    }
}
export default function reducer(state = defaultState, action) {
    switch (action.type) {
        case TOGGLE_FILTER:
            return {
                ...state,
                filter: {
                    ...state.filter,
                    [action.filter]: !state.filter[action.filter]
                }
            }
        case TOGGLE_VISIBILITY:
            return {
                ...state,
                visible: !state.visible
            }
        default:
            return state
    }
}


export function toggleEventLogFilter(filter) {
    return {type: TOGGLE_FILTER, filter}
}
export function toggleEventLogVisibility() {
    return {type: TOGGLE_VISIBILITY}
}