Remove doubled ContextMenuResource, spearate menu for trash view
authorDaniel Kos <daniel.kos@contractors.roche.com>
Mon, 3 Sep 2018 21:09:35 +0000 (23:09 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Mon, 3 Sep 2018 21:09:35 +0000 (23:09 +0200)
Feature #13828

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

19 files changed:
src/index.tsx
src/models/resource.ts
src/models/test-utils.ts
src/store/collections/collection-update-actions.ts
src/store/context-menu/context-menu-actions.ts
src/store/context-menu/context-menu-reducer.ts
src/store/projects/project-update-actions.ts
src/store/trash/trash-actions.ts
src/views-components/collection-panel-files/collection-panel-files.ts
src/views-components/context-menu/action-sets/collection-action-set.ts
src/views-components/context-menu/action-sets/collection-resource-action-set.ts
src/views-components/context-menu/action-sets/project-action-set.ts
src/views-components/context-menu/action-sets/trash-action-set.ts [new file with mode: 0644]
src/views-components/context-menu/context-menu-action-set.ts
src/views-components/context-menu/context-menu.tsx
src/views/collection-panel/collection-panel.tsx
src/views/favorite-panel/favorite-panel.tsx
src/views/project-panel/project-panel.tsx
src/views/trash-panel/trash-panel.tsx

index d3115a6754bf70feb6731e8910e71b04859534f4..6137e26dd9319e83d4973280c8dab04b9e209e1d 100644 (file)
@@ -31,6 +31,7 @@ import { processActionSet } from './views-components/context-menu/action-sets/pr
 import { addRouteChangeHandlers } from './routes/routes';
 import { loadWorkbench } from './store/workbench/workbench-actions';
 import { Routes } from '~/routes/routes';
+import { trashActionSet } from "~/views-components/context-menu/action-sets/trash-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);
@@ -49,6 +50,7 @@ addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActio
 addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
 addMenuActionSet(ContextMenuKind.PROCESS, processActionSet);
+addMenuActionSet(ContextMenuKind.TRASH, trashActionSet);
 
 fetchConfig()
     .then((config) => {
index 3d40b50c42217df19b0830b8d9869deddc015cbc..4d7031a455115a58b13684f364115e749e2915df 100644 (file)
@@ -10,7 +10,7 @@ export interface Resource {
     modifiedByUserUuid: string;
     modifiedAt: string;
     href: string;
-    kind: string;
+    kind: ResourceKind;
     etag: string;
 }
 
@@ -29,6 +29,7 @@ export enum ResourceKind {
     PROJECT = "arvados#group",
     USER = "arvados#user",
     WORKFLOW = "arvados#workflow",
+    NONE = "arvados#none"
 }
 
 export enum ResourceObjectType {
index 49eea605d563d106cb53cc63817f3074227576f7..b08ce5a0525bd913b4d774262f3548b664e8e9ac 100644 (file)
@@ -34,7 +34,7 @@ export const mockCommonResource = (data: Partial<Resource>): Resource => ({
     createdAt: "",
     etag: "",
     href: "",
-    kind: "",
+    kind: ResourceKind.NONE,
     modifiedAt: "",
     modifiedByClientUuid: "",
     modifiedByUserUuid: "",
index 03bb72aa56ff4f8c4cebce0414af3ad0d2efd23f..bf05d4ddc5a3a02075e42c402d22f22090061f1f 100644 (file)
@@ -6,15 +6,11 @@ import { Dispatch } from "redux";
 import { initialize, startSubmit, stopSubmit } from 'redux-form';
 import { RootState } from "~/store/store";
 import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
-import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
 import { dialogActions } from "~/store/dialog/dialog-actions";
-import { dataExplorerActions } from "~/store/data-explorer/data-explorer-action";
-import { snackbarActions } from "~/store/snackbar/snackbar-actions";
-import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer';
-import { PROJECT_PANEL_ID } from "~/views/project-panel/project-panel";
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
 import { ServiceRepository } from "~/services/services";
 import { CollectionResource } from '~/models/collection';
+import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 
 export interface CollectionUpdateFormDialogData {
     uuid: string;
index 5ec3a84b6fbc395b02802331de207c0e2b9cf6c3..85e576112f60cc773aa471e248f30c79acb526c7 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { unionize, ofType, UnionOf } from '~/common/unionize';
-import { ContextMenuPosition, ContextMenuResource } from "./context-menu-reducer";
+import { ContextMenuPosition } from "./context-menu-reducer";
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 import { Dispatch } from 'redux';
 import { RootState } from '~/store/store';
@@ -11,7 +11,7 @@ import { getResource } from '../resources/resources';
 import { ProjectResource } from '~/models/project';
 import { UserResource } from '~/models/user';
 import { isSidePanelTreeCategory } from '~/store/side-panel-tree/side-panel-tree-actions';
-import { extractUuidKind, ResourceKind } from '~/models/resource';
+import { extractUuidKind, ResourceKind, TrashableResource } from '~/models/resource';
 
 export const contextMenuActions = unionize({
     OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition, resource: ContextMenuResource }>(),
@@ -25,7 +25,8 @@ export type ContextMenuResource = {
     uuid: string;
     ownerUuid: string;
     description?: string;
-    kind: ContextMenuKind;
+    kind: ResourceKind,
+    menuKind: ContextMenuKind;
     isTrashed?: boolean;
 };
 
@@ -48,7 +49,8 @@ export const openRootProjectContextMenu = (event: React.MouseEvent<HTMLElement>,
                 name: '',
                 uuid: res.uuid,
                 ownerUuid: res.uuid,
-                kind: ContextMenuKind.ROOT_PROJECT,
+                kind: res.kind,
+                menuKind: ContextMenuKind.ROOT_PROJECT,
                 isTrashed: false
             }));
         }
@@ -61,7 +63,8 @@ export const openProjectContextMenu = (event: React.MouseEvent<HTMLElement>, pro
             dispatch<any>(openContextMenu(event, {
                 name: res.name,
                 uuid: res.uuid,
-                kind: ContextMenuKind.PROJECT,
+                kind: res.kind,
+                menuKind: ContextMenuKind.PROJECT,
                 ownerUuid: res.ownerUuid,
                 isTrashed: res.isTrashed
             }));
@@ -84,9 +87,11 @@ export const openProcessContextMenu = (event: React.MouseEvent<HTMLElement>) =>
     (dispatch: Dispatch, getState: () => RootState) => {
         const resource = {
             uuid: '',
+            ownerUuid: '',
+            kind: ResourceKind.PROCESS,
             name: '',
             description: '',
-            kind: ContextMenuKind.PROCESS
+            menuKind: ContextMenuKind.PROCESS
         };
         dispatch<any>(openContextMenu(event, resource));
     };
index 8026c1d1d66125f2ee5a597dc5e3eb95b2cb8089..03d9cc7843a8df8e5f068a74274d0d6cb7a682e0 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { contextMenuActions, ContextMenuAction } from "./context-menu-actions";
+import { contextMenuActions, ContextMenuAction, ContextMenuResource } from "./context-menu-actions";
 
 export interface ContextMenuState {
     open: boolean;
@@ -15,15 +15,6 @@ export interface ContextMenuPosition {
     y: number;
 }
 
-export interface ContextMenuResource {
-    uuid: string;
-    kind: string;
-    name: string;
-    description?: string;
-    isTrashed?: boolean;
-    ownerUuid?: string;
-}
-
 const initialState = {
     open: false,
     position: { x: 0, y: 0 }
index 8e327ebeb3e25041012ad918f3e30aa1225bdda6..afa2e35e8d7c6555055ba053c0bfaeadb6145d84 100644 (file)
@@ -6,10 +6,10 @@ import { Dispatch } from "redux";
 import { initialize, startSubmit, stopSubmit } from 'redux-form';
 import { RootState } from "~/store/store";
 import { dialogActions } from "~/store/dialog/dialog-actions";
-import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer';
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
 import { ServiceRepository } from "~/services/services";
 import { ProjectResource } from '~/models/project';
+import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 
 export interface ProjectUpdateFormDialogData {
     uuid: string;
index 4b2000d7b6003469ecedf12d6982aea31ffd882c..06e1648323e754444437dfb114e0fb15cdb0e586 100644 (file)
@@ -10,12 +10,12 @@ import { trashPanelActions } from "~/store/trash-panel/trash-panel-action";
 import { activateSidePanelTreeItem, loadSidePanelTreeProjects } from "~/store/side-panel-tree/side-panel-tree-actions";
 import { projectPanelActions } from "~/store/project-panel/project-panel-action";
 
-export const toggleProjectTrashed = (resource: { uuid: string; name: string, isTrashed?: boolean, ownerUuid?: string }) =>
+export const toggleProjectTrashed = (uuid: string, ownerUuid: string, isTrashed: boolean) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
-        if (resource.isTrashed) {
+        if (isTrashed) {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
-            await services.groupsService.untrash(resource.uuid);
-            dispatch<any>(activateSidePanelTreeItem(resource.uuid));
+            await services.groupsService.untrash(uuid);
+            dispatch<any>(activateSidePanelTreeItem(uuid));
             dispatch(trashPanelActions.REQUEST_ITEMS());
             dispatch(snackbarActions.CLOSE_SNACKBAR());
             dispatch(snackbarActions.OPEN_SNACKBAR({
@@ -24,8 +24,8 @@ export const toggleProjectTrashed = (resource: { uuid: string; name: string, isT
             }));
         } else {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
-            await services.groupsService.trash(resource.uuid);
-            dispatch<any>(loadSidePanelTreeProjects(resource.ownerUuid!!));
+            await services.groupsService.trash(uuid);
+            dispatch<any>(loadSidePanelTreeProjects(ownerUuid));
             dispatch(snackbarActions.CLOSE_SNACKBAR());
             dispatch(snackbarActions.OPEN_SNACKBAR({
                 message: "Added to trash",
@@ -34,11 +34,11 @@ export const toggleProjectTrashed = (resource: { uuid: string; name: string, isT
         }
     };
 
-export const toggleCollectionTrashed = (resource: { uuid: string; name: string, isTrashed?: boolean, ownerUuid?: string }) =>
+export const toggleCollectionTrashed = (uuid: string, isTrashed: boolean) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
-        if (resource.isTrashed) {
+        if (isTrashed) {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Restoring from trash..." }));
-            await services.collectionService.untrash(resource.uuid);
+            await services.collectionService.untrash(uuid);
             dispatch(trashPanelActions.REQUEST_ITEMS());
             dispatch(snackbarActions.OPEN_SNACKBAR({
                 message: "Restored from trash",
@@ -46,7 +46,7 @@ export const toggleCollectionTrashed = (resource: { uuid: string; name: string,
             }));
         } else {
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Moving to trash..." }));
-            await services.collectionService.trash(resource.uuid);
+            await services.collectionService.trash(uuid);
             dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(snackbarActions.OPEN_SNACKBAR({
                 message: "Added to trash",
index ccb18c8f98d715eac025855d502a2c03bc021880..edc100f783d282745172da4bf68cfe6873436b84 100644 (file)
@@ -3,18 +3,26 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { connect } from "react-redux";
-import { CollectionPanelFiles as Component, CollectionPanelFilesProps } from "~/components/collection-panel-files/collection-panel-files";
+import {
+    CollectionPanelFiles as Component,
+    CollectionPanelFilesProps
+} from "~/components/collection-panel-files/collection-panel-files";
 import { RootState } from "~/store/store";
-import { TreeItemStatus, TreeItem } from "~/components/tree/tree";
-import { CollectionPanelFilesState, CollectionPanelDirectory, CollectionPanelFile } from "~/store/collection-panel/collection-panel-files/collection-panel-files-state";
+import { TreeItem, TreeItemStatus } from "~/components/tree/tree";
+import {
+    CollectionPanelDirectory,
+    CollectionPanelFile,
+    CollectionPanelFilesState
+} from "~/store/collection-panel/collection-panel-files/collection-panel-files-state";
 import { FileTreeData } from "~/components/file-tree/file-tree-data";
 import { Dispatch } from "redux";
 import { collectionPanelFilesAction } from "~/store/collection-panel/collection-panel-files/collection-panel-files-actions";
 import { ContextMenuKind } from "../context-menu/context-menu";
-import { Tree, getNodeChildrenIds, getNode } from "~/models/tree";
+import { getNode, getNodeChildrenIds, Tree } from "~/models/tree";
 import { CollectionFileType } from "~/models/collection-file";
 import { openContextMenu } from '~/store/context-menu/context-menu-actions';
 import { openUploadCollectionFilesDialog } from '~/store/collections/collection-upload-actions';
+import { ResourceKind } from "~/models/resource";
 
 const memoizedMapStateToProps = () => {
     let prevState: CollectionPanelFilesState;
@@ -43,10 +51,10 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick<CollectionPanelFilesProps,
         dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
     },
     onItemMenuOpen: (event, item) => {
-        dispatch<any>(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES_ITEM, name: item.data.name, uuid: item.id }));
+        dispatch<any>(openContextMenu(event, { menuKind: ContextMenuKind.COLLECTION_FILES_ITEM, kind: ResourceKind.COLLECTION, name: item.data.name, uuid: item.id, ownerUuid: '' }));
     },
     onOptionsMenuOpen: (event) => {
-        dispatch<any>(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES, name: '', uuid: '' }));
+        dispatch<any>(openContextMenu(event, { menuKind: ContextMenuKind.COLLECTION_FILES, kind: ResourceKind.COLLECTION, name: '', uuid: '', ownerUuid: '' }));
     },
 });
 
index a7d16c680f636655a19b4b0f70981ac703bf338a..67249fc716ae80d6ddd2f5b1b0c8d4b0892aeeec 100644 (file)
@@ -44,7 +44,7 @@ export const collectionActionSet: ContextMenuActionSet = [[
     {
         component: ToggleTrashAction,
         execute: (dispatch, resource) => {
-            dispatch<any>(toggleCollectionTrashed(resource));
+            dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
         }
     },
     {
index f1df0c08a84a8ad2531b374b927823a6cca289cc..b7d3e64f29f97db9620243d2ee93fdabd37ce84f 100644 (file)
@@ -44,7 +44,7 @@ export const collectionResourceActionSet: ContextMenuActionSet = [[
     {
         component: ToggleTrashAction,
         execute: (dispatch, resource) => {
-            dispatch<any>(toggleCollectionTrashed(resource));
+            dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
         }
     },
     {
index eca395bbcab728172404593598521b2f7aeac289..e5a1915472c7d39ef3f8d9e67c5160c8d437b1ca 100644 (file)
@@ -39,7 +39,7 @@ export const projectActionSet: ContextMenuActionSet = [[
     {
         component: ToggleTrashAction,
         execute: (dispatch, resource) => {
-            dispatch<any>(toggleProjectTrashed(resource));
+            dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
         }
     },
     {
diff --git a/src/views-components/context-menu/action-sets/trash-action-set.ts b/src/views-components/context-menu/action-sets/trash-action-set.ts
new file mode 100644 (file)
index 0000000..3a5c530
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
+import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
+
+export const trashActionSet: ContextMenuActionSet = [[
+    {
+        component: ToggleTrashAction,
+        execute: (dispatch, resource) => {
+            dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
+        }
+    },
+]];
index cbcc0b72f201b76190ea4e7384af8d3433512ba6..c89cd3a5dcf2aa09e4a03953a48c9d960b76ba77 100644 (file)
@@ -4,7 +4,7 @@
 
 import { Dispatch } from "redux";
 import { ContextMenuItem } from "~/components/context-menu/context-menu";
-import { ContextMenuResource } from "~/store/context-menu/context-menu-reducer";
+import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 
 export interface ContextMenuAction extends ContextMenuItem {
     execute(dispatch: Dispatch, resource: ContextMenuResource): void;
index 5d94766c447674170560e45b5392993ef505a977..2df776e59e8fe3ac54f41dabf969bd4241d6c40b 100644 (file)
@@ -4,10 +4,9 @@
 
 import { connect } from "react-redux";
 import { RootState } from "~/store/store";
-import { contextMenuActions } from "~/store/context-menu/context-menu-actions";
+import { contextMenuActions, ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 import { ContextMenu as ContextMenuComponent, ContextMenuProps, ContextMenuItem } from "~/components/context-menu/context-menu";
 import { createAnchorAt } from "~/components/popover/helpers";
-import { ContextMenuResource } from "~/store/context-menu/context-menu-reducer";
 import { ContextMenuActionSet, ContextMenuAction } from "./context-menu-action-set";
 import { Dispatch } from "redux";
 
@@ -52,7 +51,7 @@ export const addMenuActionSet = (name: string, itemSet: ContextMenuActionSet) =>
 };
 
 const getMenuActionSet = (resource?: ContextMenuResource): ContextMenuActionSet => {
-    return resource ? menuActionSets.get(resource.kind) || [] : [];
+    return resource ? menuActionSets.get(resource.menuKind) || [] : [];
 };
 
 export enum ContextMenuKind {
@@ -60,6 +59,7 @@ export enum ContextMenuKind {
     PROJECT = "Project",
     RESOURCE = "Resource",
     FAVORITE = "Favorite",
+    TRASH = "Trash",
     COLLECTION_FILES = "CollectionFiles",
     COLLECTION_FILES_ITEM = "CollectionFilesItem",
     COLLECTION = 'Collection',
index 8a0e2f8108332c5110218b1711d5d4ac36242767..748151c6c366d30f3ef650eca3d90738d0369b7a 100644 (file)
@@ -21,7 +21,7 @@ import { CollectionTagForm } from './collection-tag-form';
 import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { getResource } from '~/store/resources/resources';
-import { contextMenuActions, openContextMenu } from '~/store/context-menu/context-menu-actions';
+import { openContextMenu } from '~/store/context-menu/context-menu-actions';
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 
 type CssRules = 'card' | 'iconHeader' | 'tag' | 'copyIcon' | 'label' | 'value';
@@ -133,12 +133,14 @@ export const CollectionPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<any>) => {
-                const { uuid, name, description } = this.props.item;
+                const { uuid, ownerUuid, name, description, kind } = this.props.item;
                 const resource = {
                     uuid,
+                    ownerUuid,
                     name,
                     description,
-                    kind: ContextMenuKind.COLLECTION
+                    kind,
+                    menuKind: ContextMenuKind.COLLECTION
                 };
                 this.props.dispatch<any>(openContextMenu(event, resource));
             }
index 003a319bff6f1d8b019cbb96b1163c08f1d4b1fb..2cb30198e7242c54fca8020bdf5579dc57535a66 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from 'react';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
 import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
-import { DispatchProp, connect } from 'react-redux';
+import { connect, DispatchProp } from 'react-redux';
 import { DataColumns } from '~/components/data-table/data-table';
 import { RouteComponentProps } from 'react-router';
 import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
@@ -14,7 +14,14 @@ import { ResourceKind } from '~/models/resource';
 import { resourceLabel } from '~/common/labels';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { FAVORITE_PANEL_ID } from "~/store/favorite-panel/favorite-panel-action";
-import { ResourceFileSize, ResourceLastModifiedDate, ProcessStatus, ResourceType, ResourceOwner, ResourceName } from '~/views-components/data-explorer/renderers';
+import {
+    ProcessStatus,
+    ResourceFileSize,
+    ResourceLastModifiedDate,
+    ResourceName,
+    ResourceOwner,
+    ResourceType
+} from '~/views-components/data-explorer/renderers';
 import { FavoriteIcon } from '~/components/icon/icon';
 import { Dispatch } from 'redux';
 import { openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-actions';
@@ -151,7 +158,13 @@ const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({
     onContextMenu: (event, resourceUuid) => {
         const kind = resourceKindToContextMenuKind(resourceUuid);
         if (kind) {
-            dispatch<any>(openContextMenu(event, { name: '', uuid: resourceUuid, kind }));
+            dispatch<any>(openContextMenu(event, {
+                name: '',
+                uuid: resourceUuid,
+                ownerUuid: '',
+                kind: ResourceKind.NONE,
+                menuKind: kind
+            }));
         }
     },
     onDialogOpen: (ownerUuid: string) => { return; },
index cfdeec9987a51ece8fada9233a2afcf4e9d718b7..1cb72a963b0ff709bff33203ad21859eda374c01 100644 (file)
@@ -197,15 +197,16 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                const kind = resourceKindToContextMenuKind(resourceUuid);
+                const menuKind = resourceKindToContextMenuKind(resourceUuid);
                 const resource = getResource<ProjectResource>(resourceUuid)(this.props.resources);
-                if (kind && resource) {
+                if (menuKind && resource) {
                     this.props.dispatch<any>(openContextMenu(event, {
                         name: resource.name,
                         uuid: resource.uuid,
                         ownerUuid: resource.ownerUuid,
                         isTrashed: resource.isTrashed,
-                        kind
+                        kind: resource.kind,
+                        menuKind
                     }));
                 }
             }
index 56724eabe11d501ab8c4fccc95eeb7d24641b97e..dadfabb0d6e0fcafee0b361125a8624b78997cd2 100644 (file)
@@ -5,7 +5,7 @@
 import * as React from 'react';
 import { IconButton, StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core';
 import { DataExplorer } from "~/views-components/data-explorer/data-explorer";
-import { DispatchProp, connect } from 'react-redux';
+import { connect, DispatchProp } from 'react-redux';
 import { DataColumns } from '~/components/data-table/data-table';
 import { RootState } from '~/store/store';
 import { DataTableFilterItem } from '~/components/data-table-filters/data-table-filters';
@@ -17,10 +17,9 @@ import { RestoreFromTrashIcon, TrashIcon } from '~/components/icon/icon';
 import { TRASH_PANEL_ID } from "~/store/trash-panel/trash-panel-action";
 import { getProperty } from "~/store/properties/properties";
 import { PROJECT_PANEL_CURRENT_UUID } from "~/store/project-panel/project-panel-action";
-import { openContextMenu, resourceKindToContextMenuKind } from "~/store/context-menu/context-menu-actions";
+import { ContextMenuResource, openContextMenu } from "~/store/context-menu/context-menu-actions";
 import { getResource, ResourcesState } from "~/store/resources/resources";
 import {
-    renderDate,
     ResourceDeleteDate,
     ResourceFileSize,
     ResourceName,
@@ -30,6 +29,7 @@ import {
 import { navigateTo } from "~/store/navigation/navigation-action";
 import { loadDetailsPanel } from "~/store/details-panel/details-panel-action";
 import { toggleCollectionTrashed, toggleProjectTrashed } from "~/store/trash/trash-actions";
+import { ContextMenuKind } from "~/views-components/context-menu/context-menu";
 import { Dispatch } from "redux";
 
 type CssRules = "toolbar" | "button";
@@ -63,17 +63,12 @@ export const ResourceRestore =
     })((props: { resource?: TrashableResource, dispatch?: Dispatch<any> }) =>
         <IconButton onClick={() => {
             if (props.resource && props.dispatch) {
-                const ctxRes = {
-                    name: '',
-                    uuid: props.resource.uuid,
-                    isTrashed: props.resource.isTrashed,
-                    ownerUuid: props.resource.ownerUuid
-                };
+                const res = props.resource;
 
                 if (props.resource.kind === ResourceKind.PROJECT) {
-                    props.dispatch(toggleProjectTrashed(ctxRes));
+                    props.dispatch(toggleProjectTrashed(res.uuid, res.ownerUuid, res.isTrashed));
                 } else if (props.resource.kind === ResourceKind.COLLECTION) {
-                    props.dispatch(toggleCollectionTrashed(ctxRes));
+                    props.dispatch(toggleCollectionTrashed(res.uuid, res.isTrashed));
                 }
             }
         }}>
@@ -180,15 +175,15 @@ export const TrashPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                const kind = resourceKindToContextMenuKind(resourceUuid);
-                const resource = getResource(resourceUuid)(this.props.resources) as TrashableResource;
-                if (kind && resource) {
+                const resource = getResource<TrashableResource>(resourceUuid)(this.props.resources);
+                if (resource) {
                     this.props.dispatch<any>(openContextMenu(event, {
                         name: '',
                         uuid: resource.uuid,
                         ownerUuid: resource.ownerUuid,
                         isTrashed: resource.isTrashed,
-                        kind
+                        kind: resource.kind,
+                        menuKind: ContextMenuKind.TRASH
                     }));
                 }
             }