DEV: drops jquery/simplify code/removes leaked event (#14947)

This commit is contained in:
Joffrey JAFFEUX 2021-11-16 10:26:39 +01:00 committed by GitHub
parent c768c2ab3a
commit ef881fdedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 29 deletions

View File

@ -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}`);
}
},
});

View File

@ -0,0 +1,4 @@
{{!-- template-lint-disable no-invalid-interactive --}}
<div class="table staff-actions" {{on "click" (fn this.openLinks)}}>
{{yield}}
</div>