[ARVADOS-WORKBENCH2] updated: 1.1.4-449-ga3e0dc8

Git user git at public.curoverse.com
Thu Aug 2 07:03:46 EDT 2018


Summary of changes:
 src/common/api/common-resource-service.ts          |  7 +++--
 .../collection-panel/collection-panel-action.ts    |  2 +-
 .../updator/collection-updator-action.ts           | 30 ++++++++++++++++------
 .../updator/collection-updator-reducer.ts          |  9 +++----
 .../action-sets/collection-action-set.ts           |  4 +--
 .../dialog-update/dialog-collection-update.tsx     |  3 ++-
 src/views/collection-panel/collection-panel.tsx    |  7 +++--
 7 files changed, 39 insertions(+), 23 deletions(-)

       via  a3e0dc8338ab730f62d442b9dfcf18cc2e649253 (commit)
      from  4b065bb111ccdfdde1756e6507b84b72ce67c511 (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 a3e0dc8338ab730f62d442b9dfcf18cc2e649253
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Thu Aug 2 13:03:34 2018 +0200

    init and save form, modify store
    
    Feature #13903
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/common/api/common-resource-service.ts b/src/common/api/common-resource-service.ts
index 3956fb7..8ad8fe9 100644
--- a/src/common/api/common-resource-service.ts
+++ b/src/common/api/common-resource-service.ts
@@ -100,8 +100,11 @@ export class CommonResourceService<T extends Resource> {
                 }));
     }
 
-    update(uuid: string) {
-        throw new Error("Not implemented");
+    update(uuid: string, data: any) {
+        return CommonResourceService.defaultResponse(
+            this.serverApi
+                .put<T>(this.resourceType + uuid, data));
+        
     }
 }
 
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index 946836a..c0d3366 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -21,7 +21,7 @@ export const loadCollection = (uuid: string, kind: ResourceKind) =>
         return collectionService
             .get(uuid)
             .then(item => {
-                dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource }));
+                dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item }));
             });
     };
 
diff --git a/src/store/collections/updator/collection-updator-action.ts b/src/store/collections/updator/collection-updator-action.ts
index 5272baa..ac422f0 100644
--- a/src/store/collections/updator/collection-updator-action.ts
+++ b/src/store/collections/updator/collection-updator-action.ts
@@ -8,26 +8,40 @@ import { Dispatch } from "redux";
 import { RootState } from "../../store";
 import { collectionService } from '../../../services/services';
 import { CollectionResource } from '../../../models/collection';
+import { initialize } from 'redux-form';
+import { collectionPanelActions } from "../../collection-panel/collection-panel-action";
 
 export const collectionUpdatorActions = unionize({
-    OPEN_COLLECTION_UPDATOR: ofType<{ ownerUuid: string }>(),
+    OPEN_COLLECTION_UPDATOR: ofType<{ uuid: string }>(),
     CLOSE_COLLECTION_UPDATOR: ofType<{}>(),
-    UPDATE_COLLECTION: ofType<{}>(),
     UPDATE_COLLECTION_SUCCESS: ofType<{}>(),
 }, {
         tag: 'type',
         value: 'payload'
     });
 
+
+export const COLLECTION_FORM_NAME = 'collectionEditDialog';
+    
+export const openUpdator = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState) => {
+        dispatch(collectionUpdatorActions.OPEN_COLLECTION_UPDATOR({ uuid }));
+        const item = getState().collectionPanel.item;
+        if(item) {
+            dispatch(initialize(COLLECTION_FORM_NAME, { name: item.name, description: item.description }));
+        }
+    };
+
 export const updateCollection = (collection: Partial<CollectionResource>) =>
     (dispatch: Dispatch, getState: () => RootState) => {
-        const { ownerUuid } = getState().collections.creator;
-        const collectiontData = { ownerUuid, ...collection };
-        dispatch(collectionUpdatorActions.UPDATE_COLLECTION(collectiontData));
+        const { uuid } = getState().collections.updator;
         return collectionService
-            // change for update
-            .create(collectiontData)
-            .then(collection => dispatch(collectionUpdatorActions.UPDATE_COLLECTION_SUCCESS(collection)));
+            .update(uuid, collection)
+            .then(collection => {
+                    dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection }));
+                    dispatch(collectionUpdatorActions.UPDATE_COLLECTION_SUCCESS());
+                }
+            );
     };
 
 export type CollectionUpdatorAction = UnionOf<typeof collectionUpdatorActions>;
