Add typescript paths to top level folders
[arvados-workbench2.git] / src / views-components / create-collection-dialog / create-collection-dialog.tsx
index 0ba2b22add6e33179a04cba44b8e5e3228be6310..94eb82f94e8c89b5aaf354c1c11930d4af8679a9 100644 (file)
@@ -6,12 +6,12 @@ import { connect } from "react-redux";
 import { Dispatch } from "redux";
 import { SubmissionError } from "redux-form";
 
-import { RootState } from "../../store/store";
+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 { collectionCreateActions, createCollection } from "~/store/collections/creator/collection-creator-action";
+import { snackbarActions } from "~/store/snackbar/snackbar-actions";
+import { UploadFile } from "~/store/collections/uploader/collection-uploader-actions";
+import { projectPanelActions } from "~/store/project-panel/project-panel-action";
 
 const mapStateToProps = (state: RootState) => ({
     open: state.collections.creator.opened
@@ -21,22 +21,22 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
     handleClose: () => {
         dispatch(collectionCreateActions.CLOSE_COLLECTION_CREATOR());
     },
-    onSubmit: (data: { name: string, description: string }) => {
-        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 }) =>
+const addCollection = (data: { name: string, description: string }, files: File[]) =>
     (dispatch: Dispatch) => {
-        return dispatch<any>(createCollection(data)).then(() => {
+        return dispatch<any>(createCollection(data, files)).then(() => {
             dispatch(snackbarActions.OPEN_SNACKBAR({
                 message: "Collection has been successfully created.",
                 hideDuration: 2000
             }));
-            dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+            dispatch(projectPanelActions.REQUEST_ITEMS());
         });
     };