2024-08-13 21:45:44 +08:00
|
|
|
import Component from "@glimmer/component";
|
|
|
|
import { action } from "@ember/object";
|
|
|
|
import { service } from "@ember/service";
|
|
|
|
import { eq, or } from "truth-helpers";
|
|
|
|
import DButton from "discourse/components/d-button";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from "discourse-i18n";
|
2024-08-13 21:45:44 +08:00
|
|
|
|
|
|
|
export default class AdminWatchedWord extends Component {
|
|
|
|
@service dialog;
|
|
|
|
|
|
|
|
get tags() {
|
2024-08-26 17:37:12 +08:00
|
|
|
return this.args.word.replacement.split(",");
|
2024-08-13 21:45:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async deleteWord() {
|
|
|
|
try {
|
|
|
|
await this.args.word.destroy();
|
|
|
|
this.args.action(this.args.word);
|
|
|
|
} catch (e) {
|
|
|
|
this.dialog.alert(
|
|
|
|
i18n("generic_error_with_reason", {
|
|
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="watched-word">
|
|
|
|
<DButton
|
|
|
|
@action={{this.deleteWord}}
|
2024-09-13 23:50:52 +08:00
|
|
|
@icon="xmark"
|
2024-08-13 21:45:44 +08:00
|
|
|
class="btn-transparent delete-word-record"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<span>{{@word.word}}</span>
|
|
|
|
|
|
|
|
{{#if (or (eq @actionKey "replace") (eq @actionKey "link"))}}
|
|
|
|
→
|
|
|
|
<span class="replacement">{{@word.replacement}}</span>
|
|
|
|
{{else if (eq @actionKey "tag")}}
|
|
|
|
→
|
|
|
|
{{#each this.tags as |tag|}}
|
|
|
|
<span class="tag">{{tag}}</span>
|
|
|
|
{{/each}}
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{#if @word.case_sensitive}}
|
|
|
|
<span class="case-sensitive">
|
|
|
|
{{i18n "admin.watched_words.case_sensitive"}}
|
|
|
|
</span>
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{#if @word.html}}
|
|
|
|
<span class="html">{{i18n "admin.watched_words.html"}}</span>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
}
|