X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/d842372e4f45ee06315e511529e65ae1d3f319a0..4f49d0cc42ae4b046b9702d2549097558ae5a928:/src/store/collections/collection-update-actions.ts diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts index 27c3bfce..bf05d4dd 100644 --- a/src/store/collections/collection-update-actions.ts +++ b/src/store/collections/collection-update-actions.ts @@ -6,15 +6,11 @@ import { Dispatch } from "redux"; import { initialize, startSubmit, stopSubmit } from 'redux-form'; import { RootState } from "~/store/store"; import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action"; -import { updateDetails } from "~/store/details-panel/details-panel-action"; import { dialogActions } from "~/store/dialog/dialog-actions"; -import { dataExplorerActions } from "~/store/data-explorer/data-explorer-action"; -import { snackbarActions } from "~/store/snackbar/snackbar-actions"; -import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer'; -import { PROJECT_PANEL_ID } from "~/views/project-panel/project-panel"; -import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service"; +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"; export interface CollectionUpdateFormDialogData { uuid: string; @@ -30,15 +26,6 @@ export const openCollectionUpdateDialog = (resource: ContextMenuResource) => dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME, data: {} })); }; -export const editCollection = (data: CollectionUpdateFormDialogData) => - async (dispatch: Dispatch) => { - await dispatch(updateCollection(data)); - dispatch(snackbarActions.OPEN_SNACKBAR({ - message: "Collection has been successfully updated.", - hideDuration: 2000 - })); - }; - export const updateCollection = (collection: Partial) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const uuid = collection.uuid || ''; @@ -46,13 +33,13 @@ export const updateCollection = (collection: Partial) => try { const updatedCollection = await services.collectionService.update(uuid, collection); dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource })); - dispatch(updateDetails(updatedCollection)); - dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID })); dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME })); - } catch(e) { + return updatedCollection; + } catch (e) { const error = getCommonResourceServiceError(e); if (error === CommonResourceServiceError.UNIQUE_VIOLATION) { dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' })); } + return; } - }; \ No newline at end of file + };