2023-02-23 23:32:53 +08:00
|
|
|
import Component from "@ember/component";
|
2021-06-28 17:44:18 +08:00
|
|
|
import { action } from "@ember/object";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { alias, equal } from "@ember/object/computed";
|
2024-03-07 01:05:11 +08:00
|
|
|
import { service } from "@ember/service";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2023-10-18 18:07:09 +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-word")
|
|
|
|
export default class AdminWatchedWord extends Component {
|
|
|
|
@service dialog;
|
|
|
|
|
|
|
|
@equal("actionKey", "replace") isReplace;
|
|
|
|
@equal("actionKey", "tag") isTag;
|
|
|
|
@equal("actionKey", "link") isLink;
|
|
|
|
@alias("word.case_sensitive") isCaseSensitive;
|
2024-05-06 23:08:34 +08:00
|
|
|
@alias("word.html") isHtml;
|
2021-05-21 22:50:24 +08:00
|
|
|
|
|
|
|
@discourseComputed("word.replacement")
|
|
|
|
tags(replacement) {
|
|
|
|
return replacement.split(",");
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
2021-05-21 22:50:24 +08:00
|
|
|
|
2021-06-28 17:44:18 +08:00
|
|
|
@action
|
|
|
|
deleteWord() {
|
2019-11-28 06:44:01 +08:00
|
|
|
this.word
|
|
|
|
.destroy()
|
|
|
|
.then(() => {
|
|
|
|
this.action(this.word);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2022-09-28 02:47:13 +08:00
|
|
|
this.dialog.alert(
|
2019-11-28 06:44:01 +08:00
|
|
|
I18n.t("generic_error_with_reason", {
|
|
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
|
|
|
}
|