mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
DEV: Update create-invite-uploader uppy usage (#29282)
This commit is contained in:
parent
c90fe2666f
commit
4dabdd38db
@ -5,7 +5,7 @@
|
||||
uploadProgress=this.uploadProgress
|
||||
uploaded=this.uploaded
|
||||
submitDisabled=this.submitDisabled
|
||||
startUpload=(action "startUpload")
|
||||
startUpload=this.startUpload
|
||||
)
|
||||
this.setElement
|
||||
this.uppyUpload.setup
|
||||
}}
|
@ -1,40 +1,34 @@
|
||||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { getOwner } from "@ember/owner";
|
||||
import { tagName } from "@ember-decorators/component";
|
||||
import UppyUploadMixin from "discourse/mixins/uppy-upload";
|
||||
import UppyUpload from "discourse/lib/uppy/uppy-upload";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
@tagName("div")
|
||||
export default class CreateInviteUploader extends Component.extend(
|
||||
UppyUploadMixin
|
||||
) {
|
||||
id = "create-invite-uploader";
|
||||
type = "csv";
|
||||
autoStartUploads = false;
|
||||
uploadUrl = "/invites/upload_csv";
|
||||
preventDirectS3Uploads = true;
|
||||
fileInputSelector = "#csv-file";
|
||||
export default class CreateInviteUploader extends Component {
|
||||
uppyUpload = new UppyUpload(getOwner(this), {
|
||||
id: "create-invite-uploader",
|
||||
type: "csv",
|
||||
autoStartUploads: false,
|
||||
uploadUrl: "/invites/upload_csv",
|
||||
preventDirectS3Uploads: true,
|
||||
validateUploadedFilesOptions: {
|
||||
bypassNewUserRestriction: true,
|
||||
csvOnly: true,
|
||||
},
|
||||
uploadDone: () => {
|
||||
this.set("uploaded", true);
|
||||
},
|
||||
});
|
||||
|
||||
validateUploadedFilesOptions() {
|
||||
return { bypassNewUserRestriction: true, csvOnly: true };
|
||||
}
|
||||
|
||||
@discourseComputed("filesAwaitingUpload", "uploading")
|
||||
@discourseComputed("uppyUpload.filesAwaitingUpload", "uppyUpload.uploading")
|
||||
submitDisabled(filesAwaitingUpload, uploading) {
|
||||
return !filesAwaitingUpload || uploading;
|
||||
}
|
||||
|
||||
uploadDone() {
|
||||
this.set("uploaded", true);
|
||||
}
|
||||
|
||||
@action
|
||||
startUpload() {
|
||||
this._startUpload();
|
||||
}
|
||||
|
||||
@action
|
||||
setElement(element) {
|
||||
this.uppyUpload.setup(element);
|
||||
this.uppyUpload.startUpload();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user