DEV: Change images-uploader to use Uppy (#15375)

Missed this one, it is only used for the selectable_avatars
site setting.
This commit is contained in:
Martin Brennan 2021-12-21 15:53:44 +10:00 committed by GitHub
parent d330a5447d
commit 3ca1b17589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -1,15 +1,15 @@
import Component from "@ember/component"; import Component from "@ember/component";
import I18n from "I18n"; import I18n from "I18n";
import UploadMixin from "discourse/mixins/upload"; import UppyUploadMixin from "discourse/mixins/uppy-upload";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend(UploadMixin, { export default Component.extend(UppyUploadMixin, {
type: "avatar", type: "avatar",
tagName: "span", tagName: "span",
@discourseComputed("uploading") @discourseComputed("uploadingOrProcessing")
uploadButtonText(uploading) { uploadButtonText(uploadingOrProcessing) {
return uploading ? I18n.t("uploading") : I18n.t("upload"); return uploadingOrProcessing ? I18n.t("uploading") : I18n.t("upload");
}, },
validateUploadedFilesOptions() { validateUploadedFilesOptions() {

View File

@ -1,4 +1,5 @@
import Mixin from "@ember/object/mixin"; import Mixin from "@ember/object/mixin";
import { or } from "@ember/object/computed";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { import {
@ -42,6 +43,8 @@ export default Mixin.create(UppyS3Multipart, {
return {}; return {};
}, },
uploadingOrProcessing: or("uploading", "processing"),
@on("willDestroyElement") @on("willDestroyElement")
_destroy() { _destroy() {
if (this.messageBus) { if (this.messageBus) {

View File

@ -1,7 +1,7 @@
<label class="btn" disabled={{uploading}} title={{i18n "admin.site_settings.uploaded_image_list.upload.title"}}> <label class="btn" disabled={{uploadingOrProcessing}} title={{i18n "admin.site_settings.uploaded_image_list.upload.title"}}>
{{d-icon "far-image"}}&nbsp;{{uploadButtonText}} {{d-icon "far-image"}}&nbsp;{{uploadButtonText}}
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" multiple> <input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" multiple>
</label> </label>
{{#if uploading}} {{#if uploadingOrProcessing}}
<span>{{i18n "upload_selector.uploading"}} {{uploadProgress}}%</span> <span>{{i18n "upload_selector.uploading"}} {{uploadProgress}}%</span>
{{/if}} {{/if}}