16116: Unifies collections and projects update handling with process. 16116-collection-rename-fix
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 5 Feb 2020 15:23:14 +0000 (12:23 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 5 Feb 2020 15:23:14 +0000 (12:23 -0300)
Fields should be passed explicitly to the api server to avoid unwanted
(and illegal) fields to eventually infiltrate on the api request call.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/store/collections/collection-update-actions.ts
src/store/projects/project-update-actions.ts

index 5b176beac5bd6d2c67bcbca2204e70b307e1c369..f8fac398b7ad3458241213e4f4772be401f43074 100644 (file)
@@ -10,30 +10,29 @@ import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
 import { ServiceRepository } from "~/services/services";
 import { CollectionResource } from '~/models/collection';
-import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
 
 export interface CollectionUpdateFormDialogData {
     uuid: string;
     name: string;
-    description: string;
+    description?: string;
 }
 
 export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateFormName';
 
-export const openCollectionUpdateDialog = (resource: ContextMenuResource) =>
+export const openCollectionUpdateDialog = (resource: CollectionUpdateFormDialogData) =>
     (dispatch: Dispatch) => {
         dispatch(initialize(COLLECTION_UPDATE_FORM_NAME, resource));
         dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME, data: {} }));
     };
 
-export const updateCollection = (collection: Partial<CollectionResource>) =>
+export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const uuid = collection.uuid || '';
         dispatch(startSubmit(COLLECTION_UPDATE_FORM_NAME));
         dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPDATE_FORM_NAME));
         try {
-            const updatedCollection = await services.collectionService.update(uuid, collection);
+            const updatedCollection = await services.collectionService.update(uuid, { name: collection.name, description: collection.description });
             dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource }));
             dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME }));
             dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPDATE_FORM_NAME));
index 2449b9ce9bf1a049eeb7790cfe1fc84ee2ef6b3b..2cb0278872b20cb6150166c4e9cd28302277bf00 100644 (file)
@@ -8,32 +8,28 @@ import { RootState } from "~/store/store";
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
 import { ServiceRepository } from "~/services/services";
-import { ProjectResource } from '~/models/project';
-import { ContextMenuResource } from "~/store/context-menu/context-menu-actions";
-import { getResource } from '~/store/resources/resources';
 import { projectPanelActions } from '~/store/project-panel/project-panel-action';
 
 export interface ProjectUpdateFormDialogData {
     uuid: string;
     name: string;
-    description: string;
+    description?: string;
 }
 
 export const PROJECT_UPDATE_FORM_NAME = 'projectUpdateFormName';
 
-export const openProjectUpdateDialog = (resource: ContextMenuResource) =>
+export const openProjectUpdateDialog = (resource: ProjectUpdateFormDialogData) =>
     (dispatch: Dispatch, getState: () => RootState) => {
-        const project = getResource(resource.uuid)(getState().resources);
-        dispatch(initialize(PROJECT_UPDATE_FORM_NAME, project));
+        dispatch(initialize(PROJECT_UPDATE_FORM_NAME, resource));
         dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_UPDATE_FORM_NAME, data: {} }));
     };
 
-export const updateProject = (project: Partial<ProjectResource>) =>
+export const updateProject = (project: ProjectUpdateFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         const uuid = project.uuid || '';
         dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME));
         try {
-            const updatedProject = await services.projectService.update(uuid, project);
+            const updatedProject = await services.projectService.update(uuid, { name: project.name, description: project.description });
             dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
             return updatedProject;