Skip to content

Commit

Permalink
WP-707: Data Depot Toolbar updates (#1455)
Browse files Browse the repository at this point in the history
* adding in separate canMove check for toolbar Move button

* Fix linting

* Fix check for hazmapper files

---------

Co-authored-by: Nathan Franklin <[email protected]>
  • Loading branch information
SilversunKSauri and nathanfranklin authored Oct 4, 2024
1 parent 7151b22 commit d374e65
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions client/modules/datafiles/src/DatafilesToolbar/DatafilesToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
Expand Down Expand Up @@ -138,7 +146,7 @@ export const DatafilesToolbar: React.FC<{ searchInput?: React.ReactNode }> = ({
{({ onClick }) => (
<ToolbarButton
onClick={onClick}
disabled={!rules.canRename}
disabled={!rules.canMove}
className={styles.toolbarButton}
>
<i role="none" className="fa fa-arrows" />
Expand Down

0 comments on commit d374e65

Please sign in to comment.