2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2021-05-21 10:50:24 -04:00
|
|
|
import { equal } from "@ember/object/computed";
|
2020-08-26 12:57:13 -04:00
|
|
|
import bootbox from "bootbox";
|
2021-05-21 10:50:24 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
import I18n from "I18n";
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2019-11-27 17:44:01 -05:00
|
|
|
export default Component.extend({
|
|
|
|
classNames: ["watched-word"],
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2021-05-21 10:50:24 -04:00
|
|
|
isReplace: equal("actionKey", "replace"),
|
|
|
|
isTag: equal("actionKey", "tag"),
|
|
|
|
|
|
|
|
@discourseComputed("word.replacement")
|
|
|
|
tags(replacement) {
|
|
|
|
return replacement.split(",");
|
|
|
|
},
|
|
|
|
|
2019-11-27 17:44:01 -05:00
|
|
|
click() {
|
|
|
|
this.word
|
|
|
|
.destroy()
|
|
|
|
.then(() => {
|
|
|
|
this.action(this.word);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
bootbox.alert(
|
|
|
|
I18n.t("generic_error_with_reason", {
|
|
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|