From d374e6545df83aa3951c6ad08ddc182db756ea48 Mon Sep 17 00:00:00 2001 From: Sarah Gray Date: Fri, 4 Oct 2024 09:31:44 -0500 Subject: [PATCH] WP-707: Data Depot Toolbar updates (#1455) * adding in separate canMove check for toolbar Move button * Fix linting * Fix check for hazmapper files --------- Co-authored-by: Nathan Franklin --- .../src/DatafilesToolbar/DatafilesToolbar.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/client/modules/datafiles/src/DatafilesToolbar/DatafilesToolbar.tsx b/client/modules/datafiles/src/DatafilesToolbar/DatafilesToolbar.tsx index 3bc79721e1..15689d9984 100644 --- a/client/modules/datafiles/src/DatafilesToolbar/DatafilesToolbar.tsx +++ b/client/modules/datafiles/src/DatafilesToolbar/DatafilesToolbar.tsx @@ -83,6 +83,11 @@ export const DatafilesToolbar: React.FC<{ searchInput?: React.ReactNode }> = ({ const rules = useMemo( function () { + // Check if none of the selected files end with `.hazmapper`. + const notContainingHazmapperFile = selectedFiles.every( + (file) => !file.path.endsWith('.hazmapper') + ); + // Rules for which toolbar buttons are active for a given selection. return { canPreview: @@ -91,21 +96,24 @@ export const DatafilesToolbar: React.FC<{ searchInput?: React.ReactNode }> = ({ user && selectedFiles.length === 1 && !isReadOnly && - !selectedFiles[0].path.endsWith('.hazmapper'), + notContainingHazmapperFile, canCopy: + user && selectedFiles.length >= 1 && notContainingHazmapperFile, + canMove: user && selectedFiles.length >= 1 && - !selectedFiles[0].path.endsWith('.hazmapper'), + !isReadOnly && + notContainingHazmapperFile, canTrash: user && selectedFiles.length >= 1 && !isReadOnly && - !selectedFiles[0].path.endsWith('.hazmapper'), + notContainingHazmapperFile, // Disable downloads from frontera.work until we have a non-flaky mount on ds-download. canDownload: selectedFiles.length >= 1 && system !== USER_WORK_SYSTEM && - !selectedFiles[0].path.endsWith('.hazmapper'), + notContainingHazmapperFile, }; }, [selectedFiles, isReadOnly, user, system] @@ -138,7 +146,7 @@ export const DatafilesToolbar: React.FC<{ searchInput?: React.ReactNode }> = ({ {({ onClick }) => (