mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 22:53:44 +08:00
d9484db718
It was not clear that replace watched words can be used to replace text with URLs. This introduces a new watched word type that makes it easier to understand.
34 lines
796 B
JavaScript
34 lines
796 B
JavaScript
import Component from "@ember/component";
|
|
import { equal } from "@ember/object/computed";
|
|
import bootbox from "bootbox";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import I18n from "I18n";
|
|
|
|
export default Component.extend({
|
|
classNames: ["watched-word"],
|
|
|
|
isReplace: equal("actionKey", "replace"),
|
|
isTag: equal("actionKey", "tag"),
|
|
isLink: equal("actionKey", "link"),
|
|
|
|
@discourseComputed("word.replacement")
|
|
tags(replacement) {
|
|
return replacement.split(",");
|
|
},
|
|
|
|
click() {
|
|
this.word
|
|
.destroy()
|
|
.then(() => {
|
|
this.action(this.word);
|
|
})
|
|
.catch((e) => {
|
|
bootbox.alert(
|
|
I18n.t("generic_error_with_reason", {
|
|
error: `http: ${e.status} - ${e.body}`,
|
|
})
|
|
);
|
|
});
|
|
},
|
|
});
|