Merge branch '17018-readonly-file-actions-fix'
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / collection-action-set.ts
index b3fdc3fbab642561d823cddd003a70b9ab288149..7fa6f2241f5144f6c21eeefef5eb2375d737fd09 100644 (file)
@@ -5,32 +5,18 @@
 import { ContextMenuActionSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
-import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "~/components/icon/icon";
+import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, AdvancedIcon } from "~/components/icon/icon";
 import { openCollectionUpdateDialog } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/collections/collection-move-actions';
 import { openCollectionCopyDialog } from "~/store/collections/collection-copy-actions";
+import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
+import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
+import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
+import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
+import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
 
-export const collectionActionSet: ContextMenuActionSet = [[
-    {
-        icon: RenameIcon,
-        name: "Edit collection",
-        execute: (dispatch, resource) => {
-            dispatch<any>(openCollectionUpdateDialog(resource));
-        }
-    },
-    {
-        icon: ShareIcon,
-        name: "Share",
-        execute: (dispatch, resource) => {
-            // add code
-        }
-    },
-    {
-        icon: MoveToIcon,
-        name: "Move to",
-        execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
-    },
+export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
     {
         component: ToggleFavoriteAction,
         execute: (dispatch, resource) => {
@@ -41,37 +27,55 @@ export const collectionActionSet: ContextMenuActionSet = [[
     },
     {
         icon: CopyIcon,
-        name: "Copy to project",
+        name: "Make a copy",
         execute: (dispatch, resource) => {
             dispatch<any>(openCollectionCopyDialog(resource));
         }
+
     },
     {
         icon: DetailsIcon,
         name: "View details",
-        execute: (dispatch, resource) => {
-            // add code
-        }
-    },
-    {
-        icon: ProvenanceGraphIcon,
-        name: "Provenance graph",
-        execute: (dispatch, resource) => {
-            // add code
+        execute: dispatch => {
+            dispatch<any>(toggleDetailsPanel());
         }
     },
     {
         icon: AdvancedIcon,
         name: "Advanced",
         execute: (dispatch, resource) => {
-            // add code
+            dispatch<any>(openAdvancedTabDialog(resource.uuid));
         }
     },
-    {
-        icon: RemoveIcon,
-        name: "Remove",
-        execute: (dispatch, resource) => {
-            // add code
-        }
-    }
 ]];
+
+export const collectionActionSet: ContextMenuActionSet = [
+    [
+        ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
+        {
+            icon: RenameIcon,
+            name: "Edit collection",
+            execute: (dispatch, resource) => {
+                dispatch<any>(openCollectionUpdateDialog(resource));
+            }
+        },
+        {
+            icon: ShareIcon,
+            name: "Share",
+            execute: (dispatch, { uuid }) => {
+                dispatch<any>(openSharingDialog(uuid));
+            }
+        },
+        {
+            icon: MoveToIcon,
+            name: "Move to",
+            execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
+        },
+        {
+            component: ToggleTrashAction,
+            execute: (dispatch, resource) => {
+                dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
+            }
+        },
+    ]
+];