21128: basic collection actioons good Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
[arvados-workbench2.git] / src / views-components / multiselect-toolbar / ms-collection-action-set.ts
index 3afe15568efbbdece0afefa737c5f5c75cc635d5..d9ad017b7e74f265d3a1a6647b3dfa2078e069b6 100644 (file)
@@ -2,43 +2,66 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { MoveToIcon, CopyIcon } from "components/icon/icon";
+import { MoveToIcon, CopyIcon, RenameIcon } from "components/icon/icon";
 import { openMoveCollectionDialog } from "store/collections/collection-move-actions";
 import { openCollectionCopyDialog, openMultiCollectionCopyDialog } from "store/collections/collection-copy-actions";
 import { toggleCollectionTrashed } from "store/trash/trash-actions";
 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
-import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-actions";
+import { msCommonActionSet, MultiSelectMenuActionSet, MultiSelectMenuActionNames, MultiSelectMenuAction } from "./ms-menu-actions";
 import { TrashIcon } from "components/icon/icon";
+import { openCollectionUpdateDialog } from "store/collections/collection-update-actions";
+
+const { MAKE_A_COPY, MOVE_TO, ADD_TO_TRASH, EDIT_COLLECTION } = MultiSelectMenuActionNames;
+
+const msCopyCollection: MultiSelectMenuAction = {
+    name: MultiSelectMenuActionNames.MAKE_A_COPY,
+    icon: CopyIcon,
+    hasAlts: false,
+    isForMulti: true,
+    execute: (dispatch, [...resources]) => {
+        if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
+        else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
+    },
+}
+
+const msMoveCollection: MultiSelectMenuAction = {
+    name: MultiSelectMenuActionNames.MOVE_TO,
+    icon: MoveToIcon,
+    hasAlts: false,
+    isForMulti: true,
+    execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
+}
+
+const msToggleTrashAction: MultiSelectMenuAction = {
+    name: MultiSelectMenuActionNames.ADD_TO_TRASH,
+    icon: TrashIcon,
+    isForMulti: true,
+    hasAlts: false,
+    execute: (dispatch, resources: ContextMenuResource[]) => {
+        for (const resource of [...resources]) {
+            dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
+        }
+    },
+}
+
+const msEditCollection: MultiSelectMenuAction = {
+    icon: RenameIcon,
+    hasAlts: false,
+    isForMulti: false,
+    name: "Edit collection",
+    execute: (dispatch, resources) => {
+        dispatch<any>(openCollectionUpdateDialog(resources[0]));
+    },
+}
 
 export const msCollectionActionSet: MultiSelectMenuActionSet = [
     [
-        {
-            name: MultiSelectMenuActionNames.MAKE_A_COPY,
-            icon: CopyIcon,
-            hasAlts: false,
-            isForMulti: true,
-            execute: (dispatch, [...resources]) => {
-                if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
-                else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
-            },
-        },
-        {
-            name: MultiSelectMenuActionNames.MOVE_TO,
-            icon: MoveToIcon,
-            hasAlts: false,
-            isForMulti: true,
-            execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
-        },
-        {
-            name: MultiSelectMenuActionNames.ADD_TO_TRASH,
-            icon: TrashIcon,
-            isForMulti: true,
-            hasAlts: false,
-            execute: (dispatch, resources: ContextMenuResource[]) => {
-                for (const resource of [...resources]) {
-                    dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
-                }
-            },
-        },
+        ...msCommonActionSet,
+        msCopyCollection,
+        msMoveCollection,
+        msToggleTrashAction,
+        msEditCollection
     ],
 ];
+
+//edit collection
\ No newline at end of file