FEATURE: filter admin sidebar (#25853)

Ability to filter admin sidebar. The filter can be cleared. In addition, it can be accessed with ctrl+/ shortcut
This commit is contained in:
Krzysztof Kotlarek
2024-02-28 12:15:02 +11:00
committed by GitHub
parent ffce2dd04f
commit 8b5204579c
15 changed files with 298 additions and 47 deletions

View File

@ -5,6 +5,7 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
let(:filter) { PageObjects::Components::Filter.new }
before do
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
@ -60,4 +61,34 @@ describe "Admin Revamp | Sidebar Navigation", type: :system do
expect(sidebar).to have_no_section("admin-nav-section-root")
end
end
it "allows links to be filtered" do
visit("/admin")
all_links_count = page.all(".sidebar-section-link-content-text").count
links = page.all(".sidebar-section-link-content-text")
expect(links.count).to eq(all_links_count)
expect(page).to have_no_css(".sidebar-no-results")
filter.filter("ie")
links = page.all(".sidebar-section-link-content-text")
expect(links.count).to eq(2)
expect(links.map(&:text)).to eq(["Preview Summary", "User Fields"])
expect(page).to have_no_css(".sidebar-no-results")
filter.filter("ieeee")
expect(page).to have_no_css(".sidebar-section-link-content-text")
expect(page).to have_css(".sidebar-no-results")
filter.clear
links = page.all(".sidebar-section-link-content-text")
expect(links.count).to eq(all_links_count)
expect(page).to have_no_css(".sidebar-no-results")
# When match section title, display all links
filter.filter("Backups")
links = page.all(".sidebar-section-link-content-text")
expect(links.count).to eq(2)
expect(links.map(&:text)).to eq(%w[Backups Logs])
end
end