2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { alias } from "@ember/object/computed";
|
2024-10-21 22:09:14 +08:00
|
|
|
import { getOwner } from "@ember/owner";
|
|
|
|
import { service } from "@ember/service";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
2024-10-21 22:09:14 +08:00
|
|
|
import UppyUpload from "discourse/lib/uppy/uppy-upload";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from "discourse-i18n";
|
2017-06-29 04:56:44 +08:00
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
@classNames("watched-words-uploader")
|
2024-10-21 22:09:14 +08:00
|
|
|
export default class WatchedWordUploader extends Component {
|
|
|
|
@service dialog;
|
2023-02-23 23:32:53 +08:00
|
|
|
|
2024-10-21 22:09:14 +08:00
|
|
|
uppyUpload = new UppyUpload(getOwner(this), {
|
|
|
|
id: "watched-word-uploader",
|
|
|
|
type: "txt",
|
|
|
|
uploadUrl: "/admin/customize/watched_words/upload",
|
|
|
|
preventDirectS3Uploads: true,
|
|
|
|
validateUploadedFilesOptions: {
|
|
|
|
skipValidation: true,
|
|
|
|
},
|
|
|
|
perFileData: () => ({ action_key: this.actionKey }),
|
|
|
|
uploadDone: () => {
|
2024-11-20 04:45:18 +08:00
|
|
|
this.dialog.alert(i18n("admin.watched_words.form.upload_successful"));
|
2019-01-10 18:06:01 +08:00
|
|
|
this.done();
|
2024-10-21 22:09:14 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
@alias("uppyUpload.uploading") addDisabled;
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|