diff --git a/packages/@uppy/dashboard/src/components/FileCard/index.js b/packages/@uppy/dashboard/src/components/FileCard/index.js index 00f5d3323..9231d97d2 100644 --- a/packages/@uppy/dashboard/src/components/FileCard/index.js +++ b/packages/@uppy/dashboard/src/components/FileCard/index.js @@ -45,7 +45,7 @@ class FileCard extends Component { } handleCancel = () => { - this.props.toggleFileCard() + this.props.toggleFileCard(false) } renderMetaFields = () => { diff --git a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js index 8ede028df..0dfb341ca 100644 --- a/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js +++ b/packages/@uppy/dashboard/src/components/FileItem/Buttons/index.js @@ -96,7 +96,7 @@ module.exports = function Buttons (props) { const editAction = () => { if (metaFields && metaFields.length > 0) { - toggleFileCard(file.id) + toggleFileCard(true, file.id) } else { openFileEditor(file) } diff --git a/packages/@uppy/dashboard/src/index.js b/packages/@uppy/dashboard/src/index.js index 114465af2..d728f7493 100644 --- a/packages/@uppy/dashboard/src/index.js +++ b/packages/@uppy/dashboard/src/index.js @@ -399,16 +399,17 @@ module.exports = class Dashboard extends Plugin { this.setDarkModeCapability(isDarkModeOnNow) } - toggleFileCard = (fileId) => { - if (fileId) { - this.uppy.emit('dashboard:file-edit-start') + toggleFileCard = (show, fileID) => { + const file = this.uppy.getFile(fileID) + if (show) { + this.uppy.emit('dashboard:file-edit-start', file) } else { - this.uppy.emit('dashboard:file-edit-complete') + this.uppy.emit('dashboard:file-edit-complete', file) } this.setPluginState({ - fileCardFor: fileId || null, - activeOverlayType: fileId ? 'FileCard' : null + fileCardFor: show ? fileID : null, + activeOverlayType: show ? 'FileCard' : null }) } @@ -765,7 +766,7 @@ module.exports = class Dashboard extends Plugin { saveFileCard = (meta, fileID) => { this.uppy.setFileMeta(fileID, meta) - this.toggleFileCard() + this.toggleFileCard(false, fileID) } _attachRenderFunctionToTarget = (target) => { diff --git a/website/src/docs/dashboard.md b/website/src/docs/dashboard.md index dbe7fd298..8c0c65d84 100644 --- a/website/src/docs/dashboard.md +++ b/website/src/docs/dashboard.md @@ -467,8 +467,16 @@ Fired when the Dashboard modal is closed. ### `dashboard:file-edit-start` +**Parameters:** + +- `file` — The [File Object](https://uppy.io/docs/uppy/#File-Objects) representing the file that was opened for editing. + Fired when the user clicks “edit” icon next to a file in the Dashboard. The FileCard panel is then open with file metadata available for editing. ### `dashboard:file-edit-complete` +**Parameters:** + +- `file` — The [File Object](https://uppy.io/docs/uppy/#File-Objects) representing the file that was edited. + Fired when the user finished editing the file metadata.