-
Notifications
You must be signed in to change notification settings - Fork 383
/
dashboards.js
59 lines (55 loc) · 1.75 KB
/
dashboards.js
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
53
54
55
56
57
58
59
/*
* Copyright 2018, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import { MAPS_LIST_LOADING } from '../actions/maps';
import { LOCATION_CHANGE } from 'connected-react-router';
import { DASHBOARDS_LIST_LOADED, SET_DASHBOARDS_AVAILABLE, LOADING } from '../actions/dashboards';
import { set } from '../utils/ImmutableUtils';
import { castArray } from 'lodash';
function dashboards(state = {
enabled: false,
start: 0,
limit: 12,
errors: [],
searchText: ""
}, action) {
switch (action.type) {
case SET_DASHBOARDS_AVAILABLE: {
return set("available", action.available, state);
}
case LOCATION_CHANGE: {
return set('showModal', {}, state);
}
case DASHBOARDS_LIST_LOADED:
return {
...state,
results: action.results !== "" ? castArray(action.results) : [],
success: action.success,
totalCount: action.totalCount,
start: action.params && action.params.start,
limit: action.params && action.params.limit,
searchText: action.searchText,
options: action.options
};
case MAPS_LIST_LOADING:
return {
...state,
start: action.params && action.params.start,
limit: action.params && action.params.limit,
searchText: action.searchText
};
case LOADING: {
// anyway sets loading to true
return set(action.name === "loading" ? "loading" : `loadFlags.${action.name}`, action.value, set(
"loading", action.value, state
));
}
default:
return state;
}
}
export default dashboards;