DEV: Move user/group cards from named outlet to component (#20718)

Named outlets are deprecated and will be removed in Ember 4.x.
This commit is contained in:
David Taylor 2023-03-20 14:23:15 +00:00 committed by GitHub
parent 597316125f
commit 4782c34dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 28 deletions

View File

@ -4,16 +4,17 @@
<UserCardContents
@topic={{this.topic.model}}
@showUser={{action "showUser"}}
@filterPosts={{action "filterPosts"}}
@showUser={{this.showUser}}
@filterPosts={{this.filterPosts}}
@composePrivateMessage={{route-action "composePrivateMessage"}}
@createNewMessageViaParams={{route-action "createNewMessageViaParams"}}
role="dialog"
aria-labelledby="discourse-user-card-title"
/>
<GroupCardContents
@topic={{this.topic.model}}
@showUser={{action "showUser"}}
@showGroup={{action "showGroup"}}
@showUser={{this.showUser}}
@showGroup={{this.showGroup}}
@createNewMessageViaParams={{route-action "createNewMessageViaParams"}}
/>

View File

@ -0,0 +1,26 @@
import Component from "@glimmer/component";
import { inject as service } from "@ember/service";
import { inject as controller } from "@ember/controller";
import { action } from "@ember/object";
import DiscourseURL, { groupPath, userPath } from "discourse/lib/url";
export default class CardWrapper extends Component {
@service site;
@controller topic;
@action
filterPosts(user) {
const topicController = this.topic;
topicController.send("filterParticipant", user);
}
@action
showUser(user) {
DiscourseURL.routeTo(userPath(user.username_lower));
}
@action
showGroup(group) {
DiscourseURL.routeTo(groupPath(group.name));
}
}

View File

@ -1,21 +0,0 @@
import Controller, { inject as controller } from "@ember/controller";
import DiscourseURL, { groupPath, userPath } from "discourse/lib/url";
export default Controller.extend({
topic: controller(),
actions: {
filterPosts(user) {
const topicController = this.topic;
topicController.send("filterParticipant", user);
},
showUser(user) {
DiscourseURL.routeTo(userPath(user.username_lower));
},
showGroup(group) {
DiscourseURL.routeTo(groupPath(group.name));
},
},
});

View File

@ -256,7 +256,6 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
renderTemplate() {
this.render("application");
this.render("user-card", { into: "application", outlet: "user-card" });
this.render("modal", { into: "application", outlet: "modal" });
this.render("composer", { into: "application", outlet: "composer" });
},

View File

@ -325,7 +325,6 @@ const TopicRoute = DiscourseRoute.extend({
this._super(...arguments);
this.searchService.set("searchContext", null);
this.controllerFor("user-card").set("visible", false);
const topicController = this.controllerFor("topic");
const postStream = topicController.get("model.postStream");

View File

@ -61,7 +61,8 @@
</div>
{{outlet}}
{{outlet "user-card"}}
<CardContainer />
</div>
</div>