FIX: Broken links to site settings under Content section (#33597)

The Content section in particular has four tabs which are all site setting pages. It does not have one under /settings, like other sections.

The admin search functionality will automatically use /settings for multi-tabbed sections. This results in a 404 when searching for Content site settings.

This PR adds a front-end redirect (replaceWith) for /content/settings to fix the immediate issue.
This commit is contained in:
Ted Johansson
2025-07-14 16:14:50 +08:00
committed by GitHub
parent 6bc460a78d
commit 1bf7136b27
5 changed files with 30 additions and 0 deletions
@@ -0,0 +1,3 @@
import AdminAreaSettingsBaseController from "admin/controllers/admin-area-settings-base";
export default class AdminConfigContentSettingsController extends AdminAreaSettingsBaseController {}
@@ -0,0 +1,14 @@
import { service } from "@ember/service";
import DiscourseRoute from "discourse/routes/discourse";
export default class AdminConfigContentSettingsRoute extends DiscourseRoute {
@service router;
beforeModel(transition) {
let { queryParams } = transition.to;
if (transition.to.name !== "adminConfig.content") {
this.router.replaceWith("adminConfig.content", { queryParams });
}
}
}
@@ -251,6 +251,7 @@ export default function () {
);
this.route("content", function () {
this.route("categoriesAndTags", { path: "/" });
this.route("settings");
this.route("sharing");
this.route("postsAndTopics", { path: "/posts-and-topics" });
this.route("statsAndThresholds", { path: "/stats-and-thresholds" });
+1
View File
@@ -409,6 +409,7 @@ Discourse::Application.routes.draw do
resources :site_settings, only: %i[index]
get "analytics-and-seo" => "site_settings#index"
get "content" => "site_settings#index"
get "content/settings" => "site_settings#index"
get "content/sharing" => "site_settings#index"
get "content/posts-and-topics" => "site_settings#index"
get "content/stats-and-thresholds" => "site_settings#index"
+11
View File
@@ -78,4 +78,15 @@ describe "Admin Search", type: :system do
send_keys([SystemHelpers::PLATFORM_KEY_MODIFIER, "/"])
expect(search_modal).to be_open
end
it "works with sections which have a redirect instead of explicit /settings route" do
visit "/admin"
sidebar.click_search_input
search_modal.search("tags tag style")
search_modal.find_result("setting", 0).click
expect(page).to have_current_path("/admin/config/content?filter=tag_style")
end
end