mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Routing back to homepage from admin sidebar (#29125)
This commit is contained in:
parent
315f8c5ec6
commit
520f71b8f8
@ -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;
|
||||
|
@ -1607,6 +1607,8 @@ Discourse::Application.routes.draw do
|
||||
constraints: 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"
|
||||
|
@ -27,10 +27,21 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
||||
expect(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" do
|
||||
visit("/admin")
|
||||
expect(sidebar).to have_panel_header
|
||||
@ -43,14 +54,6 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
||||
expect(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" do
|
||||
it "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 do
|
||||
expect(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.click
|
||||
expect(sidebar).to have_no_section("admin-root")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user