DEV: Revert "DEV: Update replaceWith on Route (#22645)" (#22693)

This reverts commit 33db93c9b2.
This commit is contained in:
Isaac Janzen 2023-07-19 10:47:31 -05:00 committed by GitHub
parent 341acacba8
commit 1561e51a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 52 additions and 134 deletions

View File

@ -1,15 +1,10 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
export default class AdminCustomizeColorsShowRoute extends Route { export default class AdminCustomizeColorsShowRoute extends Route {
@service router;
model(params) { model(params) {
const all = this.modelFor("adminCustomize.colors"); const all = this.modelFor("adminCustomize.colors");
const model = all.findBy("id", parseInt(params.scheme_id, 10)); const model = all.findBy("id", parseInt(params.scheme_id, 10));
return model return model ? model : this.replaceWith("adminCustomize.colors.index");
? model
: this.router.replaceWith("adminCustomize.colors.index");
} }
serialize(model) { serialize(model) {

View File

@ -1,10 +1,7 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
export default class AdminCustomizeEmailStyleIndexRoute extends Route { export default class AdminCustomizeEmailStyleIndexRoute extends Route {
@service router;
beforeModel() { beforeModel() {
this.router.replaceWith("adminCustomizeEmailStyle.edit", "html"); this.replaceWith("adminCustomizeEmailStyle.edit", "html");
} }
} }

View File

@ -16,7 +16,7 @@ export default class AdminCustomizeThemesEditRoute extends Route {
target: params.target, target: params.target,
field_name: params.field_name, field_name: params.field_name,
} }
: this.router.replaceWith("adminCustomizeThemes.index"); : this.replaceWith("adminCustomizeThemes.index");
} }
serialize(wrapper) { serialize(wrapper) {

View File

@ -7,7 +7,6 @@ import { scrollTop } from "discourse/mixins/scroll-top";
export default class AdminCustomizeThemesShowRoute extends Route { export default class AdminCustomizeThemesShowRoute extends Route {
@service dialog; @service dialog;
@service router;
serialize(model) { serialize(model) {
return { theme_id: model.get("id") }; return { theme_id: model.get("id") };
@ -16,7 +15,7 @@ export default class AdminCustomizeThemesShowRoute extends Route {
model(params) { model(params) {
const all = this.modelFor("adminCustomizeThemes"); const all = this.modelFor("adminCustomizeThemes");
const model = all.findBy("id", parseInt(params.theme_id, 10)); const model = all.findBy("id", parseInt(params.theme_id, 10));
return model || this.router.replaceWith("adminCustomizeThemes.index"); return model ? model : this.replaceWith("adminCustomizeThemes.index");
} }
setupController(controller, model) { setupController(controller, model) {

View File

@ -3,13 +3,10 @@
chosen a category. It will redirect to the first category. chosen a category. It will redirect to the first category.
**/ **/
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class AdminSiteSettingsIndexRoute extends DiscourseRoute { export default class AdminSiteSettingsIndexRoute extends DiscourseRoute {
@service router;
beforeModel() { beforeModel() {
this.router.replaceWith( this.replaceWith(
"adminSiteSettingsCategory", "adminSiteSettingsCategory",
this.controllerFor("adminSiteSettings").get("visibleSiteSettings")[0] this.controllerFor("adminSiteSettings").get("visibleSiteSettings")[0]
.nameKey .nameKey

View File

@ -1,11 +1,8 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class AdminWatchedWordsIndexRoute extends DiscourseRoute { export default class AdminWatchedWordsIndexRoute extends DiscourseRoute {
@service router;
beforeModel() { beforeModel() {
this.router.replaceWith( this.replaceWith(
"adminWatchedWords.action", "adminWatchedWords.action",
this.modelFor("adminWatchedWords")[0].nameKey this.modelFor("adminWatchedWords")[0].nameKey
); );

View File

@ -4,18 +4,15 @@ import { next } from "@ember/runloop";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import showModal from "discourse/lib/show-modal"; import showModal from "discourse/lib/show-modal";
import cookie from "discourse/lib/cookie"; import cookie from "discourse/lib/cookie";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
beforeModel(transition) { beforeModel(transition) {
if (!this.currentUser) { if (!this.currentUser) {
cookie("destination_url", transition.intent.url); cookie("destination_url", transition.intent.url);
return this.router.replaceWith("login"); return this.replaceWith("login");
} }
const params = this.paramsFor("associate-account"); const params = this.paramsFor("associate-account");
this.router.replaceWith(`preferences.account`, this.currentUser).then(() => this.replaceWith(`preferences.account`, this.currentUser).then(() =>
next(() => next(() =>
ajax(`/associate/${encodeURIComponent(params.token)}.json`) ajax(`/associate/${encodeURIComponent(params.token)}.json`)
.then((model) => showModal("associate-account-confirm", { model })) .then((model) => showModal("associate-account-confirm", { model }))

View File

@ -23,7 +23,6 @@ export default (filterArg, params) => {
return DiscourseRoute.extend({ return DiscourseRoute.extend({
queryParams, queryParams,
composer: service(), composer: service(),
router: service(),
model(modelParams) { model(modelParams) {
const category = Category.findBySlugPathWithID( const category = Category.findBySlugPathWithID(
@ -51,7 +50,7 @@ export default (filterArg, params) => {
afterModel(model, transition) { afterModel(model, transition) {
if (!model) { if (!model) {
this.router.replaceWith("/404"); this.replaceWith("/404");
return; return;
} }
@ -65,7 +64,7 @@ export default (filterArg, params) => {
) { ) {
// TODO: avoid throwing away preload data by redirecting on the server // TODO: avoid throwing away preload data by redirecting on the server
PreloadStore.getAndRemove("topic_list"); PreloadStore.getAndRemove("topic_list");
return this.router.replaceWith( return this.replaceWith(
"discovery.categoryNone", "discovery.categoryNone",
modelParams.category_slug_path_with_id modelParams.category_slug_path_with_id
); );

View File

@ -4,10 +4,8 @@ import Route from "@ember/routing/route";
import { once } from "@ember/runloop"; import { once } from "@ember/runloop";
import { seenUser } from "discourse/lib/user-presence"; import { seenUser } from "discourse/lib/user-presence";
import { getOwner } from "discourse-common/lib/get-owner"; import { getOwner } from "discourse-common/lib/get-owner";
import { inject as service } from "@ember/service";
const DiscourseRoute = Route.extend({ const DiscourseRoute = Route.extend({
router: service(),
showFooter: false, showFooter: false,
willTransition() { willTransition() {
@ -51,7 +49,7 @@ const DiscourseRoute = Route.extend({
redirectIfLoginRequired() { redirectIfLoginRequired() {
const app = this.controllerFor("application"); const app = this.controllerFor("application");
if (app.get("loginRequired")) { if (app.get("loginRequired")) {
this.router.replaceWith("login"); this.replaceWith("login");
} }
}, },

View File

@ -8,10 +8,8 @@ import User from "discourse/models/user";
import { setTopicList } from "discourse/lib/topic-list-tracker"; import { setTopicList } from "discourse/lib/topic-list-tracker";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { resetCachedTopicList } from "discourse/lib/cached-topic-list"; import { resetCachedTopicList } from "discourse/lib/cached-topic-list";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend(OpenComposer, { export default DiscourseRoute.extend(OpenComposer, {
router: service(),
queryParams: { queryParams: {
filter: { refreshModel: true }, filter: { refreshModel: true },
}, },
@ -31,14 +29,14 @@ export default DiscourseRoute.extend(OpenComposer, {
User.currentProp("user_option.should_be_redirected_to_top", false); User.currentProp("user_option.should_be_redirected_to_top", false);
const period = const period =
User.currentProp("user_option.redirected_to_top.period") || "all"; User.currentProp("user_option.redirected_to_top.period") || "all";
this.router.replaceWith("discovery.top", { this.replaceWith("discovery.top", {
queryParams: { queryParams: {
period, period,
}, },
}); });
} else if (url && (matches = url.match(/top\/(.*)$/))) { } else if (url && (matches = url.match(/top\/(.*)$/))) {
if (this.site.periods.includes(matches[1])) { if (this.site.periods.includes(matches[1])) {
this.router.replaceWith("discovery.top", { this.replaceWith("discovery.top", {
queryParams: { queryParams: {
period: matches[1], period: matches[1],
}, },

View File

@ -1,11 +1,8 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
afterModel() { afterModel() {
const params = this.paramsFor("editCategory"); const params = this.paramsFor("editCategory");
this.router.replaceWith(`/c/${params.slug}/edit/general`); this.replaceWith(`/c/${params.slug}/edit/general`);
}, },
}); });

View File

@ -1,11 +1,8 @@
import Category from "discourse/models/category"; import Category from "discourse/models/category";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
return Category.reloadCategoryWithPermissions( return Category.reloadCategoryWithPermissions(
params, params,
@ -16,7 +13,7 @@ export default DiscourseRoute.extend({
afterModel(model) { afterModel(model) {
if (!model.can_edit) { if (!model.can_edit) {
this.router.replaceWith("/404"); this.replaceWith("/404");
return; return;
} }
}, },

View File

@ -1,15 +1,12 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { defaultHomepage } from "discourse/lib/utilities"; import { defaultHomepage } from "discourse/lib/utilities";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { inject as service } from "@ember/service";
export default class ForgotPasswordRoute extends DiscourseRoute { export default class ForgotPasswordRoute extends DiscourseRoute {
@service router;
async beforeModel() { async beforeModel() {
const { loginRequired } = this.controllerFor("application"); const { loginRequired } = this.controllerFor("application");
const e = await this.router.replaceWith( const e = await this.replaceWith(
loginRequired ? "login" : `discovery.${defaultHomepage()}` loginRequired ? "login" : `discovery.${defaultHomepage()}`
); );

View File

@ -1,9 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
showFooter: true, showFooter: true,
titleToken() { titleToken() {
@ -12,7 +10,7 @@ export default DiscourseRoute.extend({
afterModel(group) { afterModel(group) {
if (group.get("automatic")) { if (group.get("automatic")) {
this.router.replaceWith("group.manage.interaction", group); this.replaceWith("group.manage.interaction", group);
} }
}, },
}); });

View File

@ -6,7 +6,6 @@ import StaticPage from "discourse/models/static-page";
export default class LoginRoute extends DiscourseRoute { export default class LoginRoute extends DiscourseRoute {
@service siteSettings; @service siteSettings;
@service router;
// `login-page` because `login` controller is the one for // `login-page` because `login` controller is the one for
// the login modal // the login modal
@ -14,7 +13,7 @@ export default class LoginRoute extends DiscourseRoute {
beforeModel() { beforeModel() {
if (!this.siteSettings.login_required) { if (!this.siteSettings.login_required) {
this.router.replaceWith(`/${defaultHomepage()}`).then((e) => { this.replaceWith(`/${defaultHomepage()}`).then((e) => {
next(() => e.send("showLogin")); next(() => e.send("showLogin"));
}); });
} }

View File

@ -2,7 +2,6 @@ import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { Promise } from "rsvp"; import { Promise } from "rsvp";
import { SEARCH_PRIORITIES } from "discourse/lib/constants"; import { SEARCH_PRIORITIES } from "discourse/lib/constants";
import { inject as service } from "@ember/service";
let _newCategoryColor = "0088CC"; let _newCategoryColor = "0088CC";
let _newCategoryTextColor = "FFFFFF"; let _newCategoryTextColor = "FFFFFF";
@ -13,13 +12,12 @@ export function setNewCategoryDefaultColors(backgroundColor, textColor) {
} }
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
controllerName: "edit-category-tabs", controllerName: "edit-category-tabs",
templateName: "edit-category-tabs", templateName: "edit-category-tabs",
beforeModel() { beforeModel() {
if (!this.currentUser) { if (!this.currentUser) {
this.router.replaceWith("/404"); this.replaceWith("/404");
return; return;
} }
if (!this.currentUser.admin) { if (!this.currentUser.admin) {
@ -27,7 +25,7 @@ export default DiscourseRoute.extend({
!this.currentUser.moderator || !this.currentUser.moderator ||
this.siteSettings.moderators_manage_categories_and_groups === false this.siteSettings.moderators_manage_categories_and_groups === false
) { ) {
this.router.replaceWith("/404"); this.replaceWith("/404");
} }
} }
}, },

View File

@ -7,7 +7,6 @@ import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
dialog: service(), dialog: service(),
router: service(),
beforeModel(transition) { beforeModel(transition) {
const params = transition.to.queryParams; const params = transition.to.queryParams;
@ -15,7 +14,7 @@ export default DiscourseRoute.extend({
const groupName = params.groupname || params.group_name; const groupName = params.groupname || params.group_name;
if (this.currentUser) { if (this.currentUser) {
this.router.replaceWith("/latest").then((e) => { this.replaceWith("discovery.latest").then((e) => {
if (params.username) { if (params.username) {
e.send("createNewMessageViaParams", { e.send("createNewMessageViaParams", {
recipients: params.username, recipients: params.username,
@ -50,7 +49,7 @@ export default DiscourseRoute.extend({
}); });
} else { } else {
cookie("destination_url", window.location.href); cookie("destination_url", window.location.href);
this.router.replaceWith("login"); this.replaceWith("login");
} }
}, },
}); });

View File

@ -2,11 +2,8 @@ import Category from "discourse/models/category";
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import cookie from "discourse/lib/cookie"; import cookie from "discourse/lib/cookie";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
beforeModel(transition) { beforeModel(transition) {
if (this.currentUser) { if (this.currentUser) {
let category, categoryId; let category, categoryId;
@ -37,9 +34,10 @@ export default DiscourseRoute.extend({
} }
if (category) { if (category) {
// Using URL-based transition to avoid bug with dynamic segments and refreshModel query params let route = "discovery.category";
// https://github.com/emberjs/ember.js/issues/16992 let params = { category, id: category.id };
this.router.replaceWith(`/c/${category.id}`).then((e) => {
this.replaceWith(route, params).then((e) => {
if (this.controllerFor("navigation/category").canCreateTopic) { if (this.controllerFor("navigation/category").canCreateTopic) {
this._sendTransition(e, transition, categoryId); this._sendTransition(e, transition, categoryId);
} }
@ -49,7 +47,7 @@ export default DiscourseRoute.extend({
transition.abort(); transition.abort();
this.send("createNewTopicViaParams"); this.send("createNewTopicViaParams");
} else { } else {
this.router.replaceWith("discovery.latest").then((e) => { this.replaceWith("discovery.latest").then((e) => {
if (this.controllerFor("navigation/default").canCreateTopic) { if (this.controllerFor("navigation/default").canCreateTopic) {
this._sendTransition(e, transition); this._sendTransition(e, transition);
} }
@ -59,7 +57,7 @@ export default DiscourseRoute.extend({
} else { } else {
// User is not logged in // User is not logged in
cookie("destination_url", window.location.href); cookie("destination_url", window.location.href);
this.router.replaceWith("login"); this.replaceWith("login");
} }
}, },

View File

@ -1,13 +1,10 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
// A base route that allows us to redirect when access is restricted // A base route that allows us to redirect when access is restricted
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
afterModel() { afterModel() {
if (!this.modelFor("user").get("can_edit")) { if (!this.modelFor("user").get("can_edit")) {
this.router.replaceWith("userActivity"); this.replaceWith("userActivity");
} }
}, },
}); });

View File

@ -1,21 +1,18 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { inject as service } from "@ember/service";
export default class SignupRoute extends DiscourseRoute { export default class SignupRoute extends DiscourseRoute {
@service router;
beforeModel() { beforeModel() {
const { canSignUp } = this.controllerFor("application"); const { canSignUp } = this.controllerFor("application");
if (this.siteSettings.login_required) { if (this.siteSettings.login_required) {
this.router.replaceWith("login").then((e) => { this.replaceWith("login").then((e) => {
if (canSignUp) { if (canSignUp) {
next(() => e.send("showCreateAccount")); next(() => e.send("showCreateAccount"));
} }
}); });
} else { } else {
this.router.replaceWith("discovery.latest").then((e) => { this.replaceWith("discovery.latest").then((e) => {
if (canSignUp) { if (canSignUp) {
next(() => e.send("showCreateAccount")); next(() => e.send("showCreateAccount"));
} }

View File

@ -25,7 +25,6 @@ const ALL = "all";
export default DiscourseRoute.extend(FilterModeMixin, { export default DiscourseRoute.extend(FilterModeMixin, {
composer: service(), composer: service(),
router: service(),
navMode: "latest", navMode: "latest",
queryParams, queryParams,
@ -100,7 +99,7 @@ export default DiscourseRoute.extend(FilterModeMixin, {
) { ) {
// TODO: avoid throwing away preload data by redirecting on the server // TODO: avoid throwing away preload data by redirecting on the server
PreloadStore.getAndRemove("topic_list"); PreloadStore.getAndRemove("topic_list");
return this.router.replaceWith( return this.replaceWith(
"tags.showCategoryNone", "tags.showCategoryNone",
params.category_slug_path_with_id, params.category_slug_path_with_id,
tagId tagId

View File

@ -1,14 +1,11 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model() { model() {
let user = this.modelFor("user"); let user = this.modelFor("user");
if (user.get("profile_hidden")) { if (user.get("profile_hidden")) {
return this.router.replaceWith("user.profile-hidden"); return this.replaceWith("user.profile-hidden");
} }
return user; return user;

View File

@ -15,7 +15,7 @@ export default DiscourseRoute.extend({
// transition into a user's activity works. This makes the back button work on mobile // transition into a user's activity works. This makes the back button work on mobile
// where there is no user card as well as desktop where there is. // where there is no user card as well as desktop where there is.
if (this.site.mobileView) { if (this.site.mobileView) {
this.router.replaceWith(destination); this.replaceWith(destination);
} else { } else {
this.router.transitionTo(destination); this.router.transitionTo(destination);
} }

View File

@ -1,10 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
beforeModel() { beforeModel() {
this.router.replaceWith("userInvited.show", "pending"); this.replaceWith("userInvited.show", "pending");
}, },
}); });

View File

@ -2,11 +2,8 @@ import DiscourseRoute from "discourse/routes/discourse";
import Invite from "discourse/models/invite"; import Invite from "discourse/models/invite";
import { action } from "@ember/object"; import { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
model(params) { model(params) {
this.inviteFilter = params.filter; this.inviteFilter = params.filter;
return Invite.findInvitedBy(this.modelFor("user"), params.filter); return Invite.findInvitedBy(this.modelFor("user"), params.filter);
@ -14,7 +11,7 @@ export default DiscourseRoute.extend({
afterModel(model) { afterModel(model) {
if (!model.can_see_invite_details) { if (!model.can_see_invite_details) {
this.router.replaceWith("userInvited.show", "redeemed"); this.replaceWith("userInvited.show", "redeemed");
} }
this.controllerFor("user.invited").setProperties({ this.controllerFor("user.invited").setProperties({
invitesCount: model.counts, invitesCount: model.counts,

View File

@ -1,15 +1,13 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
showFooter: true, showFooter: true,
model() { model() {
const user = this.modelFor("user"); const user = this.modelFor("user");
if (user.get("profile_hidden")) { if (user.get("profile_hidden")) {
return this.router.replaceWith("user.profile-hidden"); return this.replaceWith("user.profile-hidden");
} }
return user.summary(); return user.summary();

View File

@ -2,14 +2,11 @@ import DiscourseRoute from "discourse/routes/discourse";
import User from "discourse/models/user"; import User from "discourse/models/user";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { bind } from "discourse-common/utils/decorators"; import { bind } from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
beforeModel() { beforeModel() {
if (this.siteSettings.hide_user_profiles_from_public && !this.currentUser) { if (this.siteSettings.hide_user_profiles_from_public && !this.currentUser) {
this.router.replaceWith("discovery"); this.replaceWith("discovery");
} }
}, },
@ -34,7 +31,7 @@ export default DiscourseRoute.extend({
.findDetails() .findDetails()
.then(() => user.findStaffInfo()) .then(() => user.findStaffInfo())
.then(() => user.trackStatus()) .then(() => user.trackStatus())
.catch(() => this.router.replaceWith("/404")); .catch(() => this.replaceWith("/404"));
}, },
serialize(model) { serialize(model) {

View File

@ -4,10 +4,8 @@ import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { Promise } from "rsvp"; import { Promise } from "rsvp";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
queryParams: { queryParams: {
period: { refreshModel: true }, period: { refreshModel: true },
order: { refreshModel: true }, order: { refreshModel: true },
@ -37,7 +35,7 @@ export default DiscourseRoute.extend({
beforeModel() { beforeModel() {
if (this.siteSettings.hide_user_profiles_from_public && !this.currentUser) { if (this.siteSettings.hide_user_profiles_from_public && !this.currentUser) {
this.router.replaceWith("discovery"); this.replaceWith("discovery");
} }
}, },

View File

@ -5,6 +5,7 @@ globalThis.deprecationWorkflow.config = {
workflow: [ workflow: [
{ handler: "silence", matchId: "route-render-template" }, { handler: "silence", matchId: "route-render-template" },
{ handler: "silence", matchId: "route-disconnect-outlet" }, { handler: "silence", matchId: "route-disconnect-outlet" },
{ handler: "silence", matchId: "routing.transition-methods" },
{ handler: "silence", matchId: "this-property-fallback" }, { handler: "silence", matchId: "this-property-fallback" },
{ handler: "silence", matchId: "discourse.select-kit" }, { handler: "silence", matchId: "discourse.select-kit" },
], ],

View File

@ -1,11 +1,8 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({ export default DiscourseRoute.extend({
router: service(),
beforeModel() { beforeModel() {
const appModel = this.modelFor("wizard"); const appModel = this.modelFor("wizard");
this.router.replaceWith("wizard.step", appModel.start); this.replaceWith("wizard.step", appModel.start);
}, },
}); });

View File

@ -1,13 +1,9 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class ChatBrowseIndexRoute extends DiscourseRoute { export default class ChatBrowseIndexRoute extends DiscourseRoute {
@service router;
@service siteSettings;
afterModel() { afterModel() {
if (!this.siteSettings.chat_allow_archiving_channels) { if (!this.siteSettings.chat_allow_archiving_channels) {
this.router.replaceWith("chat.browse"); this.replaceWith("chat.browse");
} }
} }
} }

View File

@ -18,6 +18,6 @@ export default class ChatBrowseIndexRoute extends DiscourseRoute {
} }
afterModel() { afterModel() {
this.router.replaceWith("chat.browse.open"); this.replaceWith("chat.browse.open");
} }
} }

View File

@ -1,12 +1,9 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class ChatChannelInfoAboutRoute extends DiscourseRoute { export default class ChatChannelInfoAboutRoute extends DiscourseRoute {
@service router;
afterModel(model) { afterModel(model) {
if (model.isDirectMessageChannel) { if (model.isDirectMessageChannel) {
this.router.replaceWith("chat.channel.info.index"); this.replaceWith("chat.channel.info.index");
} }
} }
} }

View File

@ -1,18 +1,15 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class ChatChannelInfoIndexRoute extends DiscourseRoute { export default class ChatChannelInfoIndexRoute extends DiscourseRoute {
@service router;
afterModel(model) { afterModel(model) {
if (model.isDirectMessageChannel) { if (model.isDirectMessageChannel) {
if (model.isOpen && model.membershipsCount >= 1) { if (model.isOpen && model.membershipsCount >= 1) {
this.router.replaceWith("chat.channel.info.members"); this.replaceWith("chat.channel.info.members");
} else { } else {
this.router.replaceWith("chat.channel.info.settings"); this.replaceWith("chat.channel.info.settings");
} }
} else { } else {
this.router.replaceWith("chat.channel.info.about"); this.replaceWith("chat.channel.info.about");
} }
} }
} }

View File

@ -1,16 +1,13 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class ChatChannelInfoMembersRoute extends DiscourseRoute { export default class ChatChannelInfoMembersRoute extends DiscourseRoute {
@service router;
afterModel(model) { afterModel(model) {
if (!model.isOpen) { if (!model.isOpen) {
return this.router.replaceWith("chat.channel.info.settings"); return this.replaceWith("chat.channel.info.settings");
} }
if (model.membershipsCount < 1) { if (model.membershipsCount < 1) {
return this.router.replaceWith("chat.channel.info"); return this.replaceWith("chat.channel.info");
} }
} }
} }

View File

@ -1,13 +1,9 @@
import DiscourseRoute from "discourse/routes/discourse"; import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class ChatChannelInfoSettingsRoute extends DiscourseRoute { export default class ChatChannelInfoSettingsRoute extends DiscourseRoute {
@service router;
@service currentUser;
afterModel(model) { afterModel(model) {
if (!this.currentUser?.staff && !model.currentUserMembership?.following) { if (!this.currentUser?.staff && !model.currentUserMembership?.following) {
this.router.replaceWith("chat.channel.info"); this.replaceWith("chat.channel.info");
} }
} }
} }

View File

@ -17,7 +17,7 @@ export default class ChatMessageRoute extends DiscourseRoute {
params.messageId params.messageId
); );
}) })
.catch(() => this.router.replaceWith("/404")); .catch(() => this.replaceWith("/404"));
} }
beforeModel() { beforeModel() {