mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
15.07.2019 eeb5db743dfed0254074da61d70199add8ecaff9
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
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
    LOG_VIEW_CHANGE_FILTER,
    LOG_VIEW_FAILED_RELOAD,
    LOG_VIEW_RELOADED,
    LOG_VIEW_REQUEST_RELOAD
} from '../actions/types';
 
const initialState = {
    filters: {
        threshold: 'info',
        search: '',
        locationFormat: 'none',
        showStackTrace: 'false',
        maxSize: '100',
        ascendingOrder: 'false'
    },
    loading: false,
    failed: false,
    entries: []
};
 
const reducer = (state = initialState, action) => {
    switch (action.type) {
        case LOG_VIEW_REQUEST_RELOAD:
            return Object.assign({}, state, {
                loading: true,
                failed: false
            });
        case LOG_VIEW_RELOADED:
            return Object.assign({}, state, {
                loading: false,
                entries: action.payload
            });
        case LOG_VIEW_CHANGE_FILTER:
            return Object.assign({}, state, {
                filters: {
                    ...state.filters,
                    [action.payload.name]: action.payload.value
                }
            });
        case LOG_VIEW_FAILED_RELOAD: {
            return Object.assign({}, state, {
                loading: false,
                failed: true
            });
        }
        default:
            return state;
    }
};
 
export default reducer;