[ARVADOS-WORKBENCH2] updated: 1.2.0-173-gddac62f

Git user git at public.curoverse.com
Mon Aug 27 13:00:26 EDT 2018


Summary of changes:
 src/store/collections/collection-copy-actions.ts   |  8 ++-
 src/store/collections/collection-create-actions.ts | 14 +----
 src/store/collections/collection-move-actions.ts   |  2 +
 src/store/collections/collection-update-actions.ts | 15 ++----
 src/store/workbench/workbench-actions.ts           | 62 ++++++++++++++++++++--
 .../dialog-forms/copy-collection-dialog.ts         |  3 +-
 .../dialog-forms/create-collection-dialog.ts       |  6 +--
 .../dialog-forms/move-collection-dialog.ts         |  3 +-
 .../dialog-forms/update-collection-dialog.ts       |  5 +-
 9 files changed, 78 insertions(+), 40 deletions(-)

       via  ddac62fc3f788162bd56bbd5bcacc2f9395c9cca (commit)
      from  64fcf842a75ade29706401a47759deab406f0dfd (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 ddac62fc3f788162bd56bbd5bcacc2f9395c9cca
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 27 19:00:09 2018 +0200

    Delegate collection actions to workbench actions
    
    Feature #14102
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/collections/collection-copy-actions.ts b/src/store/collections/collection-copy-actions.ts
index 80f577e..15ea855 100644
--- a/src/store/collections/collection-copy-actions.ts
+++ b/src/store/collections/collection-copy-actions.ts
@@ -9,8 +9,6 @@ import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree
 import { RootState } from '~/store/store';
 import { ServiceRepository } from '~/services/services';
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/common/api/common-resource-service';
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { projectPanelActions } from '~/store/project-panel/project-panel-action';
 
 export const COLLECTION_COPY_FORM_NAME = 'collectionCopyFormName';
 
@@ -36,16 +34,16 @@ export const copyCollection = (resource: CollectionCopyFormDialogData) =>
             const uuidKey = 'uuid';
             delete collection[uuidKey];
             await services.collectionService.create({ ...collection, ownerUuid: resource.ownerUuid, name: resource.name });
-            dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_COPY_FORM_NAME }));
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied', hideDuration: 2000 }));
+            return collection;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(COLLECTION_COPY_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' }));
             } else {
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_COPY_FORM_NAME }));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not copy the collection', hideDuration: 2000 }));
+                throw new Error('Could not copy the collection.');
             }
+            return ;
         }
     };
\ No newline at end of file
diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
index d8d292c..1981af0 100644
--- a/src/store/collections/collection-create-actions.ts
+++ b/src/store/collections/collection-create-actions.ts
@@ -6,8 +6,6 @@ import { Dispatch } from "redux";
 import { reset, startSubmit, stopSubmit, initialize } from 'redux-form';
 import { RootState } from '~/store/store';
 import { uploadCollectionFiles } from '~/store/collections/uploader/collection-uploader-actions';
-import { projectPanelActions } from "~/store/project-panel/project-panel-action";
-import { snackbarActions } from "~/store/snackbar/snackbar-actions";
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { CollectionResource } from '~/models/collection';
 import { ServiceRepository } from '~/services/services';
@@ -28,28 +26,20 @@ export const openCollectionCreateDialog = (ownerUuid: string) =>
         dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_CREATE_FORM_NAME, data: { ownerUuid } }));
     };
 
-export const addCollection = (data: CollectionCreateFormDialogData) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(createCollection(data));
-        dispatch(snackbarActions.OPEN_SNACKBAR({
-            message: "Collection has been successfully created.",
-            hideDuration: 2000
-        }));
-    };
-
 export const createCollection = (collection: Partial<CollectionResource>) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME));
         try {
             const newCollection = await services.collectionService.create(collection);
             await dispatch<any>(uploadCollectionFiles(newCollection.uuid));
-            dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
             dispatch(reset(COLLECTION_CREATE_FORM_NAME));
+            return newCollection;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
             }
+            return ;
         }
     };
\ No newline at end of file
diff --git a/src/store/collections/collection-move-actions.ts b/src/store/collections/collection-move-actions.ts
index 6fc836f..dcd7b1a 100644
--- a/src/store/collections/collection-move-actions.ts
+++ b/src/store/collections/collection-move-actions.ts
@@ -31,6 +31,7 @@ export const moveCollection = (resource: MoveToFormDialogData) =>
             dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_MOVE_FORM_NAME }));
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved', hideDuration: 2000 }));
+            return collection;
         } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
@@ -39,5 +40,6 @@ export const moveCollection = (resource: MoveToFormDialogData) =>
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_MOVE_FORM_NAME }));
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the collection.', hideDuration: 2000 }));
             }
+            return ;
         }
     };
diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts
index 2aa30d9..75e03d5 100644
--- a/src/store/collections/collection-update-actions.ts
+++ b/src/store/collections/collection-update-actions.ts
@@ -30,15 +30,6 @@ export const openCollectionUpdateDialog = (resource: ContextMenuResource) =>
         dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME, data: {} }));
     };
 
-export const editCollection = (data: CollectionUpdateFormDialogData) =>
-    async (dispatch: Dispatch) => {
-        await dispatch<any>(updateCollection(data));
-        dispatch(snackbarActions.OPEN_SNACKBAR({
-            message: "Collection has been successfully updated.",
-            hideDuration: 2000
-        }));
-    };
-
 export const updateCollection = (collection: Partial<CollectionResource>) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const uuid = collection.uuid || '';
@@ -46,13 +37,13 @@ export const updateCollection = (collection: Partial<CollectionResource>) =>
         try {
             const updatedCollection = await services.collectionService.update(uuid, collection);
             dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource }));
-            dispatch<any>(loadDetailsPanel(updatedCollection.uuid));
-            dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME }));
-        } catch(e) {
+            return updatedCollection;
+        } catch (e) {
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
                 dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
             }
+            return;
         }
     };
\ No newline at end of file
diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts
index 4a0756c..8dc64a8 100644
--- a/src/store/workbench/workbench-actions.ts
+++ b/src/store/workbench/workbench-actions.ts
@@ -10,20 +10,24 @@ import { snackbarActions } from '../snackbar/snackbar-actions';
 import { loadFavoritePanel } from '../favorite-panel/favorite-panel-action';
 import { openProjectPanel, projectPanelActions } from '~/store/project-panel/project-panel-action';
 import { activateSidePanelTreeItem, initSidePanelTree, SidePanelTreeCategory, loadSidePanelTreeProjects } from '../side-panel-tree/side-panel-tree-actions';
-import { loadResource } from '../resources/resources-actions';
+import { loadResource, updateResources } from '../resources/resources-actions';
 import { favoritePanelActions } from '~/store/favorite-panel/favorite-panel-action';
 import { projectPanelColumns } from '~/views/project-panel/project-panel';
 import { favoritePanelColumns } from '~/views/favorite-panel/favorite-panel';
 import { matchRootRoute } from '~/routes/routes';
 import { setCollectionBreadcrumbs, setProjectBreadcrumbs, setSidePanelBreadcrumbs } from '../breadcrumbs/breadcrumbs-actions';
 import { navigateToProject } from '../navigation/navigation-action';
-import * as projectCreateActions from '~/store/projects/project-create-actions';
-import * as projectMoveActions from '~/store/projects/project-move-actions';
-import * as projectUpdateActions from '~/store/projects/project-update-actions';
 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
 import { ServiceRepository } from '~/services/services';
 import { getResource } from '../resources/resources';
 import { getProjectPanelCurrentUuid } from '../project-panel/project-panel-action';
+import * as projectCreateActions from '~/store/projects/project-create-actions';
+import * as projectMoveActions from '~/store/projects/project-move-actions';
+import * as projectUpdateActions from '~/store/projects/project-update-actions';
+import * as collectionCreateActions from '~/store/collections/collection-create-actions';
+import * as collectionCopyActions from '~/store/collections/collection-copy-actions';
+import * as collectionUpdateActions from '~/store/collections/collection-update-actions';
+import * as collectionMoveActions from '~/store/collections/collection-move-actions';
 
 
 export const loadWorkbench = () =>
@@ -118,6 +122,56 @@ export const loadCollection = (uuid: string) =>
         dispatch(loadDetailsPanel(uuid));
     };
 
