Skip to content

#10489: Fix 10438: Problems with GeoStory map configurations merge process#10516

Merged
allyoucanmap merged 3 commits intogeosolutions-it:masterfrom
mahmoudadel54:fix_issue_10489
Sep 5, 2024
Merged

#10489: Fix 10438: Problems with GeoStory map configurations merge process#10516
allyoucanmap merged 3 commits intogeosolutions-it:masterfrom
mahmoudadel54:fix_issue_10489

Conversation

@mahmoudadel54
Copy link
Copy Markdown
Contributor

Description

This PR fixes the issue that was mentioned in (#10426 (comment)). The issue was in this PR: #10438 in editing this part:

const resource = find(resources, { id: resourceId }) || {};
const baseMap = omit(resource.data, ['context']);
const isLegacyGeostory = (map?.layers || [])?.indexOf(null) !== -1 || (map?.groups || [])?.indexOf(null) !== -1;
const cleanedMap = {...map, layers: (map.layers || baseMap?.layers || []).map(lay => lay ? lay : undefined), groups: (map.groups || baseMap?.groups || []).map(gr => gr ? gr : undefined)}; // for better initiating cleanedMap layers in case 'map.layers = undefined' -> baseMap.layers check is added in fallBack
return { map: createMapObject(baseMap, cleanedMap, isLegacyGeostory)};

plus 'createMapObject' method to handle legacy geostory. This editing was missing handling a case of editing layers single propery like layer's title/opacity/visibility ...etc.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

#10426 (comment)

What is the current behavior?
(#10426 (comment))

What is the new behavior?
The app doesn't crash.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

@mahmoudadel54 mahmoudadel54 added this to the 2024.02.00 milestone Aug 21, 2024
@mahmoudadel54 mahmoudadel54 self-assigned this Aug 21, 2024
@mahmoudadel54 mahmoudadel54 linked an issue Aug 21, 2024 that may be closed by this pull request
3 tasks
@mahmoudadel54 mahmoudadel54 changed the title #10489: Fix #10489 Problems with GeoStory map configurations merge process #10489: Fix 10438: Problems with GeoStory map configurations merge process Aug 21, 2024
const isLegacyGeostory = (map?.layers || [])?.indexOf(null) !== -1 || (map?.groups || [])?.indexOf(null) !== -1;
// 'layersGroupsHasEmptyItems' is a flag that indicates if the geostory 'map' object in section includes empty layers/groups
// the layers/groups array may include empty items in case change layer properties e.g: opacity,title ...etc
const layersGroupsHasEmptyItems = (map?.layers || []).includes(undefined) || (map?.groups || []).includes(undefined);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation seems to solve the problem but it introducing a new set of checks for a specific configuration caused from an inconsistency on the way we update layers/groups in the settings panel.

I would like to propose a change inside the MapEditor instead. The onChange of the Editor component should update the layers or groups key of the map instead to target a specific index of the list of layers/groups. Something like the following code:

<Editor
    closeNodeEditor={closeNodeEditor}
    editNode={editNode}
    map={map}
    onChange={(path, value) => {
        const config = set({ map: { ...map } }, path, value);
        const { layers, groups } = config?.map || {};
        if (path.includes('map.layers[')) {
            onChangeMap('layers', layers);
        } else {
            onChangeMap('groups', groups);
        }
    }}/>

By modifying the way we update the layers/groups keys of the map on the setting we are going to align it to the behaviour of the TOC. If we are introducing this change we don't need the layersGroupsHasEmptyItems introduced by this PR

…ry map configurations merge process

Description:
- fix issue of crash app in geostory if user edit layer properties of existing geostory
- add unit tests due to changes
…ry map configurations merge process

Description:
- implament new approach in onChange for Editor in MapEditor file to fix the app crash issue if user edit layer properties of existing geostory
- remove the prev implemented approach
- remove unused unit tests
…ry map configurations merge process

Description:
- remove unused unit tests
@allyoucanmap allyoucanmap merged commit d9f5390 into geosolutions-it:master Sep 5, 2024
@allyoucanmap
Copy link
Copy Markdown
Contributor

@ElenaGallo please test this on dev and let us know when we can backport on 2024.02.xx, thanks

@tdipisa tdipisa added the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Sep 5, 2024
@ElenaGallo
Copy link
Copy Markdown
Contributor

Test passed, @mahmoudadel54 please backport to 2024.02.xx. Thanks

@mahmoudadel54
Copy link
Copy Markdown
Contributor Author

Test passed, @mahmoudadel54 please backport to 2024.02.xx. Thanks

@ElenaGallo
backport is done ---> #10539

@tdipisa tdipisa removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with GeoStory map configurations merge process

4 participants