Feature #28531

Add css to distinguish when a main menu is present or not

Added by Felix Schäfer 6 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:UI
Target version:4.0.0
Resolution:Fixed

Description

We have a theme with a styling dependent on knowing when a main menu is present. We previously used a body[class*="project-"] selector to test when a project is shown, but as there is now a global main menu in some cases this doesn't work anymore.

We would suggest the following addition:

--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -592,6 +592,7 @@ module ApplicationHelper
     end

     css << 'project-' + @project.identifier if @project && @project.identifier.present?
+    css << 'has-main-menu' if display_main_menu?(@project)
     css << 'controller-' + controller_name
     css << 'action-' + action_name
     css << 'avatars-' + (Setting.gravatar_enabled? ? 'on' : 'off')

Associated revisions

Revision 17303
Added by Go MAEDA 6 months ago

Add CSS to distinguish when a main menu is present or not (#28531).

Patch by Felix Schäfer.

History

#1 Updated by Go MAEDA 6 months ago

  • Target version set to Candidate for next major release

Here is a test code for the feature.

index d52fef2d5..0b01f5d7f 100644
--- a/test/integration/lib/redmine/menu_manager_test.rb
+++ b/test/integration/lib/redmine/menu_manager_test.rb
@@ -77,4 +77,11 @@ class MenuManagerTest < Redmine::IntegrationTest
     get '/login'
     assert_select '#main-menu', 0
   end
+
+  def test_body_should_have_main_menu_css_class_if_main_menu_is_present
+    get '/projects'
+    assert_select 'body.has-main-menu'
+    get '/'
+    assert_select 'body.has-main-menu', 0
+  end
 end

#2 Updated by Felix Schäfer 6 months ago

Thank you!

#3 Updated by Go MAEDA 6 months ago

  • Category changed from Themes to UI
  • Target version changed from Candidate for next major release to 4.1.0

Setting target version to 4.1.0.

#4 Updated by Go MAEDA 6 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Target version changed from 4.1.0 to 4.0.0
  • Resolution set to Fixed

Committed. Thanks.

Also available in: Atom PDF