From: Janicki Artur Date: Fri, 3 Aug 2018 06:27:23 +0000 (+0200) Subject: fix services after merge and improve onSubmit method for save collection X-Git-Tag: 1.2.0~17^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/ecd0b36ecf1afc02871dff06c924131dcaccd856 fix services after merge and improve onSubmit method for save collection Feature #13903 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- diff --git a/src/store/collections/updator/collection-updator-action.ts b/src/store/collections/updator/collection-updator-action.ts index ac422f07..e12bfe54 100644 --- a/src/store/collections/updator/collection-updator-action.ts +++ b/src/store/collections/updator/collection-updator-action.ts @@ -6,7 +6,7 @@ import { default as unionize, ofType, UnionOf } from "unionize"; import { Dispatch } from "redux"; import { RootState } from "../../store"; -import { collectionService } from '../../../services/services'; +import { ServiceRepository } from "../../../services/services"; import { CollectionResource } from '../../../models/collection'; import { initialize } from 'redux-form'; import { collectionPanelActions } from "../../collection-panel/collection-panel-action"; @@ -33,12 +33,12 @@ export const openUpdator = (uuid: string) => }; export const updateCollection = (collection: Partial) => - (dispatch: Dispatch, getState: () => RootState) => { + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const { uuid } = getState().collections.updator; - return collectionService + return services.collectionService .update(uuid, collection) .then(collection => { - dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection })); + dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection as CollectionResource })); dispatch(collectionUpdatorActions.UPDATE_COLLECTION_SUCCESS()); } ); diff --git a/src/views-components/update-collection-dialog/update-collection-dialog..tsx b/src/views-components/update-collection-dialog/update-collection-dialog..tsx index 8daff014..a91277e9 100644 --- a/src/views-components/update-collection-dialog/update-collection-dialog..tsx +++ b/src/views-components/update-collection-dialog/update-collection-dialog..tsx @@ -23,7 +23,9 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ onSubmit: (data: { name: string, description: string }) => { return dispatch(editCollection(data)) .catch((e: any) => { - throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "Collection with this name already exists." : "" }); + if(e.errors) { + throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "Collection with this name already exists." : "" }); + } }); } });