A platform for community discussion. Free, open, simple.
FIX: Routing back to homepage from admin sidebar (#29125)
Penar Musaraj520f71b8f8a0
diff --git a/app/assets/javascripts/discourse/app/components/sidebar/back-to-forum.gjs b/app/assets/javascripts/discourse/app/components/sidebar/back-to-forum.gjsindex 5f237193d3a..b77868f7007 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/back-to-forum.gjs+++ b/app/assets/javascripts/discourse/app/components/sidebar/back-to-forum.gjs@@ -1,17 +1,13 @@-import { LinkTo } from "@ember/routing";-import { defaultHomepage } from "discourse/lib/utilities";import icon from "discourse-common/helpers/d-icon";import i18n from "discourse-common/helpers/i18n";+import getURL from "discourse-common/lib/get-url";const BackToForum = <template>- <LinkTo- @route="discovery.{{(defaultHomepage)}}"- class="sidebar-sections__back-to-forum"- >+ <a href={{getURL "/"}} class="sidebar-sections__back-to-forum">{{icon "arrow-left"}}<span>{{i18n "sidebar.back_to_forum"}}</span>- </LinkTo>+ </a></template>;export default BackToForum;diff --git a/config/routes.rb b/config/routes.rbindex a1a734a2976..629ab3c2c47 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -1607,6 +1607,8 @@ Discourse::Application.routes.draw doconstraints: HomePageConstraint.new("custom"),as: "custom_index"+ get "/custom" => "custom_homepage#index"+get "/user-api-key/new" => "user_api_keys#new"post "/user-api-key" => "user_api_keys#create"post "/user-api-key/revoke" => "user_api_keys#revoke"diff --git a/spec/system/admin_sidebar_navigation_spec.rb b/spec/system/admin_sidebar_navigation_spec.rbindex 84ebdac0d99..0b5464b97c8 100644--- a/spec/system/admin_sidebar_navigation_spec.rb+++ b/spec/system/admin_sidebar_navigation_spec.rb@@ -27,10 +27,21 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doexpect(sidebar).to have_no_section("categories")expect(page).to have_no_css(".admin-main-nav")filter.click_back_to_forum- expect(page).to have_current_path("/latest")+ expect(page).to have_current_path("/")expect(sidebar).to have_no_section("admin-root")end+ context "with subfolder" do+ before { set_subfolder "/discuss" }++ it "navigates back to homepage correctly" do+ visit("/discuss/admin")++ filter.click_back_to_forum+ expect(page).to have_current_path("/discuss/")+ end+ end+it "displays the panel header" dovisit("/admin")expect(sidebar).to have_panel_header@@ -43,14 +54,6 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doexpect(links.map(&:text)).to eq(["Dashboard", "Users", "All Site Settings"])end- it "respects the user homepage preference for the Back to Forum link" do- admin.user_option.update!(- homepage_id: UserOption::HOMEPAGES.find { |id, value| value == "categories" }.first,- )- visit("/admin")- expect(page).to have_link("Back to Forum", href: "/categories")- end-context "when on mobile" doit "shows the admin sidebar links in the header-dropdown when navigating to an admin route and hides them when leaving",mobile: true do@@ -63,7 +66,7 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doexpect(sidebar).to have_no_section("community")expect(page).to have_no_css(".admin-main-nav")filter.click_back_to_forum- expect(page).to have_current_path("/latest")+ expect(page).to have_current_path("/")sidebar_dropdown.clickexpect(sidebar).to have_no_section("admin-root")end