mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:12:45 +08:00
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 BaseCustomSidebarSection from "discourse/lib/sidebar/base-custom-sidebar-section";
|
||||||
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/base-custom-sidebar-section-link";
|
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/base-custom-sidebar-section-link";
|
||||||
import { ADMIN_PANEL } from "discourse/lib/sidebar/panels";
|
import { ADMIN_PANEL } from "discourse/lib/sidebar/panels";
|
||||||
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ export function useAdminNavConfig(navMap) {
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
name: "back_to_forum",
|
name: "back_to_forum",
|
||||||
route: "discovery.latest",
|
route: `discovery.${defaultHomepage()}`,
|
||||||
label: "admin.back_to_forum",
|
label: "admin.back_to_forum",
|
||||||
icon: "arrow-left",
|
icon: "arrow-left",
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class UserOption < ActiveRecord::Base
|
class UserOption < ActiveRecord::Base
|
||||||
|
HOMEPAGES = {
|
||||||
|
1 => "latest",
|
||||||
|
2 => "categories",
|
||||||
|
3 => "unread",
|
||||||
|
4 => "new",
|
||||||
|
5 => "top",
|
||||||
|
6 => "bookmarks",
|
||||||
|
7 => "unseen",
|
||||||
|
}
|
||||||
|
|
||||||
self.ignored_columns = [
|
self.ignored_columns = [
|
||||||
"disable_jump_reply", # Remove once 20210706091905 is promoted from post_deploy to regular migration
|
"disable_jump_reply", # Remove once 20210706091905 is promoted from post_deploy to regular migration
|
||||||
"sidebar_list_destination", # TODO(osama): Remove in January 2024
|
"sidebar_list_destination", # TODO(osama): Remove in January 2024
|
||||||
|
@ -170,30 +180,11 @@ class UserOption < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def homepage
|
def homepage
|
||||||
case homepage_id
|
return HOMEPAGES[homepage_id] if HOMEPAGES.keys.include?(homepage_id)
|
||||||
when 1
|
|
||||||
"latest"
|
return SiteSetting.experimental_hot_topics ? "hot" : SiteSetting.homepage if homepage_id == 8
|
||||||
when 2
|
|
||||||
"categories"
|
SiteSetting.homepage
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_size
|
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")
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
||||||
end
|
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
|
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",
|
it "shows the admin sidebar links in the header-dropdown when navigating to an admin route and hides them when leaving",
|
||||||
mobile: true do
|
mobile: true do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user