21128: renamed overloaded context menu types Arvados-DCO-1.1-Signed-off-by: Lisa...
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / collection-action-set.ts
index 86c850f08f717db536769e2c87a62428ea6a0292..264ca5c0ca1596f4c19b8443e008a6d5878ccff6 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { ContextMenuAction, ContextMenuActionSet } from "../context-menu-action-set";
+import { ContextMenuActionItem, ContextMenuActionItemSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "store/favorites/favorites-actions";
 import {
@@ -34,19 +34,18 @@ import { togglePublicFavorite } from "store/public-favorites/public-favorites-ac
 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
 
-const toggleFavoriteAction: ContextMenuAction = {
+const toggleFavoriteAction: ContextMenuActionItem = {
     component: ToggleFavoriteAction,
     name: "ToggleFavoriteAction",
     execute: (dispatch, resources) => {
-        resources.forEach(resource =>
+        for (const resource of [...resources]) {
             dispatch<any>(toggleFavorite(resource)).then(() => {
                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
-            })
-        );
+            });
+        }
     },
 };
-
-const commonActionSet: ContextMenuActionSet = [
+const commonActionSet: ContextMenuActionItemSet = [
     [
         {
             icon: OpenIcon,
@@ -66,7 +65,7 @@ const commonActionSet: ContextMenuActionSet = [
             icon: CopyIcon,
             name: "Make a copy",
             execute: (dispatch, resources) => {
-                if (resources[0].isSingle || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
+                if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
             },
         },
@@ -81,13 +80,13 @@ const commonActionSet: ContextMenuActionSet = [
             icon: AdvancedIcon,
             name: "API Details",
             execute: (dispatch, resources) => {
-                resources.forEach(resource => dispatch<any>(openAdvancedTabDialog(resource.uuid)));
+                dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
             },
         },
     ],
 ];
 
-export const readOnlyCollectionActionSet: ContextMenuActionSet = [
+export const readOnlyCollectionActionSet: ContextMenuActionItemSet = [
     [
         ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
         toggleFavoriteAction,
@@ -95,27 +94,27 @@ export const readOnlyCollectionActionSet: ContextMenuActionSet = [
             icon: FolderSharedIcon,
             name: "Open with 3rd party client",
             execute: (dispatch, resources) => {
-                resources.forEach(resource => dispatch<any>(openWebDavS3InfoDialog(resource.uuid)));
+                dispatch<any>(openWebDavS3InfoDialog(resources[0].uuid));
             },
         },
     ],
 ];
 
-export const collectionActionSet: ContextMenuActionSet = [
+export const collectionActionSet: ContextMenuActionItemSet = [
     [
         ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
         {
             icon: RenameIcon,
             name: "Edit collection",
             execute: (dispatch, resources) => {
-                resources.forEach(resource => dispatch<any>(openCollectionUpdateDialog(resource)));
+                dispatch<any>(openCollectionUpdateDialog(resources[0]));
             },
         },
         {
             icon: ShareIcon,
             name: "Share",
             execute: (dispatch, resources) => {
-                resources.forEach(({ uuid }) => dispatch<any>(openSharingDialog(uuid)));
+                dispatch<any>(openSharingDialog(resources[0].uuid));
             },
         },
         {
@@ -127,7 +126,7 @@ export const collectionActionSet: ContextMenuActionSet = [
             component: ToggleTrashAction,
             name: "ToggleTrashAction",
             execute: (dispatch, resources: ContextMenuResource[]) => {
-                for (const resource of resources) {
+                for (const resource of [...resources]) {
                     dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
                 }
             },
@@ -135,31 +134,31 @@ export const collectionActionSet: ContextMenuActionSet = [
     ],
 ];
 
-export const collectionAdminActionSet: ContextMenuActionSet = [
+export const collectionAdminActionSet: ContextMenuActionItemSet = [
     [
         ...collectionActionSet.reduce((prev, next) => prev.concat(next), []),
         {
             component: TogglePublicFavoriteAction,
             name: "TogglePublicFavoriteAction",
             execute: (dispatch, resources) => {
-                resources.forEach(resource =>
+                for (const resource of [...resources]) {
                     dispatch<any>(togglePublicFavorite(resource)).then(() => {
                         dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
-                    })
-                );
+                    });
+                }
             },
         },
     ],
 ];
 
-export const oldCollectionVersionActionSet: ContextMenuActionSet = [
+export const oldCollectionVersionActionSet: ContextMenuActionItemSet = [
     [
         ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
         {
             icon: RestoreVersionIcon,
             name: "Restore version",
             execute: (dispatch, resources) => {
-                for (const resource of resources) {
+                for (const resource of [...resources]) {
                     dispatch<any>(openRestoreCollectionVersionDialog(resource.uuid));
                 }
             },