Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / collection-action-set.ts
index c63144e8b96316c6ade88855fcf7d2d36b80c354..95aec9c7c94f476be3de1aa2f595040211b8d6b6 100644 (file)
@@ -38,14 +38,13 @@ const toggleFavoriteAction: ContextMenuAction = {
     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 = [
     [
         {
@@ -66,7 +65,7 @@ const commonActionSet: ContextMenuActionSet = [
             icon: CopyIcon,
             name: "Make a copy",
             execute: (dispatch, resources) => {
-                if (resources[0].isSingle) dispatch<any>(openCollectionCopyDialog(resources[0]));
+                if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
             },
         },
@@ -81,7 +80,7 @@ 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));
             },
         },
     ],
@@ -95,7 +94,7 @@ 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));
             },
         },
     ],
@@ -108,14 +107,14 @@ export const collectionActionSet: ContextMenuActionSet = [
             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,9 @@ export const collectionActionSet: ContextMenuActionSet = [
             component: ToggleTrashAction,
             name: "ToggleTrashAction",
             execute: (dispatch, resources: ContextMenuResource[]) => {
-                resources.forEach(resource => dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!)));
+                for (const resource of [...resources]) {
+                    dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
+                }
             },
         },
     ],
@@ -140,11 +141,11 @@ export const collectionAdminActionSet: ContextMenuActionSet = [
             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());
-                    })
-                );
+                    });
+                }
             },
         },
     ],
@@ -157,7 +158,9 @@ export const oldCollectionVersionActionSet: ContextMenuActionSet = [
             icon: RestoreVersionIcon,
             name: "Restore version",
             execute: (dispatch, resources) => {
-                resources.forEach(({ uuid }) => dispatch<any>(openRestoreCollectionVersionDialog(uuid)));
+                for (const resource of [...resources]) {
+                    dispatch<any>(openRestoreCollectionVersionDialog(resource.uuid));
+                }
             },
         },
     ],