+export const createCollection = (data: collectionCreateActions.CollectionCreateFormDialogData) =>
+    async (dispatch: Dispatch) => {
+        const collection = await dispatch<any>(collectionCreateActions.createCollection(data));
+        if (collection) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Collection has been successfully created.",
+                hideDuration: 2000
+            }));
+            dispatch<any>(updateResources([collection]));
+            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
+        }
+    };
+
+export const updateCollection = (data: collectionUpdateActions.CollectionUpdateFormDialogData) =>
+    async (dispatch: Dispatch) => {
+        const collection = await dispatch<any>(collectionUpdateActions.updateCollection(data));
+        if (collection) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({
+                message: "Collection has been successfully updated.",
+                hideDuration: 2000
+            }));
+            dispatch<any>(updateResources([collection]));
+            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
+        }
+    };
+
+export const copyCollection = (data: collectionCopyActions.CollectionCopyFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const collection = await dispatch<any>(collectionCopyActions.copyCollection(data));
+            dispatch<any>(updateResources([collection]));
+            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied.', hideDuration: 2000 }));
+        } catch (e) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
+        }
+    };
+
+export const moveCollection = (data: MoveToFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        try {
+            const collection = await dispatch<any>(collectionMoveActions.moveCollection(data));
+            dispatch<any>(updateResources([collection]));
+            dispatch<any>(reloadProjectMatchingUuid([collection.ownerUuid]));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved.', hideDuration: 2000 }));
+        } catch (e) {
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.message, hideDuration: 2000 }));
+        }
+    };
+
 export const resourceIsNotLoaded = (uuid: string) =>
     snackbarActions.OPEN_SNACKBAR({
         message: `Resource identified by ${uuid} is not loaded.`
diff --git a/src/views-components/dialog-forms/copy-collection-dialog.ts b/src/views-components/dialog-forms/copy-collection-dialog.ts
index ee6293a..245465f 100644
--- a/src/views-components/dialog-forms/copy-collection-dialog.ts
+++ b/src/views-components/dialog-forms/copy-collection-dialog.ts
@@ -5,8 +5,9 @@
 import { compose } from "redux";
 import { withDialog } from "~/store/dialog/with-dialog";
 import { reduxForm } from 'redux-form';
-import { COLLECTION_COPY_FORM_NAME, CollectionCopyFormDialogData, copyCollection } from '~/store/collections/collection-copy-actions';
+import { COLLECTION_COPY_FORM_NAME, CollectionCopyFormDialogData } from '~/store/collections/collection-copy-actions';
 import { DialogCollectionCopy } from "~/views-components/dialog-copy/dialog-collection-copy";
+import { copyCollection } from '~/store/workbench/workbench-actions';
 
 export const CopyCollectionDialog = compose(
     withDialog(COLLECTION_COPY_FORM_NAME),
diff --git a/src/views-components/dialog-forms/create-collection-dialog.ts b/src/views-components/dialog-forms/create-collection-dialog.ts
index d2699d8..581743e 100644
--- a/src/views-components/dialog-forms/create-collection-dialog.ts
+++ b/src/views-components/dialog-forms/create-collection-dialog.ts
@@ -5,16 +5,16 @@
 import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
-import { addCollection, COLLECTION_CREATE_FORM_NAME, CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
-import { UploadFile } from "~/store/collections/uploader/collection-uploader-actions";
+import { COLLECTION_CREATE_FORM_NAME, CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions';
 import { DialogCollectionCreate } from "~/views-components/dialog-create/dialog-collection-create";
+import { createCollection } from "~/store/workbench/workbench-actions";
 
 export const CreateCollectionDialog = compose(
     withDialog(COLLECTION_CREATE_FORM_NAME),
     reduxForm<CollectionCreateFormDialogData>({
         form: COLLECTION_CREATE_FORM_NAME,
         onSubmit: (data, dispatch) => {
-            dispatch(addCollection(data));
+            dispatch(createCollection(data));
         }
     })
 )(DialogCollectionCreate);
diff --git a/src/views-components/dialog-forms/move-collection-dialog.ts b/src/views-components/dialog-forms/move-collection-dialog.ts
index 38d6d03..fcdd999 100644
--- a/src/views-components/dialog-forms/move-collection-dialog.ts
+++ b/src/views-components/dialog-forms/move-collection-dialog.ts
@@ -6,8 +6,9 @@ import { compose } from "redux";
 import { withDialog } from "~/store/dialog/with-dialog";
 import { reduxForm } from 'redux-form';
 import { DialogMoveTo } from '~/views-components/dialog-move/dialog-move-to';
-import { COLLECTION_MOVE_FORM_NAME, moveCollection } from '~/store/collections/collection-move-actions';
+import { COLLECTION_MOVE_FORM_NAME } from '~/store/collections/collection-move-actions';
 import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
+import { moveCollection } from '~/store/workbench/workbench-actions';
 
 export const MoveCollectionDialog = compose(
     withDialog(COLLECTION_MOVE_FORM_NAME),
diff --git a/src/views-components/dialog-forms/update-collection-dialog.ts b/src/views-components/dialog-forms/update-collection-dialog.ts
index 2c4296d..cfa5263 100644
--- a/src/views-components/dialog-forms/update-collection-dialog.ts
+++ b/src/views-components/dialog-forms/update-collection-dialog.ts
@@ -6,14 +6,15 @@ import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
 import { DialogCollectionUpdate } from '~/views-components/dialog-update/dialog-collection-update';
-import { editCollection, COLLECTION_UPDATE_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
+import { COLLECTION_UPDATE_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
+import { updateCollection } from "~/store/workbench/workbench-actions";
 
 export const UpdateCollectionDialog = compose(
     withDialog(COLLECTION_UPDATE_FORM_NAME),
     reduxForm<CollectionUpdateFormDialogData>({
         form: COLLECTION_UPDATE_FORM_NAME,
         onSubmit: (data, dispatch) => {
-            dispatch(editCollection(data));
+            dispatch(updateCollection(data));
         }
     })
 )(DialogCollectionUpdate);
\ No newline at end of file

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list