From e000bd9a6131f8538f7b597b1a4a89a1c3ced4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 12 Jan 2023 16:42:43 +0100 Subject: [PATCH] Hide menu button to managers on small screens This menu isn't rendered in this case, so the "menu" button to toggle it did nothing. --- .../layout/admin_header_component.html.erb | 16 +++++++++------- app/components/layout/admin_header_component.rb | 4 ++++ .../layout/admin_header_component_spec.rb | 6 ++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/components/layout/admin_header_component.html.erb b/app/components/layout/admin_header_component.html.erb index 05251335a..f1be1d2f6 100644 --- a/app/components/layout/admin_header_component.html.erb +++ b/app/components/layout/admin_header_component.html.erb @@ -8,12 +8,14 @@
-
- -
+ <% if show_account_menu? %> +
+ +
+ <% end %>
@@ -25,7 +27,7 @@
- <% if show_admin_menu?(user) || namespace != "management" %> + <% if show_account_menu? %>
<%= render Layout::AccountMenuComponent.new(user) %> diff --git a/app/components/layout/admin_header_component.rb b/app/components/layout/admin_header_component.rb index 4d730dd02..3f97f9656 100644 --- a/app/components/layout/admin_header_component.rb +++ b/app/components/layout/admin_header_component.rb @@ -25,4 +25,8 @@ class Layout::AdminHeaderComponent < ApplicationComponent namespaced_root_path end end + + def show_account_menu? + show_admin_menu?(user) || namespace != "management" + end end diff --git a/spec/components/layout/admin_header_component_spec.rb b/spec/components/layout/admin_header_component_spec.rb index bbcfa319a..62a938369 100644 --- a/spec/components/layout/admin_header_component_spec.rb +++ b/spec/components/layout/admin_header_component_spec.rb @@ -9,7 +9,7 @@ describe Layout::AdminHeaderComponent do end context "management section", controller: Management::BaseController do - it "shows the menu for administrators" do + it "shows the menu button and menu for administrators" do create(:administrator, user: user) render_inline Layout::AdminHeaderComponent.new(user) @@ -19,9 +19,10 @@ describe Layout::AdminHeaderComponent do expect(page).to have_link "My content" expect(page).to have_link "My account" expect(page).to have_link "Sign out" + expect(page).to have_css "[data-toggle]" end - it "does not show the menu managers" do + it "does not show the menu button and menu for managers" do create(:manager, user: user) render_inline Layout::AdminHeaderComponent.new(user) @@ -31,6 +32,7 @@ describe Layout::AdminHeaderComponent do expect(page).not_to have_content "My content" expect(page).not_to have_content "My account" expect(page).not_to have_content "Sign out" + expect(page).not_to have_css "[data-toggle]" end end end