From 637d66ee33190a45690bfdef74bc46f3f480e5c4 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 22 Aug 2019 15:33:10 -0300 Subject: [PATCH] 15027: Fixes collection update requests to only send what's being updated. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../collection-files-service.ts | 3 +-- .../collection-panel-action.ts | 23 +++++++++++-------- .../collections/collection-move-actions.ts | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/services/collection-files-service/collection-files-service.ts b/src/services/collection-files-service/collection-files-service.ts index 9cda22b2..3a209406 100644 --- a/src/services/collection-files-service/collection-files-service.ts +++ b/src/services/collection-files-service/collection-files-service.ts @@ -40,8 +40,7 @@ export class CollectionFilesService { : stream ); const manifestText = stringifyKeepManifest(updatedManifest); - const data = { ...collection, manifestText }; - return this.collectionService.update(collectionUuid, CommonResourceService.mapKeys(_.snakeCase)(data)); + return this.collectionService.update(collectionUuid, { manifestText }); } async deleteFile(collectionUuid: string, file: { name: string, path: string }) { diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index cb28fcea..159fb27d 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -45,11 +45,14 @@ export const createCollectionTag = (data: TagProperty) => const uuid = item ? item.uuid : ''; try { if (item) { - const d: Partial = { - properties: JSON.parse(JSON.stringify(item.properties)) - }; - d.properties[data.key] = data.value; - const updatedCollection = await services.collectionService.update(uuid, d); + const updatedCollection = await services.collectionService.update( + uuid, { + properties: { + ...JSON.parse(JSON.stringify(item.properties)), + [data.key]: data.value + } + } + ); item.properties[data.key] = data.value; dispatch(resourcesActions.SET_RESOURCES([updatedCollection])); dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS })); @@ -78,12 +81,12 @@ export const deleteCollectionTag = (key: string) => const uuid = item ? item.uuid : ''; try { if (item) { - const data: Partial = { - properties: JSON.parse(JSON.stringify(item.properties)) - }; - delete data.properties[key]; - const updatedCollection = await services.collectionService.update(uuid, data); delete item.properties[key]; + const updatedCollection = await services.collectionService.update( + uuid, { + properties: {...item.properties} + } + ); dispatch(resourcesActions.SET_RESOURCES([updatedCollection])); dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS })); return updatedCollection; diff --git a/src/store/collections/collection-move-actions.ts b/src/store/collections/collection-move-actions.ts index dc73e5a5..0351e746 100644 --- a/src/store/collections/collection-move-actions.ts +++ b/src/store/collections/collection-move-actions.ts @@ -30,8 +30,8 @@ export const moveCollection = (resource: MoveToFormDialogData) => dispatch(startSubmit(COLLECTION_MOVE_FORM_NAME)); try { dispatch(progressIndicatorActions.START_WORKING(COLLECTION_MOVE_FORM_NAME)); + await services.collectionService.update(resource.uuid, { ownerUuid: resource.ownerUuid }); const collection = await services.collectionService.get(resource.uuid); - await services.collectionService.update(resource.uuid, { ...collection, ownerUuid: resource.ownerUuid }); dispatch(projectPanelActions.REQUEST_ITEMS()); dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_MOVE_FORM_NAME })); dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_MOVE_FORM_NAME)); -- 2.30.2