FIX: Respect homepage prefs on admin sidebar Back to Forum link (#25642)
This commit is contained in:
parent
3094f32ff5
commit
5935148bd8
|
@ -4,6 +4,7 @@ import BaseCustomSidebarPanel from "discourse/lib/sidebar/base-custom-sidebar-pa
|
|||
import BaseCustomSidebarSection from "discourse/lib/sidebar/base-custom-sidebar-section";
|
||||
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/base-custom-sidebar-section-link";
|
||||
import { ADMIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||
import { defaultHomepage } from "discourse/lib/utilities";
|
||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
|
@ -109,7 +110,7 @@ export function useAdminNavConfig(navMap) {
|
|||
links: [
|
||||
{
|
||||
name: "back_to_forum",
|
||||
route: "discovery.latest",
|
||||
route: `discovery.${defaultHomepage()}`,
|
||||
label: "admin.back_to_forum",
|
||||
icon: "arrow-left",
|
||||
},
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UserOption < ActiveRecord::Base
|
||||
HOMEPAGES = {
|
||||
1 => "latest",
|
||||
2 => "categories",
|
||||
3 => "unread",
|
||||
4 => "new",
|
||||
5 => "top",
|
||||
6 => "bookmarks",
|
||||
7 => "unseen",
|
||||
}
|
||||
|
||||
self.ignored_columns = [
|
||||
"disable_jump_reply", # Remove once 20210706091905 is promoted from post_deploy to regular migration
|
||||
"sidebar_list_destination", # TODO(osama): Remove in January 2024
|
||||
|
@ -170,30 +180,11 @@ class UserOption < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def homepage
|
||||
case homepage_id
|
||||
when 1
|
||||
"latest"
|
||||
when 2
|
||||
"categories"
|
||||
when 3
|
||||
"unread"
|
||||
when 4
|
||||
"new"
|
||||
when 5
|
||||
"top"
|
||||
when 6
|
||||
"bookmarks"
|
||||
when 7
|
||||
"unseen"
|
||||
when 8
|
||||
if SiteSetting.experimental_hot_topics
|
||||
"hot"
|
||||
else
|
||||
SiteSetting.homepage
|
||||
end
|
||||
else
|
||||
SiteSetting.homepage
|
||||
end
|
||||
return HOMEPAGES[homepage_id] if HOMEPAGES.keys.include?(homepage_id)
|
||||
|
||||
return SiteSetting.experimental_hot_topics ? "hot" : SiteSetting.homepage if homepage_id == 8
|
||||
|
||||
SiteSetting.homepage
|
||||
end
|
||||
|
||||
def text_size
|
||||
|
|
|
@ -24,6 +24,14 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
|
|||
expect(sidebar).to have_no_section("admin-nav-section-root")
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue