X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e4b54c3b5d99c99553e319ead28c3aa8dcd6eecc..074cc61145869165217e2d35a4b949f92a6829e7:/src/store/collections/collection-upload-actions.ts diff --git a/src/store/collections/collection-upload-actions.ts b/src/store/collections/collection-upload-actions.ts index cf8c37c8..e9c5cc35 100644 --- a/src/store/collections/collection-upload-actions.ts +++ b/src/store/collections/collection-upload-actions.ts @@ -3,40 +3,40 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from 'redux'; -import { RootState } from '~/store/store'; -import { ServiceRepository } from '~/services/services'; -import { dialogActions } from '~/store/dialog/dialog-actions'; -import { loadCollectionFiles } from '../collection-panel/collection-panel-files/collection-panel-files-actions'; -import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; -import { fileUploaderActions } from '~/store/file-uploader/file-uploader-actions'; +import { RootState } from 'store/store'; +import { ServiceRepository } from 'services/services'; +import { dialogActions } from 'store/dialog/dialog-actions'; +import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions'; +import { fileUploaderActions } from 'store/file-uploader/file-uploader-actions'; import { reset, startSubmit, stopSubmit } from 'redux-form'; -import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions"; +import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions"; +import * as WorkbenchActions from 'store/workbench/workbench-actions'; -export const uploadCollectionFiles = (collectionUuid: string) => - async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { +export const uploadCollectionFiles = (collectionUuid: string, targetLocation?: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(fileUploaderActions.START_UPLOAD()); const files = getState().fileUploader.map(file => file.file); - await services.collectionService.uploadFiles(collectionUuid, files, handleUploadProgress(dispatch)); + await services.collectionService.uploadFiles(collectionUuid, files, handleUploadProgress(dispatch), targetLocation); + dispatch(WorkbenchActions.loadCollection(collectionUuid)); dispatch(fileUploaderActions.CLEAR_UPLOAD()); }; export const COLLECTION_UPLOAD_FILES_DIALOG = 'uploadCollectionFilesDialog'; -export const openUploadCollectionFilesDialog = () => (dispatch: Dispatch) => { +export const openUploadCollectionFilesDialog = (targetLocation?: string) => (dispatch: Dispatch) => { dispatch(reset(COLLECTION_UPLOAD_FILES_DIALOG)); dispatch(fileUploaderActions.CLEAR_UPLOAD()); - dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPLOAD_FILES_DIALOG, data: {} })); + dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_UPLOAD_FILES_DIALOG, data: { targetLocation } })); }; -export const submitCollectionFiles = () => +export const submitCollectionFiles = (targetLocation?: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const currentCollection = getState().collectionPanel.item; if (currentCollection) { try { dispatch(progressIndicatorActions.START_WORKING(COLLECTION_UPLOAD_FILES_DIALOG)); dispatch(startSubmit(COLLECTION_UPLOAD_FILES_DIALOG)); - await dispatch(uploadCollectionFiles(currentCollection.uuid)); - dispatch(loadCollectionFiles(currentCollection.uuid)); + await dispatch(uploadCollectionFiles(currentCollection.uuid, targetLocation)); dispatch(closeUploadCollectionFilesDialog()); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Data has been uploaded.', @@ -61,4 +61,4 @@ export const closeUploadCollectionFilesDialog = () => dialogActions.CLOSE_DIALOG const handleUploadProgress = (dispatch: Dispatch) => (fileId: number, loaded: number, total: number, currentTime: number) => { dispatch(fileUploaderActions.SET_UPLOAD_PROGRESS({ fileId, loaded, total, currentTime })); -}; +}; \ No newline at end of file