@@ -18,7 +18,12 @@ import FolderOpenIcon from "@mui/icons-material/FolderOpen";
18
18
import VisibilityIcon from "@mui/icons-material/Visibility" ;
19
19
import { observer } from "mobx-react-lite" ;
20
20
import { computed } from "mobx" ;
21
- import { type GalleryFile , idToString , type Id , Filestore } from "../useGalleryListing" ;
21
+ import {
22
+ type GalleryFile ,
23
+ idToString ,
24
+ type Id ,
25
+ Filestore ,
26
+ } from "../useGalleryListing" ;
22
27
import { useGalleryActions } from "../useGalleryActions" ;
23
28
import { useGallerySelection } from "../useGallerySelection" ;
24
29
import Dialog from "@mui/material/Dialog" ;
@@ -452,9 +457,15 @@ function ActionsMenu({
452
457
const logOutAllowed = computed ( ( ) : Result < Filestore > => {
453
458
return selection
454
459
. asSet ( )
455
- . only . toResult ( ( ) => new Error ( "Only one item may be logged out of at once." ) )
460
+ . only . toResult (
461
+ ( ) => new Error ( "Only one item may be logged out of at once." )
462
+ )
456
463
. flatMapDiscarding ( ( file ) => file . canBeLoggedOutOf )
457
- . flatMap ( ( f : GalleryFile ) => f instanceof Filestore ? Result . Ok ( f ) : Result . Error ( [ new Error ( "Cannot log out of this item." ) ] ) ) ;
464
+ . flatMap ( ( f : GalleryFile ) =>
465
+ f instanceof Filestore
466
+ ? Result . Ok ( f )
467
+ : Result . Error ( [ new Error ( "Cannot log out of this item." ) ] )
468
+ ) ;
458
469
} ) ;
459
470
const { logout } = useFilestoresEndpoint ( ) ;
460
471
@@ -695,28 +706,35 @@ function ActionsMenu({
695
706
disabled = { exportAllowed . get ( ) . isError }
696
707
/>
697
708
< EventBoundary >
698
- { Result . all ( ...selection . asSet ( ) . toArray ( ) . map ( ( { id } ) => idToString ( id ) ) ) . map ( exportIds => (
699
- < ExportDialog
700
- open = { exportOpen }
701
- onClose = { ( ) => {
702
- setExportOpen ( false ) ;
703
- setActionsMenuAnchorEl ( null ) ;
704
- } }
705
- exportSelection = { {
706
- type : "selection" ,
707
- exportTypes : selection
708
- . asSet ( )
709
- . toArray ( )
710
- . map ( ( f ) => ( f . isFolder ? "FOLDER" : "MEDIA_FILE" ) ) ,
711
- exportNames : selection
712
- . asSet ( )
713
- . toArray ( )
714
- . map ( ( { name } ) => name ) ,
715
- exportIds,
716
- } }
717
- allowFileStores = { false }
718
- />
719
- ) ) . orElse ( null ) }
709
+ { Result . all (
710
+ ...selection
711
+ . asSet ( )
712
+ . toArray ( )
713
+ . map ( ( { id } ) => idToString ( id ) )
714
+ )
715
+ . map ( ( exportIds ) => (
716
+ < ExportDialog
717
+ open = { exportOpen }
718
+ onClose = { ( ) => {
719
+ setExportOpen ( false ) ;
720
+ setActionsMenuAnchorEl ( null ) ;
721
+ } }
722
+ exportSelection = { {
723
+ type : "selection" ,
724
+ exportTypes : selection
725
+ . asSet ( )
726
+ . toArray ( )
727
+ . map ( ( f ) => ( f . isFolder ? "FOLDER" : "MEDIA_FILE" ) ) ,
728
+ exportNames : selection
729
+ . asSet ( )
730
+ . toArray ( )
731
+ . map ( ( { name } ) => name ) ,
732
+ exportIds,
733
+ } }
734
+ allowFileStores = { false }
735
+ />
736
+ ) )
737
+ . orElse ( null ) }
720
738
</ EventBoundary >
721
739
< AccentMenuItem
722
740
title = "Move to iRODS"
@@ -734,44 +752,54 @@ function ActionsMenu({
734
752
disabled = { moveToIrodsAllowed . get ( ) . isError }
735
753
aria-haspopup = "dialog"
736
754
/>
737
- { Result . all ( ...selection . asSet ( ) . toArray ( ) . map ( ( { id } ) => idToString ( id ) ) ) . map ( selectedIds => (
738
- < MoveToIrods
739
- selectedIds = { selectedIds }
740
- dialogOpen = { irodsOpen }
741
- setDialogOpen = { ( newState ) => {
742
- setIrodsOpen ( newState ) ;
743
- if ( ! newState ) {
744
- setActionsMenuAnchorEl ( null ) ;
745
- void refreshListing ( ) ;
746
- }
747
- } }
748
- />
749
- ) ) . orElse ( null ) }
755
+ { Result . all (
756
+ ...selection
757
+ . asSet ( )
758
+ . toArray ( )
759
+ . map ( ( { id } ) => idToString ( id ) )
760
+ )
761
+ . map ( ( selectedIds ) => (
762
+ < MoveToIrods
763
+ selectedIds = { selectedIds }
764
+ dialogOpen = { irodsOpen }
765
+ setDialogOpen = { ( newState ) => {
766
+ setIrodsOpen ( newState ) ;
767
+ if ( ! newState ) {
768
+ setActionsMenuAnchorEl ( null ) ;
769
+ void refreshListing ( ) ;
770
+ }
771
+ } }
772
+ />
773
+ ) )
774
+ . orElse ( null ) }
750
775
< Divider aria-orientation = "horizontal" />
751
776
{ /*
752
777
* We hide the log out option rather than disabling it because it
753
778
* is only available for filestores so doesn't apply in the vast,
754
779
* vast majority of cases.
755
780
*/ }
756
- { logOutAllowed . get ( ) . map ( filestore => (
757
- < AccentMenuItem
758
- title = "Log Out"
759
- subheader = { logOutAllowed
760
- . get ( )
761
- . map ( ( ) => "" )
762
- . orElseGet ( ( [ e ] ) => e . message ) }
763
- backgroundColor = { lighten ( theme . palette . warning . light , 0.5 ) }
764
- foregroundColor = { darken ( theme . palette . warning . dark , 0.3 ) }
765
- avatar = { < LogoutIcon /> }
766
- onClick = { ( ) => {
767
- void logout ( filestore ) . then ( ( ) => {
768
- void refreshListing ( ) ;
769
- setActionsMenuAnchorEl ( null ) ;
770
- } ) ;
771
- } }
772
- compact
773
- />
774
- ) ) . orElse ( null ) }
781
+ { logOutAllowed
782
+ . get ( )
783
+ . map ( ( filestore ) => (
784
+ < AccentMenuItem
785
+ title = "Log Out"
786
+ subheader = { logOutAllowed
787
+ . get ( )
788
+ . map ( ( ) => "" )
789
+ . orElseGet ( ( [ e ] ) => e . message ) }
790
+ backgroundColor = { lighten ( theme . palette . warning . light , 0.5 ) }
791
+ foregroundColor = { darken ( theme . palette . warning . dark , 0.3 ) }
792
+ avatar = { < LogoutIcon /> }
793
+ onClick = { ( ) => {
794
+ void logout ( filestore ) . then ( ( ) => {
795
+ void refreshListing ( ) ;
796
+ setActionsMenuAnchorEl ( null ) ;
797
+ } ) ;
798
+ } }
799
+ compact
800
+ />
801
+ ) )
802
+ . orElse ( null ) }
775
803
< AccentMenuItem
776
804
title = "Delete"
777
805
subheader = { deleteAllowed
0 commit comments