\ No newline at end of file
diff --git a/src/store/collections/updator/collection-updator-reducer.ts b/src/store/collections/updator/collection-updator-reducer.ts
index f47f196..b9d0250 100644
--- a/src/store/collections/updator/collection-updator-reducer.ts
+++ b/src/store/collections/updator/collection-updator-reducer.ts
@@ -8,7 +8,7 @@ export type CollectionUpdatorState = CollectionUpdator;
 
 interface CollectionUpdator {
     opened: boolean;
-    ownerUuid: string;
+    uuid: string;
 }
 
 const updateCollection = (state: CollectionUpdatorState, updator?: Partial<CollectionUpdator>) => ({
@@ -18,15 +18,14 @@ const updateCollection = (state: CollectionUpdatorState, updator?: Partial<Colle
 
 const initialState: CollectionUpdatorState = {
     opened: false,
-    ownerUuid: ''
+    uuid: ''
 };
 
 export const collectionCreationReducer = (state: CollectionUpdatorState = initialState, action: CollectionUpdatorAction) => {
     return collectionUpdatorActions.match(action, {
-        OPEN_COLLECTION_UPDATOR: ({ ownerUuid }) => updateCollection(state, { ownerUuid, opened: true }),
+        OPEN_COLLECTION_UPDATOR: ({ uuid }) => updateCollection(state, { uuid, opened: true }),
         CLOSE_COLLECTION_UPDATOR: () => updateCollection(state, { opened: false }),
-        UPDATE_COLLECTION: () => updateCollection(state),
-        UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, ownerUuid: "" }),
+        UPDATE_COLLECTION_SUCCESS: () => updateCollection(state, { opened: false, uuid: "" }),
         default: () => state
     });
 };
diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts
index 7f9cbc1..9e3ff34 100644
--- a/src/views-components/context-menu/action-sets/collection-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-action-set.ts
@@ -8,14 +8,14 @@ import { toggleFavorite } from "../../../store/favorites/favorites-actions";
 import { dataExplorerActions } from "../../../store/data-explorer/data-explorer-action";
 import { FAVORITE_PANEL_ID } from "../../../views/favorite-panel/favorite-panel";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "../../../components/icon/icon";
-import { collectionUpdatorActions } from "../../../store/collections/updator/collection-updator-action";
+import { openUpdator } from "../../../store/collections/updator/collection-updator-action";
 
 export const collectionActionSet: ContextMenuActionSet = [[
     {
         icon: RenameIcon,
         name: "Edit collection",
         execute: (dispatch, resource) => {
-            dispatch(collectionUpdatorActions.OPEN_COLLECTION_UPDATOR({ ownerUuid: resource.uuid }));
+            dispatch<any>(openUpdator(resource.uuid));
         }
     },
     {
diff --git a/src/views-components/dialog-update/dialog-collection-update.tsx b/src/views-components/dialog-update/dialog-collection-update.tsx
index 30a3256..80a82b2 100644
--- a/src/views-components/dialog-update/dialog-collection-update.tsx
+++ b/src/views-components/dialog-update/dialog-collection-update.tsx
@@ -8,6 +8,7 @@ import { compose } from 'redux';
 import { ArvadosTheme } from '../../common/custom-theme';
 import { Dialog, DialogActions, DialogContent, DialogTitle, TextField, StyleRulesCallback, withStyles, WithStyles, Button, CircularProgress } from '../../../node_modules/@material-ui/core';
 import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
+import { COLLECTION_FORM_NAME } from '../../store/collections/updator/collection-updator-action';
 
 type CssRules = 'content' | 'actions' | 'textField' | 'buttonWrapper' | 'saveButton' | 'circularProgress';
 
@@ -64,7 +65,7 @@ interface TextFieldProps {
 }
 
 export const DialogCollectionUpdate = compose(
-    reduxForm({ form: 'collectionEditDialog' }),
+    reduxForm({ form: COLLECTION_FORM_NAME }),
     withStyles(styles))(
 
         class DialogCollectionUpdate extends React.Component<DialogCollectionProps> {
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 71ec309..340d7c9 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -59,13 +59,12 @@ export const CollectionPanel = withStyles(styles)(
                                         <MoreOptionsIcon />
                                     </IconButton> 
                                 }
-                                title={item && item.name } />
+                                title={item && item.name } 
+                                subheader={item && item.description} />
                             <CardContent>
                                 <Grid container direction="column">
                                     <Grid item xs={6}>
-                                    <DetailsAttribute label='Collection UUID' value={item && item.uuid}>
-                                        Here I will add copy
-                                    </DetailsAttribute>
+                                    <DetailsAttribute label='Collection UUID' value={item && item.uuid} />
                                     <DetailsAttribute label='Content size' value='54 MB' />
                                     <DetailsAttribute label='Owner' value={item && item.ownerUuid} />
                                     </Grid>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list