From 2e6b59a8e4f0cdc6b0989c0e88a5eee5bd04ca3e Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Wed, 13 Jul 2022 12:23:55 +0000 Subject: [PATCH] [FIX] web_editor: fix upload progress toast visibility Before this commit, when uploading multiple files and clicking on the cross button, the toast was reappearing every time a new file was succesfully uploaded. This commit changes its state so that it is only visible when one or multiple files are added to the uploading queue. The user can still hide it with the cross. task-2687506 Part-of: odoo/odoo#95955 --- .../upload_progress_toast.js | 20 +++++++++---------- .../upload_progress_toast.xml | 6 ++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.js b/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.js index 01ea712306f..997591fa335 100644 --- a/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.js +++ b/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.js @@ -11,21 +11,21 @@ ProgressBar.template = 'web_editor.ProgressBar'; export class UploadProgressToast extends Component { setup() { - this.state = useState({ hide: false }); + this.state = useState({ + isVisible: false, + numberOfFiles: 0, + }); useEffect((numberOfFiles) => { - if (numberOfFiles) { - this.state.hide = false; + if (numberOfFiles === 0) { + this.state.isVisible = false; } + if (numberOfFiles > this.state.numberOfFiles) { + this.state.isVisible = true; + } + this.state.numberOfFiles = numberOfFiles; }, () => [Object.keys(this.props.files).length]); } - - get show() { - if (!this.props.files || !Object.keys(this.props.files).length) { - return false; - } - return !this.state.hide; - } } UploadProgressToast.defaultProps = { files: {}, diff --git a/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.xml b/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.xml index ac8a864d0cd..c31620f3b39 100644 --- a/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.xml +++ b/addons/web_editor/static/src/components/upload_progress_toast/upload_progress_toast.xml @@ -18,10 +18,8 @@
-