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";
|
|
|
|
import { inject as service } from "@ember/service";
|
|
|
|
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;
|
2017-06-29 04:56:44 +08:00
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
@alias("word.case_sensitive") isCaseSensitive;
|
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
|
|
|
}
|
|
|
|
}
|