From 451c6a71c814a9c4d3a85636ade43f6168d3e83b Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Fri, 13 Aug 2021 17:58:38 +0200 Subject: [PATCH] replace share url with embed_url property (#431) --- .../client/js/plugins/Share.jsx | 39 +++++-------------- .../static/mapstore/configs/localConfig.json | 6 +-- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/geonode_mapstore_client/client/js/plugins/Share.jsx b/geonode_mapstore_client/client/js/plugins/Share.jsx index 72ba69ecdf..e4bd79850e 100644 --- a/geonode_mapstore_client/client/js/plugins/Share.jsx +++ b/geonode_mapstore_client/client/js/plugins/Share.jsx @@ -18,12 +18,12 @@ import Button from '@js/components/Button'; import { mapInfoSelector } from '@mapstore/framework/selectors/map'; import { layersSelector } from '@mapstore/framework/selectors/layers'; import OverlayContainer from '@js/components/OverlayContainer'; -import url from 'url'; import { isNewResource, getResourceId, getCompactPermissions, - canEditPermissions + canEditPermissions, + getResourceData } from '@js/selectors/resource'; import { updateResourceCompactPermissions } from '@js/actions/gnresource'; import FaIcon from '@js/components/FaIcon/FaIcon'; @@ -34,22 +34,6 @@ import SharePageLink from '@js/plugins/share/SharePageLink'; import ShareEmbedLink from '@js/plugins/share/ShareEmbedLink'; import { getCurrentResourcePermissionsLoading } from '@js/selectors/resourceservice'; -function getShareUrl({ - resourceId, - pathTemplate -}) { - const { - host, - protocol - } = url.parse(location.href); - const pathname = pathTemplate.replace(/\{id\}/g, resourceId); - return url.format({ - host, - protocol, - pathname - }); -} - const entriesTabs = [ { id: 'user', @@ -102,7 +86,6 @@ function Share({ width, permissionsOptions, resourceId, - pathTemplate, compactPermissions, layers, onChangePermissions, @@ -111,13 +94,11 @@ function Share({ canEdit, permissionsGroupOptions, permissionsDefaultGroupOptions, - permissionsLoading + permissionsLoading, + embedUrl }) { - const shareUrl = getShareUrl({ - resourceId, - pathTemplate - }); + const shareUrl = embedUrl; return ( {}, width: 800, @@ -238,14 +217,16 @@ const SharePlugin = connect( getCompactPermissions, layersSelector, canEditPermissions, - getCurrentResourcePermissionsLoading - ], (enabled, resourceId, mapInfo, compactPermissions, layers, canEdit, permissionsLoading) => ({ + getCurrentResourcePermissionsLoading, + getResourceData + ], (enabled, resourceId, mapInfo, compactPermissions, layers, canEdit, permissionsLoading, resource) => ({ enabled, resourceId: resourceId || mapInfo?.id, compactPermissions, layers, canEdit, - permissionsLoading + permissionsLoading, + embedUrl: resource?.embed_url })), { onClose: setControlProperty.bind(null, 'rightOverlay', 'enabled', false), diff --git a/geonode_mapstore_client/client/static/mapstore/configs/localConfig.json b/geonode_mapstore_client/client/static/mapstore/configs/localConfig.json index 06c9dfce65..f8148116b4 100644 --- a/geonode_mapstore_client/client/static/mapstore/configs/localConfig.json +++ b/geonode_mapstore_client/client/static/mapstore/configs/localConfig.json @@ -874,7 +874,6 @@ { "name": "Share", "cfg": { - "pathTemplate": "/datasets/{id}/embed", "enableGeoLimits": true } }, @@ -1728,10 +1727,7 @@ "name": "Notifications" }, { - "name": "Share", - "cfg": { - "pathTemplate": "/maps/{id}/embed" - } + "name": "Share" }, { "name": "Swipe"