mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 05:05:15 +08:00
DEV: drops jquery/simplify code/removes leaked event (#14947)
This commit is contained in:
parent
c768c2ab3a
commit
ef881fdedc
|
@ -1,39 +1,24 @@
|
|||
import { action } from "@ember/object";
|
||||
import Component from "@ember/component";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["table", "staff-actions"],
|
||||
tagName: "",
|
||||
|
||||
willDestroyElement() {
|
||||
$(this.element).off("click.discourse-staff-logs");
|
||||
},
|
||||
@action
|
||||
openLinks(event) {
|
||||
const dataset = event.target.dataset;
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
if (dataset.linkPostId) {
|
||||
event.preventDefault();
|
||||
|
||||
$(this.element).on(
|
||||
"click.discourse-staff-logs",
|
||||
"[data-link-post-id]",
|
||||
(e) => {
|
||||
let postId = $(e.target).attr("data-link-post-id");
|
||||
this.store.find("post", dataset.linkPostId).then((post) => {
|
||||
DiscourseURL.routeTo(post.url);
|
||||
});
|
||||
} else if (dataset.linkTopicId) {
|
||||
event.preventDefault();
|
||||
|
||||
this.store.find("post", postId).then((p) => {
|
||||
DiscourseURL.routeTo(p.get("url"));
|
||||
});
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$(this.element).on(
|
||||
"click.discourse-staff-logs",
|
||||
"[data-link-topic-id]",
|
||||
(e) => {
|
||||
let topicId = $(e.target).attr("data-link-topic-id");
|
||||
|
||||
DiscourseURL.routeTo(`/t/${topicId}`);
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
DiscourseURL.routeTo(`/t/${dataset.linkTopicId}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{{!-- template-lint-disable no-invalid-interactive --}}
|
||||
<div class="table staff-actions" {{on "click" (fn this.openLinks)}}>
|
||||
{{yield}}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user