• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 19710972030

26 Nov 2025 03:38PM UTC coverage: 76.665% (-0.3%) from 76.929%
19710972030

Pull #11119

github

web-flow
Fix maven publish (#11739)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32272 of 50209 branches covered (64.28%)

3 of 3 new or added lines in 2 files covered. (100.0%)

3018 existing lines in 249 files now uncovered.

40157 of 52380 relevant lines covered (76.66%)

37.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.36
/web/client/reducers/config.js
1
/**
2
 * Copyright 2015, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8
import { LOCATION_CHANGE } from 'connected-react-router';
9

10
import {
11
    MAP_CONFIG_LOADED,
12
    MAP_INFO_LOAD_START,
13
    MAP_INFO_LOADED,
14
    MAP_INFO_LOAD_ERROR,
15
    MAP_CONFIG_LOAD_ERROR,
16
    MAP_SAVE_ERROR,
17
    MAP_SAVED,
18
    RESET_MAP_SAVE_ERROR
19
} from '../actions/config';
20

21
import { DETAILS_LOADED } from '../actions/details';
22
import { MAP_TYPE_CHANGED, VISUALIZATION_MODE_CHANGED } from '../actions/maptype';
23
import ConfigUtils from '../utils/ConfigUtils';
24
import { set, unset } from '../utils/ImmutableUtils';
25
import { normalizeLayer } from '../utils/LayersUtils';
26
import { castArray } from 'lodash';
27
import {
28
    getVisualizationModeFromMapLibrary,
29
    VisualizationModes
30
} from '../utils/MapTypeUtils';
31

32
function mapConfig(state = null, action) {
6✔
33
    let map;
34
    switch (action.type) {
86!
35
    case LOCATION_CHANGE: {
UNCOV
36
        if (action?.payload?.action === 'REPLACE') {
×
37
            return state;
×
38
        }
UNCOV
39
        return {
×
40
            ...state,
41
            mapInitialConfig: {}
42
        };
43
    }
44
    case MAP_CONFIG_LOADED:
45
        let size = state && state.map && state.map.present && state.map.present.size || state && state.map && state.map.size;
15!
46
        // bbox is taken from the state to keep widgets having correct dataset after map is saved or saved as.
47
        // bbox is not getting written to the map configuration on backend
48
        let bbox = state && state.map && state.map.present && state.map.present.bbox || state && state.map && state.map.bbox;
15!
49

50
        let hasVersion = action.config && action.config.version >= 2;
15✔
51
        // we get from the configuration what will be used as the initial state
52
        let mapState = action.legacy && !hasVersion ? ConfigUtils.convertFromLegacy(action.config) : ConfigUtils.normalizeConfig(action.config.map);
15!
53

54
        let newMapState = {
15✔
55
            ...mapState,
56
            layers: mapState.layers.map( l => {
57
                if (l.group === "background" && (l.type === "ol" || l.type === "OpenLayers.Layer")) {
23✔
58
                    l.type = "empty";
2✔
59
                }
60
                return l;
23✔
61
            }).map(normalizeLayer),
62
            mapConfigRawData: { ...action.config }
63
        };
64
        // if map is loaded from an already saved map keep the same id
65
        let mapId = state?.map?.mapId || state?.map?.present?.mapId;
15✔
66
        mapId = action.config?.fileName && mapId ? mapId : action.mapId;
15✔
67
        newMapState.map = Object.assign({}, newMapState.map, {mapId, size, bbox, version: hasVersion ? action.config.version : 1});
15✔
68
        // we store the map initial state for future usage
69
        return Object.assign({}, newMapState, {mapInitialConfig: {...newMapState.map, mapId: action.mapId}});
15✔
70
    case MAP_CONFIG_LOAD_ERROR:
71
        return {
1✔
72
            loadingError: {...action.error, mapId: action.mapId}
73
        };
74
    case MAP_INFO_LOAD_START:
75
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
1!
76
        if (map && map.mapId === action.mapId) {
1!
77
            map = Object.assign({}, map, {loadingInfo: true});
1✔
78
            return Object.assign({}, state, {map: map});
1✔
79
        }
UNCOV
80
        return state;
×
81
    case MAP_INFO_LOAD_ERROR: {
UNCOV
82
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
×
83
        if (map && map.mapId === action.mapId) {
×
84
            map = Object.assign({}, map, {loadingInfoError: action.error, loadingInfo: false});
×
85
            return Object.assign({}, state, {map: map});
×
86
        }
UNCOV
87
        return state;
×
88
    }
89
    case MAP_INFO_LOADED:
90
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
5!
91
        if (map && (`${map.mapId}` === `${action.mapId}` || !map.mapId && !action.mapId)) {
5!
92
            map = Object.assign({}, map, {info: action.merge ? {
5✔
93
                ...map.info,
94
                ...action.info
95
            } : action.info, loadingInfo: false});
96
            return Object.assign({}, state, {map: map});
5✔
97
        }
UNCOV
98
        return state;
×
99
    case DETAILS_LOADED:
100
        let dashboardResource = state.dashboard?.resource;
2✔
101
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
2✔
102
        if (map && map.mapId?.toString() === action.id.toString()) {
2✔
103
            map = {
1✔
104
                ...map,
105
                info: {
106
                    ...map.info,
107
                    attributes: {
108
                        ...map.info?.attributes,
109
                        details: action.detailsUri || map.info?.attributes?.details,
1!
110
                        detailsSettings: action.detailsSettings || map.info?.attributes?.detailsSettings
2✔
111
                    }
112
                }
113
            };
114
            return Object.assign({}, state, {map: map});
1✔
115
        } else if (dashboardResource && dashboardResource.id?.toString() === action.id.toString()) {
1!
116
            dashboardResource = Object.assign({}, dashboardResource, {
1✔
117
                attributes:
118
                    Object.assign({}, dashboardResource.attributes, {
119
                        details: action.detailsUri,
120
                        detailsSettings: action.detailsSettings
121
                    })
122
            });
123
            return Object.assign({}, state, {dashboard: {
1✔
124
                ...state.dashboard, resource: dashboardResource
125
            }});
126
        }
UNCOV
127
        return state;
×
128
    case MAP_SAVE_ERROR:
UNCOV
129
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
×
130
        map = set('mapSaveErrors', castArray(action.error), map);
×
131
        return Object.assign({}, state, {map: map});
×
132
    case MAP_SAVED:
UNCOV
133
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
×
134
        map = unset('mapSaveErrors', map);
×
135
        return Object.assign({}, state, {map: map});
×
136
    case RESET_MAP_SAVE_ERROR:
UNCOV
137
        map = state?.map?.present || state?.map;
×
138
        map = unset('mapSaveErrors', map);
×
139
        return {...state, map};
×
140
    case VISUALIZATION_MODE_CHANGED:
141
    case MAP_TYPE_CHANGED:
UNCOV
142
        map = state && state.map && state.map.present ? state.map.present : state && state.map;
×
143
        const visualizationMode = action.mapType !== undefined
×
144
            ? getVisualizationModeFromMapLibrary(action.mapType)
145
            : action.visualizationMode || VisualizationModes._2D;
×
UNCOV
146
        map = set('visualizationMode', visualizationMode, map);
×
147
        return { ...state, map };
×
148
    default:
149
        return state;
62✔
150
    }
151
}
152

153
export default mapConfig;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc