15768: integration tests pass locally Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
authorLisa Knox <lisaknox83@gmail.com>
Wed, 11 Oct 2023 21:05:11 +0000 (17:05 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Wed, 11 Oct 2023 21:05:11 +0000 (17:05 -0400)
src/store/context-menu/context-menu-actions.ts

index 71da498f59616499f341b4f95654553776e47c3d..da6dac5db0006ca68f3cc3aaab0fdf6254bb58ee 100644 (file)
@@ -23,6 +23,7 @@ import { GroupContentsResource } from "services/groups-service/groups-service";
 import { LinkResource } from "models/link";
 import { resourceIsFrozen } from "common/frozen-resources";
 import { ProjectResource } from "models/project";
+import { filterCollectionFilesBySelection } from "store/collection-panel/collection-panel-files/collection-panel-files-state";
 
 export const contextMenuActions = unionize({
     OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition; resource: ContextMenuResource }>(),
@@ -68,7 +69,8 @@ export const openContextMenu = (event: React.MouseEvent<HTMLElement>, resource:
 
 export const openCollectionFilesContextMenu =
     (event: React.MouseEvent<HTMLElement>, isWritable: boolean) => (dispatch: Dispatch, getState: () => RootState) => {
-        const isCollectionFileSelected = JSON.stringify(getState().collectionPanelFiles).includes('"selected":true');
+        const selectedCount = filterCollectionFilesBySelection(getState().collectionPanelFiles, true).length;
+        const multiple = selectedCount > 1;
         dispatch<any>(
             openContextMenu(event, {
                 name: "",
@@ -76,11 +78,16 @@ export const openCollectionFilesContextMenu =
                 ownerUuid: "",
                 description: "",
                 kind: ResourceKind.COLLECTION,
-                menuKind: isCollectionFileSelected
-                    ? isWritable
-                        ? ContextMenuKind.COLLECTION_FILES
-                        : ContextMenuKind.READONLY_COLLECTION_FILES
-                    : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED,
+                menuKind:
+                    selectedCount > 0
+                        ? isWritable
+                            ? multiple
+                                ? ContextMenuKind.COLLECTION_FILES_MULTIPLE
+                                : ContextMenuKind.COLLECTION_FILES
+                            : multiple
+                            ? ContextMenuKind.READONLY_COLLECTION_FILES_MULTIPLE
+                            : ContextMenuKind.READONLY_COLLECTION_FILES
+                        : ContextMenuKind.COLLECTION_FILES_NOT_SELECTED,
             })
         );
     };