2023-02-23 10:32:53 -05:00
|
|
|
import { classNames } from "@ember-decorators/component";
|
|
|
|
import { inject as service } from "@ember/service";
|
2022-08-02 04:06:03 -04:00
|
|
|
import { alias, equal } from "@ember/object/computed";
|
2023-02-23 10:32:53 -05:00
|
|
|
import Component from "@ember/component";
|
2021-05-21 10:50:24 -04:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2021-06-28 05:44:18 -04:00
|
|
|
import { action } from "@ember/object";
|
2021-05-21 10:50:24 -04:00
|
|
|
import I18n from "I18n";
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2023-02-23 10:32:53 -05: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-28 16:56:44 -04:00
|
|
|
|
2023-02-23 10:32:53 -05:00
|
|
|
@alias("word.case_sensitive") isCaseSensitive;
|
2021-05-21 10:50:24 -04:00
|
|
|
|
|
|
|
@discourseComputed("word.replacement")
|
|
|
|
tags(replacement) {
|
|
|
|
return replacement.split(",");
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
2021-05-21 10:50:24 -04:00
|
|
|
|
2021-06-28 05:44:18 -04:00
|
|
|
@action
|
|
|
|
deleteWord() {
|
2019-11-27 17:44:01 -05:00
|
|
|
this.word
|
|
|
|
.destroy()
|
|
|
|
.then(() => {
|
|
|
|
this.action(this.word);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
2022-09-27 14:47:13 -04:00
|
|
|
this.dialog.alert(
|
2019-11-27 17:44:01 -05:00
|
|
|
I18n.t("generic_error_with_reason", {
|
|
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2023-02-23 10:32:53 -05:00
|
|
|
}
|
|
|
|
}
|