Skip to content

Commit

Permalink
Copy UUID link instead of detail_url
Browse files Browse the repository at this point in the history
The UUID link provides the user a more generic permalink (no database id
involved) which redirects to the resource, anyway.

Requires UUID resolver at the GeoNode backend.
see GeoNode/geonode#10375
  • Loading branch information
ridoo committed Mar 24, 2023
1 parent f6a02ef commit 847480e
Showing 1 changed file with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,36 @@ const EditTitle = ({ title, onEdit, disabled }) => {
</div>);
};

function formatResourceLinkUrl(resourceUrl = '') {
if (resourceUrl.indexOf('http') === 0) {
return resourceUrl;
function formatResourceLinkUrl(resource) {
if (resource?.uuid) {
return window.location.href.replace(/#.+$/, `uuid/${resource.uuid}`);
}
return window.location.href;
}

const EditAbstract = ({ abstract, onEdit, tagName, disabled }) => (
<div className="editContainer">
<TextEditable
tagName={tagName}
onEdit={onEdit}
text={abstract}
disabled={disabled}
/>
</div>

);


const EditThumbnail = ({ image, onEdit, thumbnailUpdating }) => (
<div className="editContainer imagepreview">
<ThumbnailEditable onEdit={onEdit} defaultImage={image} />
{thumbnailUpdating && <div className="gn-details-thumbnail-loader">
<Loader size={50} />
</div>
}
</div>
);

const ResourceMessage = ({ type, pathname, formatHref }) => {
return (
<span className="gn-details-panel-origin">
Expand Down Expand Up @@ -123,21 +146,21 @@ const DetailsPanelTools = ({
<FaIcon name="download" />
</Button>}

{detailUrl && <CopyToClipboard
<CopyToClipboard
tooltipPosition="top"
tooltipId={
copiedResourceLink
? 'gnhome.copiedResourceUrl'
: 'gnhome.copyResourceUrl'
}
text={formatResourceLinkUrl(detailUrl)}
text={formatResourceLinkUrl(resource)}
>
<Button
variant="default"
onClick={handleCopyPermalink}>
<FaIcon name="share-alt" />
</Button>
</CopyToClipboard>}
</CopyToClipboard>
{detailUrl && !editThumbnail && <Button
variant="primary"
href={(resourceCanPreviewed || canView) ? detailUrl : metadataDetailUrl}
Expand Down

0 comments on commit 847480e

Please sign in to comment.