FEATURE: Initial admin sidebar navigation (#24789)

This is v0 of admin sidebar navigation, which moves
all of the top-level admin nav from the top of the page
into a sidebar. This is hidden behind a enable_admin_sidebar_navigation
site setting, and is opt-in for now.

This sidebar is dynamically shown whenever the user enters an
admin route in the UI, and is hidden and replaced with either
the:

* Main forum sidebar
* Chat sidebar

Depending on where they navigate to. For now, custom sections
are not supported in the admin sidebar.

This commit removes the experimental admin sidebar generation rake
task but keeps the experimental sidebar UI for now for further
testing; it just uses the real nav as the default now.
This commit is contained in:
Martin Brennan
2023-12-18 11:48:25 +10:00
committed by GitHub
parent 194c84b217
commit 6de00f89c2
17 changed files with 252 additions and 367 deletions

View File

@ -2,18 +2,29 @@
describe "Admin Revamp | Sidebar Navigation", type: :system do
fab!(:admin)
let(:sidebar_page) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
before do
SiteSetting.enable_experimental_admin_ui_groups = Group::AUTO_GROUPS[:staff]
SidebarSection.find_by(section_type: "community").reset_community!
SiteSetting.enable_admin_sidebar_navigation = true
sign_in(admin)
end
it "navigates to the admin revamp from the sidebar" do
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
visit("/latest")
sidebar_page.click_section_link("Admin Revamp")
expect(page).to have_content("Lobby")
expect(page).to have_content("Legacy Admin")
sidebar.click_link_in_section("community", "admin")
expect(page).to have_current_path("/admin")
expect(sidebar).to be_visible
expect(page).to have_no_css(".admin-main-nav")
sidebar.click_link_in_section("admin-nav-section-root", "back_to_forum")
expect(page).to have_current_path("/latest")
expect(sidebar).to have_no_section("admin-nav-section-root")
end
it "does not show the admin sidebar if the setting is disabled" do
SiteSetting.enable_admin_sidebar_navigation = false
visit("/latest")
sidebar.click_link_in_section("community", "admin")
expect(page).to have_current_path("/admin")
expect(sidebar).to have_no_section("admin-nav-section-root")
end
end

View File

@ -4,16 +4,34 @@ module PageObjects
module Components
module NavigationMenu
class Base < PageObjects::Components::Base
def community_section
find(".sidebar-section[data-section-name='community']")
SIDEBAR_SECTION_LINK_SELECTOR = "sidebar-section-link"
def visible?
has_css?("#d-sidebar.sidebar-container")
end
SIDEBAR_SECTION_LINK_SELECTOR = "sidebar-section-link"
def hidden?
has_no_css?("#d-sidebar.sidebar-container")
end
def community_section
find_section("community")
end
def find_section(name)
find(".sidebar-section[data-section-name='#{name}']")
end
def click_section_link(name)
find(".#{SIDEBAR_SECTION_LINK_SELECTOR}", text: name).click
end
def click_link_in_section(section_name, link_name)
find_section(section_name.parameterize).find(
".#{SIDEBAR_SECTION_LINK_SELECTOR}[data-link-name=\"#{link_name.parameterize}\"]",
).click
end
def has_one_active_section_link?
has_css?(".#{SIDEBAR_SECTION_LINK_SELECTOR}--active", count: 1)
end
@ -30,6 +48,10 @@ module PageObjects
has_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
end
def has_no_section?(name)
has_no_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
end
def switch_to_chat
find(".sidebar__panel-switch-button[data-key='chat']").click
end