Skip to content

Commit

Permalink
#1603: Fix - Download button visibility with url and view only perms (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored and giohappy committed Nov 13, 2023
1 parent 11383e7 commit 7a9eeeb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions geonode_mapstore_client/client/js/plugins/DownloadResource.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import isEmpty from 'lodash/isEmpty';
import { createPlugin } from '@mapstore/framework/utils/PluginsUtils';
import { getDownloadUrlInfo } from '@js/utils/ResourceUtils';
import { getDownloadUrlInfo, isDocumentExternalSource } from '@js/utils/ResourceUtils';
import Message from '@mapstore/framework/components/I18N/Message';
import Button from '@js/components/Button';
import tooltip from '@mapstore/framework/components/misc/enhancers/tooltip';
Expand Down Expand Up @@ -44,9 +44,13 @@ const DownloadButton = ({
const isButton = renderType !== "menuItem";
const _resource = resource ?? resourceData;
const downloadInfo = getDownloadUrlInfo(_resource);
const isExternal = isDocumentExternalSource(_resource);
const isNotAjaxSafe = !Boolean(downloadInfo?.ajaxSafe);

if ((isEmpty(_resource?.download_urls) && !_resource?.perms?.includes('download_resourcebase')) || (!isButton && isNotAjaxSafe)) {
if ((isEmpty(_resource?.download_urls) && !_resource?.perms?.includes('download_resourcebase'))
|| !_resource?.perms?.includes('download_resourcebase')
|| (!isButton && isNotAjaxSafe)
) {
return null;
}

Expand All @@ -61,7 +65,7 @@ const DownloadButton = ({
rel="noopener noreferrer"
>
{showIcon
? <FaIcon name="external-link" />
? <FaIcon name={isExternal ? "external-link" : "download"} />
: <Message msgId="gnviewer.download" />
}
</Component>
Expand Down

0 comments on commit 7a9eeeb

Please sign in to comment.