mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 07:08:44 +08:00
1166db12b4
* FIX: Make watched words uploads work as intended Currently when we upload a file containing watched words, it will always add the words to the action that was initially selected: this is the `block` action by default but if changing manually the action in the URL to `flag` for example, then this action will be selected and uploaded watched words will be categorised as `flag` no matter what. The problem lies with how the component works: it’s an Uppy object where extra data is defined to provide an action key to the server but when navigating to another listed action, while this action key is properly updated on the component itself, the underlying Uppy object has already been created and doesn’t care about the new value. This patch solves this by using the `_perFileData` method instead of `data`: the former is merged just before uploading a file whereas the latter is used when the Uppy object is created.
29 lines
723 B
JavaScript
29 lines
723 B
JavaScript
import Component from "@ember/component";
|
|
import I18n from "I18n";
|
|
import UppyUploadMixin from "discourse/mixins/uppy-upload";
|
|
import { alias } from "@ember/object/computed";
|
|
import bootbox from "bootbox";
|
|
|
|
export default Component.extend(UppyUploadMixin, {
|
|
type: "txt",
|
|
classNames: "watched-words-uploader",
|
|
uploadUrl: "/admin/customize/watched_words/upload",
|
|
addDisabled: alias("uploading"),
|
|
preventDirectS3Uploads: true,
|
|
|
|
validateUploadedFilesOptions() {
|
|
return { skipValidation: true };
|
|
},
|
|
|
|
_perFileData() {
|
|
return { action_key: this.actionKey };
|
|
},
|
|
|
|
uploadDone() {
|
|
if (this) {
|
|
bootbox.alert(I18n.t("admin.watched_words.form.upload_successful"));
|
|
this.done();
|
|
}
|
|
},
|
|
});
|