discourse/app/assets/javascripts/admin/addon/routes/admin-site-settings-index.js
Isaac Janzen 3eb8046dde
DEV: Update replaceWith on Route (#23153)
# Context
This PR was originally implemented in https://github.com/discourse/discourse/pull/22645 then reverted in https://github.com/discourse/discourse/pull/22693. We protect from aborted transition when _awaiting_ on `replaceWith` by utilizing [followRedirects()](https://api.emberjs.com/ember/5.1/classes/Transition/methods/followRedirects?anchor=followRedirects)

# Description
Per https://deprecations.emberjs.com/v3.x/#toc_routing-transition-methods

We are upgrading all `this.replaceWith` calls on routes to directly call the router service (`this.router.replaceWith`)
2023-08-21 16:53:54 -05:00

19 lines
530 B
JavaScript

/**
Handles when you click the Site Settings tab in admin, but haven't
chosen a category. It will redirect to the first category.
**/
import DiscourseRoute from "discourse/routes/discourse";
import { inject as service } from "@ember/service";
export default class AdminSiteSettingsIndexRoute extends DiscourseRoute {
@service router;
beforeModel() {
this.router.replaceWith(
"adminSiteSettingsCategory",
this.controllerFor("adminSiteSettings").get("visibleSiteSettings")[0]
.nameKey
);
}
}