store project - fix test, update panel details after edit resource, change label tag
authorJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 16 Aug 2018 08:21:43 +0000 (10:21 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Thu, 16 Aug 2018 08:21:43 +0000 (10:21 +0200)
Feature #13833

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

src/store/collections/updater/collection-updater-action.ts
src/store/details-panel/details-panel-action.ts
src/store/details-panel/details-panel-reducer.ts
src/store/project/project-action.ts
src/store/project/project-reducer.test.ts
src/views-components/update-project-dialog/update-project-dialog.tsx
src/views/collection-panel/collection-panel.tsx

index 25b2f37ac1f72ecaca4172a8a173553841253abe..2f520d4a384f84b63982bfa12fd13dd8ece81e9b 100644 (file)
@@ -11,6 +11,7 @@ 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";
+import { updateDetails } from "~/store/details-panel/details-panel-action";
 
 export const collectionUpdaterActions = unionize({
     OPEN_COLLECTION_UPDATER: ofType<{ uuid: string }>(),
@@ -40,6 +41,7 @@ export const updateCollection = (collection: Partial<CollectionResource>) =>
             .then(collection => {
                     dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection as CollectionResource }));
                     dispatch(collectionUpdaterActions.UPDATE_COLLECTION_SUCCESS());
+                    dispatch<any>(updateDetails(collection));
                 }
             );
     };
index cadf517ac2376f50f9b643ac0cc5f0519371caa4..b8021fb6a0d81d12588b2efe921a0d3142c7df6c 100644 (file)
@@ -12,6 +12,7 @@ export const detailsPanelActions = unionize({
     TOGGLE_DETAILS_PANEL: ofType<{}>(),
     LOAD_DETAILS: ofType<{ uuid: string, kind: ResourceKind }>(),
     LOAD_DETAILS_SUCCESS: ofType<{ item: Resource }>(),
+    UPDATE_DETAILS: ofType<{ item: Resource }>()
 }, { tag: 'type', value: 'payload' });
 
 export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
@@ -23,6 +24,16 @@ export const loadDetails = (uuid: string, kind: ResourceKind) =>
         dispatch(detailsPanelActions.LOAD_DETAILS_SUCCESS({ item }));
     };
 
+export const updateDetails = (item: Resource) => 
+    async (dispatch: Dispatch, getState: () => RootState) => {
+        const currentItem = getState().detailsPanel.item;
+        if (currentItem && (currentItem.uuid === item.uuid)) {
+            dispatch(detailsPanelActions.UPDATE_DETAILS({ item }));
+            dispatch(detailsPanelActions.LOAD_DETAILS_SUCCESS({ item }));
+        }
+    };
+
+
 const getService = (services: ServiceRepository, kind: ResourceKind) => {
     switch (kind) {
         case ResourceKind.PROJECT:
index adc31e4bd6f60f55eff6e6f45ea6cae0ac6b275f..f22add3d49b08810a2c5cf248ca4f90503dc0a1d 100644 (file)
@@ -18,7 +18,6 @@ const initialState = {
 export const detailsPanelReducer = (state: DetailsPanelState = initialState, action: DetailsPanelAction) =>
     detailsPanelActions.match(action, {
         default: () => state,
-        LOAD_DETAILS: () => state,
         LOAD_DETAILS_SUCCESS: ({ item }) => ({ ...state, item }),
         TOGGLE_DETAILS_PANEL: () => ({ ...state, isOpened: !state.isOpened })
     });
index 70800909cdc18035f4565a2e7abc7c177af746b9..96ad62853bf5c0b5be6157b62eebaee74b9cc2d0 100644 (file)
@@ -10,6 +10,7 @@ import { RootState } from "../store";
 import { checkPresenceInFavorites } from "../favorites/favorites-actions";
 import { ServiceRepository } from "~/services/services";
 import { projectPanelActions } from "~/store/project-panel/project-panel-action";
+import { updateDetails } from "~/store/details-panel/details-panel-action";
 
 export const projectActions = unionize({
     OPEN_PROJECT_CREATOR: ofType<{ ownerUuid: string }>(),
@@ -65,7 +66,7 @@ export const updateProject = (project: Partial<ProjectResource>) =>
                 dispatch(projectActions.UPDATE_PROJECT_SUCCESS(project));
                 dispatch(projectPanelActions.REQUEST_ITEMS());
                 dispatch<any>(getProjectList(project.ownerUuid));
-                // ToDo: Update Panel Details
+                dispatch<any>(updateDetails(project));
             });
     };
 
index d5963f334994b545504a802ed3df97892342069d..bb60e396946a588f8d93a1c1f7e6803461ba82eb 100644 (file)
@@ -127,6 +127,7 @@ describe('project-reducer', () => {
             }],
             currentItemId: "1",
             creator: { opened: false, ownerUuid: "" },
+            updater: { opened: false, uuid: '' }
 
         };
 
index c45584264f50a3b8201afa57dc7f07728b422528..0ea23c8fe1609558f68f599d12b613394915f84b 100644 (file)
@@ -22,7 +22,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
         return dispatch<any>(editProject(data))
             .catch((e: any) => {
                 if (e.errors) {
-                    throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "CProject with this name already exists." : "" });
+                    throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "Project with this name already exists." : "" });
                 }
             });
     }
index 5baa6d18753fd7e1f6a0198eb942d7c922538a59..374cb95159483f5d4896fcbd539fddfc61931ea3 100644 (file)
@@ -100,7 +100,7 @@ export const CollectionPanel = withStyles(styles)(
                         </Card>
 
                         <Card className={classes.card}>
-                            <CardHeader title="Tags" />
+                            <CardHeader title="Properties" />
                             <CardContent>
                                 <Grid container direction="column">
                                     <Grid item xs={12}><CollectionTagForm /></Grid>