Skip to content

Commit

Permalink
geosolutions-it#8588: Fix - Map config load on no widget config (geos…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored Oct 20, 2022
1 parent 3a4b23a commit d5ad101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions web/client/reducers/__tests__/widgets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ describe('Test the widgets reducer', () => {
const state = widgets(undefined, configureMap({widgetsConfig: {widgets: [{id: "1"}]}}));
expect(state.containers[DEFAULT_TARGET].widgets.length).toBe(1);
});
it('configureMap with no widget', () => {
const state = widgets(undefined, configureMap({}));
expect(state.containers[DEFAULT_TARGET].widgets).toBeFalsy();
});
it('changeLayout', () => {
const L = {lg: []};
const AL = {md: []};
Expand Down
8 changes: 5 additions & 3 deletions web/client/reducers/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ function widgetsReducer(state = emptyState, action) {
...data
}, state);
case MAP_CONFIG_LOADED:
const { widgetsConfig } = (action.config || {});
const updatedWidgetsConfig = convertToCompatibleWidgets(widgetsConfig);
let { widgetsConfig } = (action.config || {});
if (widgetsConfig) {
widgetsConfig = convertToCompatibleWidgets(widgetsConfig);
}
return set(`containers[${DEFAULT_TARGET}]`, {
...updatedWidgetsConfig
...widgetsConfig
}, state);
case CHANGE_LAYOUT: {
return set(`containers[${action.target}].layout`, action.layout)(set(`containers[${action.target}].layouts`, action.allLayouts, state));
Expand Down

0 comments on commit d5ad101

Please sign in to comment.