FIX: Admin sidebar disappeared on some routes for header dropdown (#27216)

When navigation_menu is set to header dropdown, we are
still forcing admin sidebar by checking if the user is an
admin route (c.f. 9bcbfbba43).

However in the initial commit the route check had the
false premise that all admin routes started with `admin.`;
there are others that don't. We need to force admin sidebar
on all routes starting with `admin` (no `.`).

c.f. https://meta.discourse.org/t/feedback-on-admin-sidebar-when-header-dropdown-navigation-selected/309490/3?u=martin
This commit is contained in:
Martin Brennan 2024-05-28 11:47:54 +10:00 committed by GitHub
parent 998b50fdf4
commit 73c6bb2593
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -99,7 +99,7 @@ export default Controller.extend({
// Always show sidebar for admin if user can see the admin sidbar
if (
this.router.currentRouteName.startsWith("admin.") &&
this.router.currentRouteName.startsWith("admin") &&
this.currentUser?.use_admin_sidebar
) {
return true;

View File

@ -50,6 +50,15 @@ describe "Navigation menu states", type: :system, js: true do
expect(header_dropdown).to have_no_dropdown_visible
end
it "shows the sidebar on other admin pages" do
visit "/admin"
expect(sidebar_navigation).to be_visible
visit "/admin/site_settings/category/all_results"
expect(sidebar_navigation).to be_visible
visit "/admin/reports"
expect(sidebar_navigation).to be_visible
end
context "when the user is not in admin_sidebar_enabled_groups" do
before { SiteSetting.admin_sidebar_enabled_groups = "" }