FEATURE: Autotag watched words (#12244)

New topics with be matched against a set of watched words and be
tagged accordingly.
This commit is contained in:
Bianca Nenciu
2021-03-03 10:53:38 +02:00
committed by GitHub
parent 8d38438725
commit b49b455e47
9 changed files with 86 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import Component from "@ember/component";
import I18n from "I18n";
import WatchedWord from "admin/models/watched-word";
import bootbox from "bootbox";
import { equal } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
import { schedule } from "@ember/runloop";
@@ -15,10 +16,8 @@ export default Component.extend({
actionKey: null,
showMessage: false,
@discourseComputed("actionKey")
canReplace(actionKey) {
return actionKey === "replace";
},
canReplace: equal("actionKey", "replace"),
canTag: equal("actionKey", "tag"),
@discourseComputed("regularExpressions")
placeholderKey(regularExpressions) {
@@ -61,7 +60,7 @@ export default Component.extend({
const watchedWord = WatchedWord.create({
word: this.word,
replacement: this.canReplace ? this.replacement : null,
replacement: this.canReplace || this.canTag ? this.replacement : null,
action: this.actionKey,
});

View File

@@ -10,6 +10,13 @@
</div>
{{/if}}
{{#if canTag}}
<div class="watched-word-input">
<label for="watched-tag">{{i18n "admin.watched_words.form.tag_label"}}</label>
{{text-field id="watched-tag" value=replacement disabled=formSubmitted class="watched-word-input" autocorrect="off" autocapitalize="off" placeholderKey="admin.watched_words.form.tag_placeholder"}}
</div>
{{/if}}
{{d-button class="btn-default" action=(action "submit") disabled=formSubmitted label="admin.watched_words.form.add"}}
{{#if showMessage}}