2024-10-23 17:08:09 +08:00
|
|
|
import Component from "@ember/component";
|
|
|
|
import { getOwner } from "@ember/owner";
|
|
|
|
import { tagName } from "@ember-decorators/component";
|
|
|
|
import UppyUpload from "discourse/lib/uppy/uppy-upload";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from "discourse-i18n";
|
2024-10-23 17:08:09 +08:00
|
|
|
|
|
|
|
@tagName("span")
|
|
|
|
export default class ImagesUploader extends Component {
|
|
|
|
uppyUpload = new UppyUpload(getOwner(this), {
|
|
|
|
id: "images-uploader",
|
|
|
|
type: "avatar",
|
|
|
|
validateUploadedFilesOptions: {
|
|
|
|
imagesOnly: true,
|
|
|
|
},
|
|
|
|
uploadDone: (upload) => {
|
|
|
|
this.done(upload);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
get uploadingOrProcessing() {
|
|
|
|
return this.uppyUpload.uploading || this.uppyUpload.processing;
|
|
|
|
}
|
|
|
|
|
|
|
|
get uploadButtonText() {
|
2024-11-20 04:45:18 +08:00
|
|
|
return this.uploadingOrProcessing ? i18n("uploading") : i18n("upload");
|
2024-10-23 17:08:09 +08:00
|
|
|
}
|
|
|
|
}
|