A platform for community discussion. Free, open, simple.
FIX: Admin sidebar on mobile was still showing forum panel (#25236)
Martin Brennan80b93e06f7f0
diff --git a/app/assets/javascripts/discourse/app/components/sidebar.hbs b/app/assets/javascripts/discourse/app/components/sidebar.hbsindex 27a16749e5c..f97759abcc3 100644--- a/app/assets/javascripts/discourse/app/components/sidebar.hbs+++ b/app/assets/javascripts/discourse/app/components/sidebar.hbs@@ -9,7 +9,7 @@<Sidebar::Sections@currentUser={{this.currentUser}}@collapsableSections={{true}}- @panel={{this.currentPanel}}+ @panel={{this.sidebarState.currentPanel}}/>{{else}}<Sidebar::ApiPanelsdiff --git a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbsindex 3baeb1578bd..48338c55a0d 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs+++ b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs@@ -7,10 +7,18 @@<div class="panel-body"><div class="panel-body-contents"><div class="sidebar-hamburger-dropdown">- <Sidebar::Sections- @currentUser={{this.currentUser}}- @collapsableSections={{this.collapsableSections}}- />+ {{#if this.sidebarState.showMainPanel}}+ <Sidebar::Sections+ @currentUser={{this.currentUser}}+ @collapsableSections={{this.collapsableSections}}+ @panel={{this.sidebarState.currentPanel}}+ />+ {{else}}+ <Sidebar::ApiPanels+ @currentUser={{this.currentUser}}+ @collapsableSections={{this.collapsableSections}}+ />+ {{/if}}<Sidebar::Footer @tagName="" /></div></div>diff --git a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.jsindex 6e17d85693c..38ccbddcbb8 100644--- a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js+++ b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js@@ -7,6 +7,7 @@ export default class SidebarHamburgerDropdown extends Component {@service currentUser;@service site;@service siteSettings;+ @service sidebarState;@actiontriggerRenderedAppEvent() {diff --git a/spec/system/admin_revamp_sidebar_navigation_spec.rb b/spec/system/admin_revamp_sidebar_navigation_spec.rbindex 2aa85ef9c89..070c0d0d773 100644--- a/spec/system/admin_revamp_sidebar_navigation_spec.rb+++ b/spec/system/admin_revamp_sidebar_navigation_spec.rb@@ -2,7 +2,9 @@describe "Admin Revamp | Sidebar Navigation", type: :system dofab!(:admin)+let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }+ let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }before doSiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]@@ -11,15 +13,35 @@ describe "Admin Revamp | Sidebar Navigation", type: :system doit "shows the sidebar when navigating to an admin route and hides it when leaving" dovisit("/latest")+ expect(sidebar).to have_section("community")sidebar.click_link_in_section("community", "admin")expect(page).to have_current_path("/admin")expect(sidebar).to be_visible+ expect(sidebar).to have_no_section("community")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+ 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+ visit("/latest")+ sidebar_dropdown.click+ expect(sidebar).to have_section("community")+ sidebar.click_link_in_section("community", "admin")+ expect(page).to have_current_path("/admin")+ sidebar_dropdown.click+ expect(sidebar).to have_no_section("community")+ 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")+ sidebar_dropdown.click+ expect(sidebar).to have_no_section("admin-nav-section-root")+ end+ end+context "when the setting is disabled" dobefore { SiteSetting.admin_sidebar_enabled_groups = "" }