diff --git a/CHANGELOG.md b/CHANGELOG.md index d389f5e6..6cc8a645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * [UIBULKED-318](https://issues.folio.org/browse/UIBULKED-318) Add User filter to Logs tab * [UIBULKED-325](https://issues.folio.org/browse/UIBULKED-325) Rename "Suppressed from discovery" option to "Suppress from discovery" for Items and Holdings * [UIBULKED-337](https://issues.folio.org/browse/UIBULKED-337) *BREAKING* Update `react` to `v18`. +* [UIBULKED-312](https://issues.folio.org/browse/UIBULKED-312) CSV: On cancel button click uploaded file should be deleted. ## [3.0.5](https://github.com/folio-org/ui-bulk-edit/tree/v3.0.5) (2023-03-22) diff --git a/src/components/BulkEditList/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js b/src/components/BulkEditList/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js index c8df8a7c..ee82053e 100644 --- a/src/components/BulkEditList/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js +++ b/src/components/BulkEditList/BulkEditListResult/BulkEditManualUploadModal/BulkEditManualUploadModal.js @@ -23,6 +23,7 @@ import { useUpload, useBulkOperationStart, } from '../../../../hooks/api'; +import { useBulkOperationDelete } from '../../../../hooks/api/useBulkOperationDelete'; const BulkEditManualUploadModal = ({ operationId, @@ -63,6 +64,8 @@ const BulkEditManualUploadModal = ({ const confirmationModalMessage = intl.formatMessage({ id: 'ui-bulk-edit.conformationModal.message' }, { count: countOfRecords }); + const { bulkOperationDelete } = useBulkOperationDelete(); + const swwCallout = (message) => ( callout({ type: 'error', @@ -84,6 +87,7 @@ const BulkEditManualUploadModal = ({ const handleCancel = () => { if (controller.current) controller.current.abort(); + if (fileName) bulkOperationDelete({ operationId }); setCurrentStep(MANUAL_UPLOAD_STEPS.UPLOAD); setFileName(''); diff --git a/src/hooks/api/useBulkOperationDelete.js b/src/hooks/api/useBulkOperationDelete.js new file mode 100644 index 00000000..a934de7d --- /dev/null +++ b/src/hooks/api/useBulkOperationDelete.js @@ -0,0 +1,18 @@ +import { useOkapiKy } from '@folio/stripes/core'; +import { useMutation } from 'react-query'; + +export const useBulkOperationDelete = (mutationOptions = {}) => { + const ky = useOkapiKy(); + + const { mutateAsync: bulkOperationDelete, isLoading } = useMutation({ + mutationFn: async ({ operationId }) => { + await ky.post(`bulk-operations/${operationId}/cancel`); + }, + ...mutationOptions, + }); + + return { + bulkOperationDelete, + isLoading, + }; +}; diff --git a/translations/ui-bulk-edit/en.json b/translations/ui-bulk-edit/en.json index bb869ab3..de24fe20 100644 --- a/translations/ui-bulk-edit/en.json +++ b/translations/ui-bulk-edit/en.json @@ -96,7 +96,7 @@ "modal.fileExtensions.blocked.message": "Only file with .csv extension can be uploaded.", "modal.fileExtensions.blocked.message2": "Only one file with .csv extension can be uploaded.", "modal.fileExtensions.actionButton": "Choose other file to upload", - "modal.successfullMessage": "{fileName} succesfully uploaded.", + "modal.successfullMessage": "{fileName} successfully uploaded.", "modal.next": "Next", "start.edit": "Start bulk edit",