Merge branch '13898-edit-collection-from-data-explorer'
authorJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 9 Aug 2018 10:20:17 +0000 (12:20 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 9 Aug 2018 10:20:17 +0000 (12:20 +0200)
refs #13898

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

src/index.tsx
src/store/collections/updater/collection-updater-action.ts
src/store/collections/updater/collection-updater-reducer.ts
src/store/context-menu/context-menu-reducer.ts
src/views-components/context-menu/action-sets/collection-action-set.ts
src/views-components/context-menu/action-sets/collection-resource-action-set.ts [new file with mode: 0644]
src/views-components/context-menu/context-menu.tsx
src/views-components/rename-file-dialog/rename-file-dialog.tsx
src/views/project-panel/project-panel-item.ts
src/views/workbench/workbench.tsx

index aac275f9d63c286af6e032f3b3c4803a5c90e5be..dd2722335d091f032bcd116979df33df61a37953 100644 (file)
@@ -26,6 +26,7 @@ import { favoriteActionSet } from "./views-components/context-menu/action-sets/f
 import { collectionFilesActionSet } from './views-components/context-menu/action-sets/collection-files-action-set';
 import { collectionFilesItemActionSet } from './views-components/context-menu/action-sets/collection-files-item-action-set';
 import { collectionActionSet } from './views-components/context-menu/action-sets/collection-action-set';
+import { collectionResourceActionSet } from './views-components/context-menu/action-sets/collection-resource-action-set';
 
 addMenuActionSet(ContextMenuKind.ROOT_PROJECT, rootProjectActionSet);
 addMenuActionSet(ContextMenuKind.PROJECT, projectActionSet);
@@ -34,6 +35,7 @@ addMenuActionSet(ContextMenuKind.FAVORITE, favoriteActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
 addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
+addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
 
 fetchConfig()
     .then(config => {
index a7a354ad1c31940b733711c7dd27a92a6296ffca..bb9f4d3072d47bdd7fda30ac5784aeaa4e259b40 100644 (file)
@@ -10,6 +10,7 @@ import { ServiceRepository } from "../../../services/services";
 import { CollectionResource } from '../../../models/collection';
 import { initialize } from 'redux-form';
 import { collectionPanelActions } from "../../collection-panel/collection-panel-action";
+import { ContextMenuResource } from "../../context-menu/context-menu-reducer";
 
 export const collectionUpdaterActions = unionize({
     OPEN_COLLECTION_UPDATER: ofType<{ uuid: string }>(),
@@ -23,11 +24,10 @@ export const collectionUpdaterActions = unionize({
 
 export const COLLECTION_FORM_NAME = 'collectionEditDialog';
 
-export const openUpdater = (uuid: string) =>
+export const openUpdater = (item: ContextMenuResource) =>
     (dispatch: Dispatch, getState: () => RootState) => {
-        dispatch(collectionUpdaterActions.OPEN_COLLECTION_UPDATER({ uuid }));
-        const item = getState().collectionPanel.item;
-        if(item) {
+        if (item) {
+            dispatch(collectionUpdaterActions.OPEN_COLLECTION_UPDATER({ uuid: item.uuid }));
             dispatch(initialize(COLLECTION_FORM_NAME, { name: item.name, description: item.description }));
         }
     };
index 432aa2708da8abe23cf202cdf9bf74047ac7b420..97d010fca2a6ed3b307f59cc765dfee6140afe50 100644 (file)
@@ -22,7 +22,7 @@ const initialState: CollectionUpdaterState = {
 export const collectionUpdaterReducer = (state: CollectionUpdaterState = initialState, action: CollectionUpdaterAction) => {
     return collectionUpdaterActions.match(action, {
         OPEN_COLLECTION_UPDATER: ({ uuid }) => updateCollection(state, { uuid, opened: true }),
-        CLOSE_COLLECTION_UPDATER: () => updateCollection(state, { opened: false }),
+        CLOSE_COLLECTION_UPDATER: () => updateCollection(state, { opened: false, uuid: "" }),
         UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, uuid: "" }),
         default: () => state
     });
index 8b51478d2bf980680be65249fab495ae5f7e9509..ac14c35534dba5b5fd0576ec0f10bac47631b7d8 100644 (file)
@@ -19,6 +19,7 @@ export interface ContextMenuResource {
     uuid: string;
     kind: string;
     name: string;
+    description?: string;
 }
 
 const initialState = {
index 513cb5fc08647a8c419f38d5a8f6afc8822679a1..10da9ef183448299f8a695f175be28fe1d4c4687 100644 (file)
@@ -14,7 +14,7 @@ export const collectionActionSet: ContextMenuActionSet = [[
         icon: RenameIcon,
         name: "Edit collection",
         execute: (dispatch, resource) => {
-            dispatch<any>(openUpdater(resource.uuid));
+            dispatch<any>(openUpdater(resource));
         }
     },
     {
diff --git a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
new file mode 100644 (file)
index 0000000..e6356bb
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+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, RemoveIcon } from "../../../components/icon/icon";
+import { openUpdater } from "../../../store/collections/updater/collection-updater-action";
+import { favoritePanelActions } from "../../../store/favorite-panel/favorite-panel-action";
+
+export const collectionResourceActionSet: ContextMenuActionSet = [[
+    {
+        icon: RenameIcon,
+        name: "Edit collection",
+        execute: (dispatch, resource) => {
+            dispatch<any>(openUpdater(resource));
+        }
+    },
+    {
+        icon: ShareIcon,
+        name: "Share",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: MoveToIcon,
+        name: "Move to",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        component: ToggleFavoriteAction,
+        execute: (dispatch, resource) => {
+            dispatch<any>(toggleFavorite(resource)).then(() => {
+                dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
+            });
+        }
+    },
+    {
+        icon: CopyIcon,
+        name: "Copy to project",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: DetailsIcon,
+        name: "View details",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    },
+    {
+        icon: RemoveIcon,
+        name: "Remove",
+        execute: (dispatch, resource) => {
+            // add code
+        }
+    }
+]];
index 8b00893703839c5bbd9fe64d932348ff08474f4b..0a629b2e476360a5046d77a422249a377d350374 100644 (file)
@@ -62,5 +62,6 @@ export enum ContextMenuKind {
     FAVORITE = "Favorite",
     COLLECTION_FILES = "CollectionFiles",
     COLLECTION_FILES_ITEM = "CollectionFilesItem",
-    COLLECTION = 'Collection'
+    COLLECTION = 'Collection',
+    COLLECTION_RESOURCE = 'CollectionResource'
 }
index 6c880cc8bde6d07c71a70e730bd7cc1721df6ddf..5e2f7c44def1d38ecd584a80278f4f798d52ea38 100644 (file)
@@ -10,7 +10,7 @@ import { RenameDialog } from "../../components/rename-dialog/rename-dialog";
 
 export const RENAME_FILE_DIALOG = 'renameFileDialog';
 
-export const openRenameFileDialog = (originalName: string) =>
+export const openRenameFileDialog = (originalName: string) =>
     (dispatch: Dispatch) => {
         dispatch(reset(RENAME_FILE_DIALOG));
         dispatch(dialogActions.OPEN_DIALOG({ id: RENAME_FILE_DIALOG, data: originalName }));
index d0609d6df73139bbf55ebf5e404cafe7664632d5..d81ef5022cea599b174e4a4980b05ab738b4b633 100644 (file)
@@ -8,6 +8,7 @@ import { ResourceKind } from "../../models/resource";
 export interface ProjectPanelItem {
     uuid: string;
     name: string;
+    description?: string;
     kind: string;
     url: string;
     owner: string;
@@ -21,6 +22,7 @@ export function resourceToDataItem(r: GroupContentsResource): ProjectPanelItem {
     return {
         uuid: r.uuid,
         name: r.name,
+        description: r.description,
         kind: r.kind,
         url: "",
         owner: r.ownerUuid,
index a8552eef824053bf7c197bc85d18758045a77bdd..8377744c1c0a6d0d28f4e9ffaeae24fb41f832d5 100644 (file)
@@ -257,6 +257,7 @@ export const Workbench = withStyles(styles)(
                     this.openContextMenu(event, {
                         uuid: item.uuid,
                         name: item.name,
+                        description: item.description,
                         kind: ContextMenuKind.COLLECTION
                     });
                 }}
@@ -265,11 +266,20 @@ export const Workbench = withStyles(styles)(
             renderProjectPanel = (props: RouteComponentProps<{ id: string }>) => <ProjectPanel
                 onItemRouteChange={itemId => this.props.dispatch(setProjectItem(itemId, ItemMode.ACTIVE))}
                 onContextMenu={(event, item) => {
+                    let kind: ContextMenuKind;
 
-                    const kind = item.kind === ResourceKind.PROJECT ? ContextMenuKind.PROJECT : ContextMenuKind.RESOURCE;
+                    if (item.kind === ResourceKind.PROJECT) {
+                        kind = ContextMenuKind.PROJECT;
+                    } else if (item.kind === ResourceKind.COLLECTION) {
+                        kind = ContextMenuKind.COLLECTION_RESOURCE;
+                    } else {
+                        kind = ContextMenuKind.RESOURCE;
+                    }
+                    
                     this.openContextMenu(event, {
                         uuid: item.uuid,
                         name: item.name,
+                        description: item.description,
                         kind
                     });
                 }}
@@ -362,7 +372,7 @@ export const Workbench = withStyles(styles)(
                 this.props.dispatch(collectionCreateActions.OPEN_COLLECTION_CREATOR({ ownerUuid: itemUuid }));
             }
 
-            openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; kind: ContextMenuKind; }) => {
+            openContextMenu = (event: React.MouseEvent<HTMLElement>, resource: { name: string; uuid: string; description?: string; kind: ContextMenuKind; }) => {
                 event.preventDefault();
                 this.props.dispatch(
                     contextMenuActions.OPEN_CONTEXT_MENU({