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

geosolutions-it / MapStore2 / 14797665772

02 May 2025 02:55PM UTC coverage: 76.933% (-0.06%) from 76.991%
14797665772

Pull #11067

github

web-flow
Merge 99dcd7f92 into d28bf7035
Pull Request #11067: Fix #10966 basic auth for services

30858 of 48053 branches covered (64.22%)

104 of 172 new or added lines in 24 files covered. (60.47%)

3 existing lines in 3 files now uncovered.

38384 of 49893 relevant lines covered (76.93%)

35.93 hits per line

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

79.37
/web/client/reducers/catalog.js
1
/*
2
 * Copyright 2017, 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

9
import {
10
    RECORD_LIST_LOADED,
11
    RECORD_LIST_LOAD_ERROR,
12
    CHANGE_CATALOG_FORMAT,
13
    ADD_LAYER_ERROR,
14
    RESET_CATALOG,
15
    CHANGE_SELECTED_SERVICE,
16
    CHANGE_CATALOG_MODE,
17
    CHANGE_TITLE,
18
    CHANGE_TEXT,
19
    CHANGE_SERVICE_PROPERTY,
20
    CHANGE_TYPE,
21
    CHANGE_URL,
22
    CHANGE_SERVICE_FORMAT,
23
    FOCUS_SERVICES_LIST,
24
    ADD_CATALOG_SERVICE,
25
    UPDATE_CATALOG_SERVICES,
26
    DELETE_CATALOG_SERVICE,
27
    SAVING_SERVICE,
28
    CHANGE_METADATA_TEMPLATE,
29
    SET_LOADING,
30
    TOGGLE_THUMBNAIL,
31
    TOGGLE_TEMPLATE,
32
    TOGGLE_ADVANCED_SETTINGS,
33
    FORMAT_OPTIONS_LOADING,
34
    SHOW_FORMAT_ERROR,
35
    SET_FORMAT_OPTIONS,
36
    NEW_SERVICE_STATUS,
37
    INIT_PLUGIN
38
} from '../actions/catalog';
39
import {
40
    CLEAR_SECURITY,
41
    SET_CREDENTIALS
42
} from '../actions/security';
43

44
import { MAP_CONFIG_LOADED } from '../actions/config';
45
import { set } from '../utils/ImmutableUtils';
46
import { isNil } from 'lodash';
47
import assign from 'object-assign';
48
import uuid from 'uuid';
49

50
export const emptyService = {
1✔
51
    url: "",
52
    type: "wms",
53
    title: "",
54
    isNew: true,
55
    autoload: false,
56
    showAdvancedSettings: false,
57
    showTemplate: false,
58
    hideThumbnail: false,
59
    metadataTemplate: "<p>${description}</p>"
60
};
61

62
function catalog(state = {
15✔
63
    "default": {
64
        services: {},
65
        selectedService: "",
66
        newService: {}
67
    },
68
    delayAutoSearch: 1000,
69
    loading: false,
70
    showFormatError: false,
71
    pageSize: 4,
72
    services: {},
73
    selectedService: "",
74
    newService: {}
75
}, action) {
76
    switch (action.type) {
85!
77
    case INIT_PLUGIN:
78
        return {
5✔
79
            ...state,
80
            editingAllowedRoles: action?.options?.editingAllowedRoles || state.editingAllowedRoles,
6✔
81
            editingAllowedGroups: action?.options?.editingAllowedGroups || state.editingAllowedGroups
9✔
82
        };
83
    case SAVING_SERVICE:
84
        return {
1✔
85
            ...state,
86
            saving: action.status
87
        };
88
    case RECORD_LIST_LOADED:
89
        return assign({}, state, {
1✔
90
            result: action.result,
91
            searchOptions: action.searchOptions,
92
            loadingError: null,
93
            layerError: null,
94
            loading: false
95
        });
96
    case RESET_CATALOG:
97
        return assign({}, state, {
4✔
98
            result: null,
99
            loadingError: null,
100
            searchOptions: null/*
101
                MV: saida added but maybe they are unused,
102
                at least action.format doesnt exist in the action,
103

104
                format: action.format,
105
                layerError: null*/
106
        });
107
    case RECORD_LIST_LOAD_ERROR:
108
        return assign({}, state, {
1✔
109
            result: null,
110
            searchOptions: null,
111
            loadingError: action.error,
112
            loading: false,
113
            layerError: null
114
        });
115
    case CHANGE_CATALOG_FORMAT:
116
        return assign({}, state, {
1✔
117
            result: null,
118
            loadingError: null,
119
            format: action.format,
120
            layerError: null
121
        });
122
    case ADD_LAYER_ERROR:
123
        return assign({}, state, {layerError: action.error});
1✔
124
    case CHANGE_CATALOG_MODE:
125
        return assign({}, state, {
7✔
126
            newService: action.isNew ? emptyService : assign({}, state.services && state.services[state.selectedService || ""] || {}, {oldService: state.selectedService || ""}),
40✔
127
            mode: action.mode,
128
            result: null,
129
            showFormatError: false,
130
            loadingError: null,
131
            layerError: null});
132
    case MAP_CONFIG_LOADED: {
133
        if (state && !isNil(state.default)) {
1!
134
            if (action.config && !isNil(action.config.catalogServices)) {
1!
135
                return assign({}, state, {services: action.config.catalogServices.services, selectedService: action.config.catalogServices.selectedService });
1✔
136
            }
137
            return assign({}, state, {services: state.default.services, selectedService: state.default.selectedService });
×
138
        }
139
        return state;
×
140
    }
