georchestra / georchestra

This is the main geOrchestra Spatial Data Infrastructure repository, which hosts the source code.
http://www.georchestra.org/
GNU General Public License v3.0
129 stars 95 forks source link

[geonetwork/mapstore] browser history is broken #3956

Closed jeanpommier closed 4 months ago

jeanpommier commented 1 year ago

Starting on GN, on a metadata record view. I click on the 'Add to map' link. It brings me to Mapstore, showing the layer. On my browser, if I click on the Previous arrow (browser navigation history), it brings me back... not to the metadata record view but to the https://georchestra-127-0-1-1.traefik.me/geonetwork/srv/eng/catalog.search#/map?add=%255Bnull%255D path, which is not resolved (blank page)

Expected behaviour It should bring me back to the metadata view page

Context Texted on Firefox 102.10.0esr and Chrome 94.0.4606.81

jeanpommier commented 1 year ago

I believe this intermediate map is obtained in https://github.com/georchestra/geonetwork/blob/83a493242fb8bde91d9e45c9e4e5e56a4be258c1/web-ui/src/main/resources/catalog/components/common/map/externalviewer.js#L131

@jahow , you told me that maybe this was just a missing parameter that would make it not counted in the browser history. Do you see a straight simple fix ?

jeanpommier commented 1 year ago

Interestingly, it's not happening when clicking on a WFS link.

But definitely happening when clicking on a WMS link. Weird

I suspect this is related to the way WFS links are treated differently than WMS links in https://github.com/geonetwork/core-geonetwork/blob/main/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js#L132

jahow commented 1 year ago

This is where the broken URL is created: https://github.com/geonetwork/core-geonetwork/blob/c5e5ab32ebfc843ab09d6153e4d021bf7f02fcba/web-ui/src/main/resources/catalog/views/default/module.js#L419-L421

The following commit apparently changed the way adding a WMS layer on the map is done: https://github.com/geonetwork/core-geonetwork/commit/195b84950778f1782326ce0ab77f6671cf178f68

More specifically this diff: https://github.com/geonetwork/core-geonetwork/commit/195b84950778f1782326ce0ab77f6671cf178f68#diff-9c8322849a7569e40843e0cc94fac6adb4bb2186f8440c04e0e948875c2ab840

You can see here how the redirection to mapstore is done in the buildAddToMapConfig function and not in the addMdLayerToMap function any more. This means that while the redirection still happens, an intermediate url is pushed.

This was integrated as part of the huge "titellus merge" so no wonder no one noticed it.

I don't have any inspiration for fixing this properly right now, sorry... but it shouldn't be too hard.

fxprunayre commented 1 year ago

This was integrated as part of the huge "titellus merge" so no wonder no one noticed it.

Looks like some users noticed it. Not 100% sure this https://github.com/geonetwork/core-geonetwork/pull/6548 will fix your issue (and is maybe not the best way to fix it), but don't hesitate to consider reviewing small pull requests too.

jahow commented 1 year ago

This look like an acceptable fix.

f-necas commented 4 months ago

Works, fixed has been implemented in last georchestra/gn version