mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 05:03:40 +08:00
a914d3230b
Followup to 7d8974d02f
Co-authored-by: David Taylor <david@taylorhq.com>
61 lines
1.5 KiB
Plaintext
61 lines
1.5 KiB
Plaintext
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";
|
|
import i18n from "discourse-common/helpers/i18n";
|
|
|
|
export default class AdminWatchedWord extends Component {
|
|
@service dialog;
|
|
|
|
get tags() {
|
|
return this.args.word.replacement.split(",");
|
|
}
|
|
|
|
@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}}
|
|
@icon="xmark"
|
|
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>
|
|
}
|