DEV: Use `templateName` instead of `renderTemplate()` (#21517)

`renderTemplate()` is deprecated and has been removed in Ember 4.0
This commit is contained in:
Jarek Radosz 2023-05-19 11:14:38 +02:00 committed by GitHub
parent db9d998de3
commit 48987af324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 54 deletions

View File

@ -5,11 +5,7 @@ import { action } from "@ember/object";
export default function (filter) { export default function (filter) {
return DiscourseRoute.extend({ return DiscourseRoute.extend({
@action templateName: "user/posts",
didTransition() {
this.controllerFor("user-posts")._showFooter();
return true;
},
model() { model() {
return this.modelFor("user").get("postsStream"); return this.modelFor("user").get("postsStream");
@ -32,8 +28,10 @@ export default function (filter) {
this.controllerFor("user-posts").set("model", model); this.controllerFor("user-posts").set("model", model);
}, },
renderTemplate() { @action
this.render("user/posts"); didTransition() {
this.controllerFor("user-posts")._showFooter();
return true;
}, },
}); });
} }

View File

@ -1,7 +1,5 @@
import UnknownRoute from "discourse/routes/unknown"; import UnknownRoute from "discourse/routes/unknown";
export default UnknownRoute.extend({ export default UnknownRoute.extend({
renderTemplate() { templateName: "unknown",
this.render("unknown");
},
}); });

View File

@ -5,6 +5,8 @@ import { action, get } from "@ember/object";
export function buildGroupPage(type) { export function buildGroupPage(type) {
return DiscourseRoute.extend({ return DiscourseRoute.extend({
type, type,
templateName: "group-activity-posts",
controllerName: "group-activity-posts",
titleToken() { titleToken() {
return I18n.t(`groups.${type}`); return I18n.t(`groups.${type}`);
@ -17,7 +19,7 @@ export function buildGroupPage(type) {
setupController(controller, model) { setupController(controller, model) {
let loadedAll = model.length < 20; let loadedAll = model.length < 20;
this.controllerFor("group-activity-posts").setProperties({ controller.setProperties({
model, model,
type, type,
canLoadMore: !loadedAll, canLoadMore: !loadedAll,
@ -25,10 +27,6 @@ export function buildGroupPage(type) {
this.controllerFor("application").set("showFooter", loadedAll); this.controllerFor("application").set("showFooter", loadedAll);
}, },
renderTemplate() {
this.render("group-activity-posts");
},
@action @action
didTransition() { didTransition() {
return true; return true;

View File

@ -5,6 +5,8 @@ import { Promise } from "rsvp";
import I18n from "I18n"; import I18n from "I18n";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
templateName: "user/bookmarks",
queryParams: { queryParams: {
acting_username: { refreshModel: true }, acting_username: { refreshModel: true },
q: { refreshModel: true }, q: { refreshModel: true },
@ -47,10 +49,6 @@ export default DiscourseRoute.extend({
.finally(() => controller.set("loading", false)); .finally(() => controller.set("loading", false));
}, },
renderTemplate() {
this.render("user_bookmarks");
},
titleToken() { titleToken() {
return I18n.t("user_action_groups.3"); return I18n.t("user_action_groups.3");
}, },

View File

@ -3,6 +3,8 @@ import I18n from "I18n";
import { action } from "@ember/object"; import { action } from "@ember/object";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
templateName: "user/stream",
model() { model() {
const user = this.modelFor("user"); const user = this.modelFor("user");
const draftsStream = user.get("userDraftsStream"); const draftsStream = user.get("userDraftsStream");
@ -16,14 +18,6 @@ export default DiscourseRoute.extend({
}); });
}, },
renderTemplate() {
this.render("user_stream");
},
setupController(controller, model) {
controller.set("model", model);
},
emptyState() { emptyState() {
const title = I18n.t("user_activity.no_drafts_title"); const title = I18n.t("user_activity.no_drafts_title");
const body = I18n.t("user_activity.no_drafts_body"); const body = I18n.t("user_activity.no_drafts_body");

View File

@ -4,6 +4,8 @@ import { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
export default DiscourseRoute.extend(ViewingActionType, { export default DiscourseRoute.extend(ViewingActionType, {
templateName: "user/stream",
queryParams: { queryParams: {
acting_username: { refreshModel: true }, acting_username: { refreshModel: true },
}, },
@ -29,12 +31,8 @@ export default DiscourseRoute.extend(ViewingActionType, {
}); });
}, },
renderTemplate() { setupController() {
this.render("user_stream"); this._super(...arguments);
},
setupController(controller, model) {
controller.set("model", model);
this.viewingActionType(this.userActionType); this.viewingActionType(this.userActionType);
}, },

View File

@ -5,6 +5,8 @@ import { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
export default DiscourseRoute.extend(ViewingActionType, { export default DiscourseRoute.extend(ViewingActionType, {
templateName: "user/badges",
model() { model() {
return UserBadge.findByUsername( return UserBadge.findByUsername(
this.modelFor("user").get("username_lower"), this.modelFor("user").get("username_lower"),
@ -12,13 +14,9 @@ export default DiscourseRoute.extend(ViewingActionType, {
); );
}, },
setupController(controller, model) { setupController() {
this._super(...arguments);
this.viewingActionType(-1); this.viewingActionType(-1);
controller.set("model", model);
},
renderTemplate() {
this.render("user/badges");
}, },
titleToken() { titleToken() {

View File

@ -3,9 +3,7 @@ import I18n from "I18n";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
controllerName: "user-notifications", controllerName: "user-notifications",
renderTemplate() { templateName: "user/notifications-index",
this.render("user/notifications-index");
},
titleToken() { titleToken() {
return I18n.t("user.filters.all"); return I18n.t("user.filters.all");

View File

@ -27,8 +27,8 @@ export default DiscourseRoute.extend(ViewingActionType, {
} }
}, },
setupController(controller, model) { setupController(controller) {
controller.set("model", model); this._super(...arguments);
controller.set("user", this.modelFor("user")); controller.set("user", this.modelFor("user"));
this.viewingActionType(-1); this.viewingActionType(-1);
}, },

View File

@ -5,12 +5,9 @@ import { action } from "@ember/object";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
templateName: "user/messages",
composer: service(), composer: service(),
renderTemplate() {
this.render("user/messages");
},
model() { model() {
return this.modelFor("user"); return this.modelFor("user");
}, },
@ -19,8 +16,8 @@ export default DiscourseRoute.extend({
return this.pmTopicTrackingState.startTracking(); return this.pmTopicTrackingState.startTracking();
}, },
setupController(controller, model) { setupController() {
controller.set("model", model); this._super(...arguments);
if (this.currentUser) { if (this.currentUser) {
Draft.get("new_private_message").then((data) => { Draft.get("new_private_message").then((data) => {

View File

@ -3,9 +3,8 @@ import ViewingActionType from "discourse/mixins/viewing-action-type";
import { setTopicList } from "discourse/lib/topic-list-tracker"; import { setTopicList } from "discourse/lib/topic-list-tracker";
export default DiscourseRoute.extend(ViewingActionType, { export default DiscourseRoute.extend(ViewingActionType, {
renderTemplate() { templateName: "user-topics-list",
this.render("user-topics-list"); controllerName: "user-topics-list",
},
setupController(controller, model) { setupController(controller, model) {
setTopicList(model); setTopicList(model);
@ -13,7 +12,7 @@ export default DiscourseRoute.extend(ViewingActionType, {
const userActionType = this.userActionType; const userActionType = this.userActionType;
this.controllerFor("user").set("userActionType", userActionType); this.controllerFor("user").set("userActionType", userActionType);
this.controllerFor("user-activity").set("userActionType", userActionType); this.controllerFor("user-activity").set("userActionType", userActionType);
this.controllerFor("user-topics-list").setProperties({ controller.setProperties({
model, model,
hideCategory: false, hideCategory: false,
}); });