X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f1bbac648067f651d408d3cad39fd31d9a36354d..961394c0876cdc07f2195d3bc1843a5c9a6fa950:/src/views-components/create-collection-dialog/create-collection-dialog.tsx

diff --git a/src/views-components/create-collection-dialog/create-collection-dialog.tsx b/src/views-components/create-collection-dialog/create-collection-dialog.tsx
index 8711c5fa15..3f8cc07c24 100644
--- a/src/views-components/create-collection-dialog/create-collection-dialog.tsx
+++ b/src/views-components/create-collection-dialog/create-collection-dialog.tsx
@@ -9,11 +9,8 @@ import { SubmissionError } from "redux-form";
 import { RootState } from "../../store/store";
 import { DialogCollectionCreate } from "../dialog-create/dialog-collection-create";
 import { collectionCreateActions, createCollection } from "../../store/collections/creator/collection-creator-action";
-import { dataExplorerActions } from "../../store/data-explorer/data-explorer-action";
-import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel";
 import { snackbarActions } from "../../store/snackbar/snackbar-actions";
-import { ServiceRepository } from "../../services/services";
-import { CollectionResource } from "../../models/collection";
+import { UploadFile } from "../../store/collections/uploader/collection-uploader-actions";
 
 const mapStateToProps = (state: RootState) => ({
     open: state.collections.creator.opened
@@ -23,24 +20,21 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
     handleClose: () => {
         dispatch(collectionCreateActions.CLOSE_COLLECTION_CREATOR());
     },
-    onSubmit: (data: { name: string, description: string, files: File[] }) => {
-        return dispatch<any>(addCollection(data))
+    onSubmit: (data: { name: string, description: string }, files: UploadFile[]) => {
+        return dispatch<any>(addCollection(data, files.map(f => f.file)))
             .catch((e: any) => {
                 throw new SubmissionError({ name: e.errors.join("").includes("UniqueViolation") ? "Collection with this name already exists." : "" });
             });
     }
 });
 
-const addCollection = (data: { name: string, description: string, files: File[] }) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        return dispatch<any>(createCollection(data)).then((collection: CollectionResource) => {
+const addCollection = (data: { name: string, description: string }, files: File[]) =>
+    (dispatch: Dispatch) => {
+        return dispatch<any>(createCollection(data, files)).then(() => {
             dispatch(snackbarActions.OPEN_SNACKBAR({
                 message: "Collection has been successfully created.",
                 hideDuration: 2000
             }));
-            services.collectionService.uploadFiles(collection.uuid, data.files).then(() => {
-                dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
-            });
         });
     };
 
