From eab4ddd55c47634355a57072591ecd936ee33a67 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Wed, 24 Jun 2020 18:27:19 +0100 Subject: [PATCH] Add reason argument to `removeFiles` --- packages/@uppy/core/src/index.js | 10 +++++----- .../dashboard/src/components/FileItem/Buttons/index.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@uppy/core/src/index.js b/packages/@uppy/core/src/index.js index 9fe1944c5..86dfbaa1b 100644 --- a/packages/@uppy/core/src/index.js +++ b/packages/@uppy/core/src/index.js @@ -711,7 +711,7 @@ class Uppy { } } - removeFiles (fileIDs) { + removeFiles (fileIDs, reason) { const { files, currentUploads } = this.getState() const updatedFiles = { ...files } const updatedUploads = { ...currentUploads } @@ -764,7 +764,7 @@ class Uppy { const removedFileIDs = Object.keys(removedFiles) removedFileIDs.forEach((fileID) => { - this.emit('file-removed', removedFiles[fileID]) + this.emit('file-removed', removedFiles[fileID], reason) }) if (removedFileIDs.length > 5) { @@ -774,8 +774,8 @@ class Uppy { } } - removeFile (fileID) { - this.removeFiles([fileID]) + removeFile (fileID, reason = null) { + this.removeFiles([fileID], reason) } pauseResume (fileID) { @@ -866,7 +866,7 @@ class Uppy { const fileIDs = Object.keys(files) if (fileIDs.length) { - this.removeFiles(fileIDs) + this.removeFiles(fileIDs, 'cancel-all') } this.setState({ diff --git a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js index c616a6b00..b804174ad 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js +++ b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js @@ -112,7 +112,7 @@ module.exports = function Buttons (props) { i18n={i18n} info={props.info} log={props.log} - onClick={() => removeFile(file.id)} + onClick={() => removeFile(file.id, 'removed-by-user')} /> ) : null}