[ARVADOS-WORKBENCH2] updated: 1.2.0-174-g1a90c38

Git user git at public.curoverse.com
Mon Aug 27 13:21:53 EDT 2018


Summary of changes:
 src/store/context-menu/context-menu-actions.ts     | 14 ++++++++++
 .../collection-panel-files.ts                      | 15 ++++-------
 src/views/collection-panel/collection-panel.tsx    | 10 ++------
 src/views/favorite-panel/favorite-panel.tsx        | 13 ++++------
 src/views/project-panel/project-panel.tsx          | 30 +++-------------------
 5 files changed, 30 insertions(+), 52 deletions(-)

       via  1a90c384645ab8880d68abb5dbee1d1193f80538 (commit)
      from  ddac62fc3f788162bd56bbd5bcacc2f9395c9cca (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 1a90c384645ab8880d68abb5dbee1d1193f80538
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 27 19:21:36 2018 +0200

    Reuse openContextMenu action
    
    Feature #14102
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 26e25c3..4062399 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -66,3 +66,17 @@ export const openSidePanelContextMenu = (event: React.MouseEvent<HTMLElement>, i
             }
         }
     };
+
+export const resourceKindToContextMenuKind = (uuid: string) => {
+    const kind = extractUuidKind(uuid);
+    switch (kind) {
+        case ResourceKind.PROJECT:
+            return ContextMenuKind.PROJECT;
+        case ResourceKind.COLLECTION:
+            return ContextMenuKind.COLLECTION_RESOURCE;
+        case ResourceKind.USER:
+            return ContextMenuKind.ROOT_PROJECT;
+        default:
+            return;
+    }
+};
diff --git a/src/views-components/collection-panel-files/collection-panel-files.ts b/src/views-components/collection-panel-files/collection-panel-files.ts
index 3e99e10..1046995 100644
--- a/src/views-components/collection-panel-files/collection-panel-files.ts
+++ b/src/views-components/collection-panel-files/collection-panel-files.ts
@@ -15,6 +15,7 @@ import { ContextMenuKind } from "../context-menu/context-menu";
 import { Tree, getNodeChildrenIds, getNode } from "~/models/tree";
 import { CollectionFileType } from "~/models/collection-file";
 import { openUploadCollectionFilesDialog } from '~/store/collections/uploader/collection-uploader-actions';
+import { openContextMenu } from '../../store/context-menu/context-menu-actions';
 
 const memoizedMapStateToProps = () => {
     let prevState: CollectionPanelFilesState;
@@ -43,17 +44,11 @@ const mapDispatchToProps = (dispatch: Dispatch): Pick<CollectionPanelFilesProps,
         dispatch(collectionPanelFilesAction.TOGGLE_COLLECTION_FILE_SELECTION({ id: item.id }));
     },
     onItemMenuOpen: (event, item) => {
-        event.preventDefault();
-        dispatch(contextMenuActions.OPEN_CONTEXT_MENU({
-            position: { x: event.clientX, y: event.clientY },
-            resource: { kind: ContextMenuKind.COLLECTION_FILES_ITEM, name: item.data.name, uuid: item.id }
-        }));
+        dispatch<any>(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES_ITEM, name: item.data.name, uuid: item.id }));
+    },
+    onOptionsMenuOpen: (event) => {
+        dispatch<any>(openContextMenu(event, { kind: ContextMenuKind.COLLECTION_FILES, name: '', uuid: '' }));
     },
