Skip to content

Commit

Permalink
hide move button on public systems; hide copy button for unauth'd use…
Browse files Browse the repository at this point in the history
…rs (#1379)
  • Loading branch information
jarosenb authored Jul 29, 2024
1 parent ab6dc48 commit d6bf8a9
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useQueryClient } from '@tanstack/react-query';
import {
TFileListing,
useAuthenticatedUser,
useFileListingRouteParams,
useFilePreview,
} from '@client/hooks';
Expand Down Expand Up @@ -44,6 +45,13 @@ export const PreviewModalBody: React.FC<{
handleCancel();
}, [handleCancel, queryClient]);

const { user } = useAuthenticatedUser();
const isReadOnly = [
'designsafe.storage.published',
'designsafe.storage.community',
'nees.public',
].includes(selectedFile.system);

if (!isOpen) return null;

return (
Expand Down Expand Up @@ -72,7 +80,7 @@ export const PreviewModalBody: React.FC<{
>
{!selectedFile.path.endsWith('.hazmapper') && (
<>
{scheme === 'private' && api === 'tapis' && (
{!isReadOnly && api === 'tapis' && (
<MoveModal
api={api}
system={selectedFile.system}
Expand All @@ -89,19 +97,21 @@ export const PreviewModalBody: React.FC<{
</MoveModal>
)}

<CopyModal
api={api}
system={selectedFile.system}
path={listingPath}
selectedFiles={[selectedFile]}
>
{({ onClick }) => (
<Button onClick={onClick}>
<i role="none" className="fa fa-copy" />
<span>&nbsp;Copy</span>
</Button>
)}
</CopyModal>
{user && (
<CopyModal
api={api}
system={selectedFile.system}
path={listingPath}
selectedFiles={[selectedFile]}
>
{({ onClick }) => (
<Button onClick={onClick}>
<i role="none" className="fa fa-copy" />
<span>&nbsp;Copy</span>
</Button>
)}
</CopyModal>
)}
<DownloadModal
api={api}
system={selectedFile.system}
Expand Down

0 comments on commit d6bf8a9

Please sign in to comment.