141
    case FOCUS_SERVICES_LIST:
142
        return set("openCatalogServiceList", action.status, state);
1✔
143
    case CHANGE_TEXT:
144
        return set("searchOptions.text", action.text, state);
1✔
145
    case CHANGE_SERVICE_PROPERTY: {
146
        return  set(`newService.${action.property}`, action.value, state);
2✔
147
    }
148
    case CHANGE_TITLE:
149
        return set("newService.title", action.title, state);
1✔
150
    case CHANGE_URL:
151
        return set("newService.url", action.url, set("showFormatError", false, state));
1✔
152
    case CHANGE_SERVICE_FORMAT:
153
        return set("newService.format", action.format, state);
1✔
154
    case CHANGE_TYPE: {
155
        const type = action.newType.toLowerCase();
3✔
156
        let templateOptions = {};
3✔
157
        if (type !== "csw") {
3✔
158
            // reset the template options
159
            templateOptions = {showTemplate: false, metadataTemplate: ""};
2✔
160
        }
161
        return assign({}, state, {newService: assign({}, state.newService, {type, ...templateOptions})});
3✔
162
    }
163
    case ADD_CATALOG_SERVICE: {
164
        const { isNew, ...service } = action.service;
2✔
165
        const selectedService = isNew ? service.title + uuid() : state.selectedService;
2✔
166
        const newServices = assign({}, state.services, { [selectedService]: service});
2✔
167
        return assign({}, state, {
2✔
168
            services: newServices,
169
            selectedService,
170
            mode: "view",
171
            result: null,
172
            loadingError: null,
173
            searchOptions: assign({}, state.searchOptions, {
174
                text: ""
175
            }),
176
            layerError: null
177
        });
178
    }
179
    case UPDATE_CATALOG_SERVICES: {
180
        return {...state,
×
181
            services: action.services
182
        };
183
    }
184
    case CHANGE_SELECTED_SERVICE: {
185
        if (action.service !== state.selectedService) {
2✔
186
            return assign({}, state, {
1✔
187
                selectedService: action.service,
188
                result: null,
189
                loadingError: null,
190
                layerError: null
191
            });
192
        }
193
        return state;
1✔
194
    }
195
    case DELETE_CATALOG_SERVICE: {
196
        let newServices;
197
        let selectedService = "";
1✔
198
        newServices = assign({}, state.services);
1✔
199
        delete newServices[action.service];
1✔
200
        if (Object.keys(newServices).length) {
1!
201
            selectedService = newServices[Object.keys(newServices)[0]].title;
×
202
        }
203
        return assign({}, state, {
1✔
204
            services: newServices,
205
            selectedService,
206
            mode: "view",
207
            result: null,
208
            loadingError: null,
209
            layerError: null
210
        });
211
    }
212
    case TOGGLE_THUMBNAIL: {
213
        return set("newService.hideThumbnail", !state.newService.hideThumbnail, state);
2✔
214
    }
215
    case SET_LOADING: {
216
        return set("loading", action.loading, state);
3✔
217
    }
218
    case CHANGE_METADATA_TEMPLATE: {
219
        return set("newService.metadataTemplate", action.metadataTemplate, state);
1✔
220
    }
221
    case TOGGLE_TEMPLATE: {
222
        let newState = set("newService.showTemplate", !state.newService.showTemplate, state);
2✔
223
        if (newState.newService.showTemplate) {
2✔
224
            newState = set("newService.metadataTemplate", newState.newService.metadataTemplate || "<p>${description}</p>", newState);
1✔
225
        }
226
        return newState;
2✔
227
    }
228
    case TOGGLE_ADVANCED_SETTINGS: {
229
        return set("newService.showAdvancedSettings", !state.newService.showAdvancedSettings, state);
2✔
230
    }
231
    case FORMAT_OPTIONS_LOADING: {
232
        return set("formatsLoading", action.loading, state);
1✔
233
    }
234
    case SHOW_FORMAT_ERROR: {
235
        return set("showFormatError", action.status, state);
×
236
    }
237
    case SET_FORMAT_OPTIONS: {
238
        return set("newService.supportedFormats", action.formats, set("newService.formatUrlUsed", action.url, state));
1✔
239
    }
240
    case NEW_SERVICE_STATUS: {
241
        return set("isNewServiceAdded", action.status, state);
×
242
    }
243
    case SET_CREDENTIALS: {
244
        const newService = action.protectedService;
1✔
245
        const newState = set("newService", newService, state);
1✔
246
        return newState;
1✔
247
    }
248
    case CLEAR_SECURITY: {
NEW
249
        const id = action.protectedId;
×
NEW
250
        const services = Object.keys(state.services).reduce((p, service) => {
×
NEW
251
            const item = state.services[service];
×
NEW
252
            const newItem = item?.protectedId === id ? {
×
253
                ...item,
254
                protectedId: undefined
255
            } : item;
NEW
256
            return {
×
257
                ...p,
258
                [service]: newItem};
259
        }, {});
NEW
260
        const newState = set("services", services, state);
×
NEW
261
        return newState;
×
262
    }
263
    default:
264
        return state;
35✔
265
    }
266
}
267

268
export default catalog;
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