Merge remote-tracking branch 'origin/main' into 18207-Workbench2-is-not-clearing...
[arvados-workbench2.git] / src / store / collections / collection-update-actions.ts
index c753aeb6088defb93834fc0d74a519dfcccc3d0f..04f42b8d82f033b8a4d87690bfa988976ad06c40 100644 (file)
@@ -4,21 +4,23 @@
 
 import { Dispatch } from "redux";
 import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
-import { RootState } from "~/store/store";
-import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
-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 { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { RootState } from "store/store";
+import { collectionPanelActions } from "store/collection-panel/collection-panel-action";
+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 { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions";
 import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
 import { updateResources } from "../resources/resources-actions";
 import { loadDetailsPanel } from "../details-panel/details-panel-action";
+import { getResource } from "store/resources/resources";
 
 export interface CollectionUpdateFormDialogData {
     uuid: string;
     name: string;
     description?: string;
+    storageClassesDesired?: string[];
 }
 
 export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateFormName';
@@ -35,10 +37,13 @@ export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
         dispatch(startSubmit(COLLECTION_UPDATE_FORM_NAME));
         dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPDATE_FORM_NAME));
 
+        const cachedCollection = getResource<CollectionResource>(collection.uuid)(getState().resources);
         services.collectionService.update(uuid, {
             name: collection.name,
+            storageClassesDesired: collection.storageClassesDesired,
             description: collection.description }
         ).then(updatedCollection => {
+            updatedCollection = {...cachedCollection, ...updatedCollection};
             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));