-    onOptionsMenuOpen: (event) =>
-        dispatch(contextMenuActions.OPEN_CONTEXT_MENU({
-            position: { x: event.clientX, y: event.clientY },
-            resource: { kind: ContextMenuKind.COLLECTION_FILES, name: '', uuid: '' }
-        }))
 });
 
 
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index d22dd0d..348b548 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -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 } from '~/store/context-menu/context-menu-actions';
+import { contextMenuActions, 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';
@@ -134,7 +134,6 @@ export const CollectionPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<any>) => {
-                event.preventDefault();
                 const { uuid, name, description } = this.props.item;
                 const resource = {
                     uuid,
@@ -142,12 +141,7 @@ export const CollectionPanel = withStyles(styles)(
                     description,
                     kind: ContextMenuKind.COLLECTION
                 };
-                this.props.dispatch(
-                    contextMenuActions.OPEN_CONTEXT_MENU({
-                        position: { x: event.clientX, y: event.clientY },
-                        resource
-                    })
-                );
+                this.props.dispatch<any>(openContextMenu(event, resource));
             }
 
             handleDelete = (uuid: string) => () => {
diff --git a/src/views/favorite-panel/favorite-panel.tsx b/src/views/favorite-panel/favorite-panel.tsx
index f02c906..9fbae5c 100644
--- a/src/views/favorite-panel/favorite-panel.tsx
+++ b/src/views/favorite-panel/favorite-panel.tsx
@@ -18,7 +18,7 @@ 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 { FavoriteIcon } from '~/components/icon/icon';
 import { Dispatch } from 'redux';
-import { contextMenuActions } from '~/store/context-menu/context-menu-actions';
+import { contextMenuActions, openContextMenu, resourceKindToContextMenuKind } from '~/store/context-menu/context-menu-actions';
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
 import { loadDetailsPanel } from '../../store/details-panel/details-panel-action';
 import { navigateTo } from '~/store/navigation/navigation-action';
@@ -150,13 +150,10 @@ interface FavoritePanelActionProps {
 
 const mapDispatchToProps = (dispatch: Dispatch): FavoritePanelActionProps => ({
     onContextMenu: (event, resourceUuid) => {
-        event.preventDefault();
-        dispatch(
-            contextMenuActions.OPEN_CONTEXT_MENU({
-                position: { x: event.clientX, y: event.clientY },
-                resource: { name: '', uuid: resourceUuid, kind: ContextMenuKind.RESOURCE }
-            })
-        );
+        const kind = resourceKindToContextMenuKind(resourceUuid);
+        if (kind) {
+            dispatch<any>(openContextMenu(event, { name: '', uuid: resourceUuid, kind }));
+        }
     },
     onDialogOpen: (ownerUuid: string) => { return; },
     onItemClick: (resourceUuid: string) => {
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index 01c2602..0694643 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -21,7 +21,7 @@ import { ResourceName } from '~/views-components/data-explorer/renderers';
 import { ResourcesState, getResource } from '~/store/resources/resources';
 import { loadDetailsPanel } from '~/store/details-panel/details-panel-action';
 import { ContextMenuKind } from '~/views-components/context-menu/context-menu';
-import { contextMenuActions } from '~/store/context-menu/context-menu-actions';
+import { contextMenuActions, resourceKindToContextMenuKind, openContextMenu } from '~/store/context-menu/context-menu-actions';
 import { CollectionResource } from '~/models/collection';
 import { ProjectResource } from '~/models/project';
 import { navigateTo } from '~/store/navigation/navigation-action';
@@ -198,31 +198,9 @@ export const ProjectPanel = withStyles(styles)(
             }
 
             handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-                event.preventDefault();
-                const resource = getResource(resourceUuid)(this.props.resources) as CollectionResource | ProjectResource | undefined;
-                if (resource) {
-                    let kind: ContextMenuKind;
-
-                    if (resource.kind === ResourceKind.PROJECT) {
-                        kind = ContextMenuKind.PROJECT;
-                    } else if (resource.kind === ResourceKind.COLLECTION) {
-                        kind = ContextMenuKind.COLLECTION_RESOURCE;
-                    } else {
-                        kind = ContextMenuKind.RESOURCE;
-                    }
-                    if (kind !== ContextMenuKind.RESOURCE) {
-                        this.props.dispatch(
-                            contextMenuActions.OPEN_CONTEXT_MENU({
-                                position: { x: event.clientX, y: event.clientY },
-                                resource: {
-                                    uuid: resource.uuid,
-                                    name: resource.name || '',
-                                    description: resource.description,
-                                    kind,
-                                }
-                            })
-                        );
-                    }
+                const kind = resourceKindToContextMenuKind(resourceUuid);
+                if (kind) {
+                    this.props.dispatch<any>(openContextMenu(event, { name: '', uuid: resourceUuid, kind }));
                 }
             }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list