Skip to content

Commit 5547e7e

Browse files
authored
Update Share URL return UUID URL (#2102)
1 parent 26bb132 commit 5547e7e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

geonode_mapstore_client/client/js/plugins/ResourceDetails/components/DetailsToolbar.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip';
1616
import ResourceStatus from '@mapstore/framework/plugins/ResourcesCatalog/components/ResourceStatus';
1717
import useIsMounted from '@mapstore/framework/hooks/useIsMounted';
1818
import FlexBox from '@mapstore/framework/components/layout/FlexBox';
19+
import { formatResourceLinkUrl } from '@js/utils/ResourceUtils';
1920

2021
const ButtonWithTooltip = tooltip(Button);
2122
const CopyToClipboard = tooltip(CopyToClipboardCmp);
@@ -54,13 +55,6 @@ function DetailsToolbarButton({
5455
);
5556
}
5657

57-
function formatResourceLinkUrl(resource) {
58-
if (resource?.uuid) {
59-
return window.location.href.replace(/#.+$/, `uuid/${resource.uuid}`);
60-
}
61-
return window.location.href;
62-
}
63-
6458
function DetailsToolbar({
6559
resource,
6660
items = [],

geonode_mapstore_client/client/js/plugins/Share.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
getViewedResourceType
2727
} from '@js/selectors/resource';
2828
import {
29-
cleanUrl,
29+
formatResourceLinkUrl,
3030
getDownloadUrlInfo,
3131
getResourceTypesInfo
3232
} from '@js/utils/ResourceUtils';
@@ -42,18 +42,15 @@ function Share({
4242
onClose,
4343
resourceType,
4444
embedUrl,
45-
downloadUrl
45+
downloadUrl,
46+
pageUrl
4647
}) {
47-
const pageUrl = cleanUrl(window.location.href);
48-
4948
return (
5049
<OverlayContainer
5150
enabled={enabled}
5251
className="gn-overlay-wrapper"
5352
>
54-
<section
55-
className="gn-share-panel"
56-
>
53+
<section className="gn-share-panel">
5754
<div className="gn-share-panel-head">
5855
<h2><Message msgId="gnviewer.shareThisResource" /></h2>
5956
<Button className="square-button" onClick={() => onClose()}>
@@ -91,7 +88,8 @@ const SharePlugin = connect(
9188
enabled,
9289
embedUrl: getEmbedUrl(resource),
9390
resourceType: type,
94-
downloadUrl: getDownloadUrlInfo(resource)?.url
91+
downloadUrl: getDownloadUrlInfo(resource)?.url,
92+
pageUrl: formatResourceLinkUrl(resource)
9593
})),
9694
{
9795
onClose: setControlProperty.bind(null, 'rightOverlay', 'enabled', false)

geonode_mapstore_client/client/js/utils/ResourceUtils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ export const getDownloadUrlInfo = (resource) => {
779779
return hrefUrl;
780780
};
781781

782+
export const formatResourceLinkUrl = (resource) => {
783+
let href = window.location.href;
784+
if (resource?.uuid) {
785+
href = href.replace(/#.+$/, `uuid/${resource.uuid}`);
786+
}
787+
return cleanUrl(href);
788+
};
789+
782790
export const getCataloguePath = (path = '') => {
783791
const catalogPagePath = getGeoNodeLocalConfig('geoNodeSettings.catalogPagePath');
784792
if (!isEmpty(catalogPagePath)) {

0 commit comments

Comments
 (0)