Skip to content

Commit

Permalink
#10197: fix Skipping 'Configure Map' step breaks context configuration (
Browse files Browse the repository at this point in the history
#10207)

* #10197: fix Skipping 'Configure Map' step breaks context configuration
- fix the issue of beak context due to missing map config in case of edit an existing context by skip map configure tab
- write a unit test for this change

* #10197: fix Skipping 'Configure Map' step breaks context configuration
Description:
- resolve the review comments
  • Loading branch information
mahmoudadel54 committed Apr 16, 2024
1 parent 0ec0d92 commit 331e9fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
28 changes: 21 additions & 7 deletions web/client/selectors/__tests__/contextcreator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,18 @@ describe('contextcreator selectors', () => {
const source = {
map: {
present: {
zoom: 10
center: [20, 21],
maxExtent: [0, 0, 0, 0],
projection: 'EPSG:4326',
units: 'meters',
mapInfoControl: {},
zoom: 10,
mapOptions: {},
layers: [],
groups: [],
backgrounds: [],
text_search_config: undefined,
bookmark_search_config: undefined
}
},
contextcreator: {
Expand All @@ -121,11 +132,11 @@ describe('contextcreator selectors', () => {
mapConfig: {
version: 2,
map: {
center: undefined,
maxExtent: undefined,
projection: undefined,
units: undefined,
mapInfoControl: undefined,
center: [20, 21],
maxExtent: [0, 0, 0, 0],
projection: 'EPSG:4326',
units: 'meters',
mapInfoControl: {},
zoom: 10,
mapOptions: {},
layers: [],
Expand Down Expand Up @@ -176,6 +187,9 @@ describe('contextcreator selectors', () => {
metadata: { name: undefined }
};
const generatedSource = generateContextResource(source);
expect(generatedSource).toEqual(expected);
expect(generatedSource.data.mapConfig.map).toEqual(expected.data.mapConfig.map);
expect(generatedSource.data.plugins).toEqual(expected.data.plugins);
expect(generatedSource.data.plugins).toEqual(expected.data.plugins);
expect(generatedSource.data.theme).toEqual(expected.data.theme);
});
});
10 changes: 9 additions & 1 deletion web/client/selectors/contextcreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ export const prefetchedDataSelector = state => get(state, 'contextcreator.prefet
export const disableImportSelector = state => creationStepSelector(state) !== "general-settings";

export const generateContextResource = (state) => {
const mapConfig = mapSelector(state) ? mapSaveSelector(state) : {};
// in some cases, 'mapSelector' doesn't include map configuration, so check and add the map config if missing
const map = mapSelector(state);
const isMapConfigPresent = !map?.center;
let mapConfig = {};
if (isMapConfigPresent) {
mapConfig = mapConfigSelector(state) || {};
} else {
mapConfig = map ? mapSaveSelector(state) : {};
}
const plugins = pluginsSelector(state);
const context = newContextSelector(state);
const resource = resourceSelector(state);
Expand Down

0 comments on commit 331e9fd

Please sign in to comment.