X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f3d184828b69929818603bd1e88ef8cb98a472df..cfe49be676877567de9704e8d7968d611fa77fc9:/src/store/collections/collection-partial-move-actions.ts?ds=sidebyside diff --git a/src/store/collections/collection-partial-move-actions.ts b/src/store/collections/collection-partial-move-actions.ts index 318971a0..1d979f31 100644 --- a/src/store/collections/collection-partial-move-actions.ts +++ b/src/store/collections/collection-partial-move-actions.ts @@ -3,7 +3,7 @@ // SPDX-License-Identifier: AGPL-3.0 import { Dispatch } from "redux"; -import { initialize, startSubmit } from "redux-form"; +import { initialize, startSubmit, stopSubmit } from "redux-form"; import { CommonResourceServiceError, getCommonResourceServiceError } from "services/common-service/common-resource-service"; import { ServiceRepository } from "services/services"; import { CollectionFileSelection, CollectionPanelDirectory, CollectionPanelFile, filterCollectionFilesBySelection, getCollectionSelection } from "store/collection-panel/collection-panel-files/collection-panel-files-state"; @@ -17,6 +17,7 @@ import { SnackbarKind, snackbarActions } from "store/snackbar/snackbar-actions"; import { RootState } from "store/store"; import { FileOperationLocation } from "store/tree-picker/tree-picker-actions"; import { CollectionResource } from "models/collection"; +import { SOURCE_DESTINATION_EQUAL_ERROR_MESSAGE } from "services/collection-service/collection-service"; export const COLLECTION_PARTIAL_MOVE_TO_NEW_COLLECTION = 'COLLECTION_PARTIAL_MOVE_TO_NEW_DIALOG'; export const COLLECTION_PARTIAL_MOVE_TO_SELECTED_COLLECTION = 'COLLECTION_PARTIAL_MOVE_TO_SELECTED_DIALOG'; @@ -107,6 +108,7 @@ export const moveCollectionPartialToNewCollection = (fileSelection: CollectionFi dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_MOVE_TO_NEW_COLLECTION })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move files to selected collection', hideDuration: 2000, kind: SnackbarKind.ERROR })); } + dispatch(stopSubmit(COLLECTION_PARTIAL_MOVE_TO_NEW_COLLECTION)); dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_MOVE_TO_NEW_COLLECTION)); } } @@ -169,10 +171,13 @@ export const moveCollectionPartialToExistingCollection = (fileSelection: Collect dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_MOVE_TO_SELECTED_COLLECTION)); } catch (e) { const error = getCommonResourceServiceError(e); - if (error === CommonResourceServiceError.UNKNOWN) { + if (error === CommonResourceServiceError.SOURCE_DESTINATION_CANNOT_BE_SAME) { + dispatch(snackbarActions.OPEN_SNACKBAR({ message: SOURCE_DESTINATION_EQUAL_ERROR_MESSAGE, hideDuration: 2000, kind: SnackbarKind.ERROR })); + } else if (error === CommonResourceServiceError.UNKNOWN) { dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_MOVE_TO_SELECTED_COLLECTION })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not copy this files to selected collection', hideDuration: 2000, kind: SnackbarKind.ERROR })); } + dispatch(stopSubmit(COLLECTION_PARTIAL_MOVE_TO_SELECTED_COLLECTION)); dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_MOVE_TO_SELECTED_COLLECTION)); } } @@ -240,6 +245,7 @@ export const moveCollectionPartialToSeparateCollections = (fileSelection: Collec dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_MOVE_TO_SEPARATE_COLLECTIONS })); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been copied but may contain incorrect files.', hideDuration: 2000, kind: SnackbarKind.ERROR })); } + dispatch(stopSubmit(COLLECTION_PARTIAL_MOVE_TO_SEPARATE_COLLECTIONS)); dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_PARTIAL_MOVE_TO_SEPARATE_COLLECTIONS)); } }