Add trashed collection context menu
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 25 Sep 2018 09:31:03 +0000 (11:31 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Tue, 25 Sep 2018 09:31:03 +0000 (11:31 +0200)
Feature #14244

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/index.tsx
src/views-components/context-menu/action-sets/trashed-collection-action-set.ts [new file with mode: 0644]
src/views-components/context-menu/context-menu.tsx
src/views/collection-panel/collection-panel.tsx

index f456c995d1b34698decde9953479f4ffdde1250f..52054a4aa5a0c49f81775d7c527f815a3f0ec05f 100644 (file)
@@ -18,7 +18,7 @@ import { createServices } from "./services/services";
 import { MuiThemeProvider } from '@material-ui/core/styles';
 import { CustomTheme } from './common/custom-theme';
 import { fetchConfig } from './common/config';
-import { addMenuActionSet, ContextMenuKind } from "./views-components/context-menu/context-menu";
+import { addMenuActionSet, ContextMenuKind } from './views-components/context-menu/context-menu';
 import { rootProjectActionSet } from "./views-components/context-menu/action-sets/root-project-action-set";
 import { projectActionSet } from "./views-components/context-menu/action-sets/project-action-set";
 import { resourceActionSet } from './views-components/context-menu/action-sets/resource-action-set';
@@ -38,6 +38,7 @@ import { addRouteChangeHandlers } from './routes/route-change-handlers';
 import { setCurrentTokenDialogApiHost } from '~/store/current-token-dialog/current-token-dialog-actions';
 import { processResourceActionSet } from './views-components/context-menu/action-sets/process-resource-action-set';
 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
+import { trashedCollectionActionSet } from '~/views-components/context-menu/action-sets/trashed-collection-action-set';
 
 const getBuildNumber = () => "BN-" + (process.env.REACT_APP_BUILD_NUMBER || "dev");
 const getGitCommit = () => "GIT-" + (process.env.REACT_APP_GIT_COMMIT || "latest").substr(0, 7);
@@ -55,6 +56,7 @@ addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
+addMenuActionSet(ContextMenuKind.TRASHED_COLLECTION, trashedCollectionActionSet);
 addMenuActionSet(ContextMenuKind.PROCESS, processActionSet);
 addMenuActionSet(ContextMenuKind.PROCESS_RESOURCE, processResourceActionSet);
 addMenuActionSet(ContextMenuKind.TRASH, trashActionSet);
diff --git a/src/views-components/context-menu/action-sets/trashed-collection-action-set.ts b/src/views-components/context-menu/action-sets/trashed-collection-action-set.ts
new file mode 100644 (file)
index 0000000..c42da1e
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RestoreFromTrashIcon } from '~/components/icon/icon';
+import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
+
+export const trashedCollectionActionSet: ContextMenuActionSet = [[
+    {
+        icon: DetailsIcon,
+        name: "View details",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: ProvenanceGraphIcon,
+        name: "Provenance graph",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: AdvancedIcon,
+        name: "Advanced",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: RestoreFromTrashIcon,
+        name: "Restore",
+        execute: (dispatch, resource) => {
+            dispatch<any>(toggleCollectionTrashed(resource.uuid, true));
+        }
+    },
+]];
index d5c82be2d7f0736243f5e97661e4f7c7ec51d7a4..ad6f7e306030b5eedea8309dd2d2b931fccc6bab 100644 (file)
@@ -64,6 +64,7 @@ export enum ContextMenuKind {
     COLLECTION_FILES_ITEM = "CollectionFilesItem",
     COLLECTION = 'Collection',
     COLLECTION_RESOURCE = 'CollectionResource',
+    TRASHED_COLLECTION = 'TrashedCollection',
     PROCESS = "Process",
     PROCESS_RESOURCE = 'ProcessResource',
     PROCESS_LOGS = "ProcessLogs"
index 672493769d5062216409dbbfb76b018244573cfb..07eb7d971a5cfe01f292c04e34f7a756b3e62ecd 100644 (file)
@@ -134,14 +134,16 @@ export const CollectionPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<any>) => {
-                const { uuid, ownerUuid, name, description, kind } = this.props.item;
+                const { uuid, ownerUuid, name, description, kind, isTrashed } = this.props.item;
                 const resource = {
                     uuid,
                     ownerUuid,
                     name,
                     description,
                     kind,
-                    menuKind: ContextMenuKind.COLLECTION
+                    menuKind: isTrashed
+                        ? ContextMenuKind.TRASHED_COLLECTION
+                        : ContextMenuKind.COLLECTION
                 };
                 this.props.dispatch<any>(openContextMenu(event, resource));
             }