diff --git a/app/assets/javascripts/discourse/app/components/pick-files-button.js b/app/assets/javascripts/discourse/app/components/pick-files-button.js index 56aae7ed42c..3f2482ad50f 100644 --- a/app/assets/javascripts/discourse/app/components/pick-files-button.js +++ b/app/assets/javascripts/discourse/app/components/pick-files-button.js @@ -20,6 +20,7 @@ import I18n from "I18n"; export default Component.extend({ fileInputId: null, fileInputClass: null, + fileInputDisabled: false, classNames: ["pick-files-button"], acceptedFormatsOverride: null, allowMultiple: false, diff --git a/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js b/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js index 1b794cd5c4b..02fd2b93fa2 100644 --- a/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js +++ b/app/assets/javascripts/discourse/app/components/uppy-image-uploader.js @@ -50,6 +50,12 @@ export default Component.extend(UppyUploadMixin, { return { imagesOnly: true }; }, + _uppyReady() { + this._onPreProcessComplete(() => { + this.set("processing", false); + }); + }, + uploadDone(upload) { this.setProperties({ imageFilesize: upload.human_filesize, diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js index 5cfef90d95e..55258c9afb4 100644 --- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js @@ -223,11 +223,11 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { deepMerge(completeResponse, { file_name: file.name }) ); - this._checkInProgressUploads(); + this._triggerInProgressUploadsEvent(); }) .catch((errResponse) => { displayErrorForUpload(errResponse, this.siteSettings, file.name); - this._checkInProgressUploads(); + this._triggerInProgressUploadsEvent(); }); } else { this._removeInProgressUpload(file.id); @@ -238,7 +238,7 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { upload ); this.uploadDone(deepMerge(upload, { file_name: file.name })); - this._checkInProgressUploads(); + this._triggerInProgressUploadsEvent(); } }); @@ -263,6 +263,13 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { }); }); + this._uppyInstance.on("complete", () => { + run(() => { + this.appEvents.trigger(`upload-mixin:${this.id}:all-uploads-complete`); + this._reset(); + }); + }); + // TODO (martin) preventDirectS3Uploads is necessary because some of // the current upload mixin components, for example the emoji uploader, // send the upload to custom endpoints that do fancy things in the rails @@ -316,13 +323,6 @@ export default Mixin.create(UppyS3Multipart, ExtendableUploader, { ); }, - _checkInProgressUploads() { - this._triggerInProgressUploadsEvent(); - if (this.inProgressUploads.length === 0) { - this._reset(); - } - }, - // This should be overridden in a child component if you need to // hook into uppy events and be sure that everything is already // set up for _uppyInstance. diff --git a/app/assets/javascripts/discourse/app/templates/components/pick-files-button.hbs b/app/assets/javascripts/discourse/app/templates/components/pick-files-button.hbs index dc6bc33f6ab..5b91833292b 100644 --- a/app/assets/javascripts/discourse/app/templates/components/pick-files-button.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/pick-files-button.hbs @@ -2,7 +2,7 @@ {{d-button action=(action "openSystemFilePicker") label=label icon=icon}} {{/if}} {{#if acceptsAllFormats}} - + {{else}} - + {{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/components/uppy-image-uploader.hbs b/app/assets/javascripts/discourse/app/templates/components/uppy-image-uploader.hbs index 1038cfe06cc..9244794936c 100644 --- a/app/assets/javascripts/discourse/app/templates/components/uppy-image-uploader.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/uppy-image-uploader.hbs @@ -5,7 +5,7 @@