Skip to content

Commit

Permalink
Allow configuration of Navbar css class
Browse files Browse the repository at this point in the history
Refs. #3507
  • Loading branch information
mshibuya committed Apr 25, 2022
1 parent e5bb7ba commit 99708e0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Metrics/MethodLength:
Max: 29 # TODO: Lower to 15

Metrics/ModuleLength:
Max: 217 # TODO: Lower to 100
Max: 219 # TODO: Lower to 100

Metrics/ParameterLists:
Max: 8 # TODO: Lower to 4
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/rails_admin/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body class="rails_admin">
<div data-i18n-options="<%= I18n.t("admin.js").to_json %>" id="admin-js"></div>
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-primary border-bottom">
<nav class="navbar navbar-expand-md fixed-top <%= RailsAdmin::Config.navbar_css_classes.join(' ') %>">
<%= render "layouts/rails_admin/navigation" %>
</nav>
<div class="container-fluid">
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class << self
# @see RailsAdmin.config
attr_reader :registry

# Bootstrap CSS classes used for Navigation bar
attr_accessor :navbar_css_classes

# show Gravatar in Navigation bar
attr_accessor :show_gravatar

Expand Down Expand Up @@ -336,6 +339,7 @@ def reset
@label_methods = %i[name title]
@main_app_name = proc { [Rails.application.engine_name.titleize.chomp(' Application'), 'Admin'] }
@registry = {}
@navbar_css_classes = %w[navbar-dark bg-primary border-bottom]
@show_gravatar = true
@navigation_static_links = {}
@navigation_static_label = nil
Expand Down
14 changes: 14 additions & 0 deletions spec/integration/rails_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
end
end

describe 'navbar css class' do
it 'is set by default' do
expect(RailsAdmin.config.navbar_css_classes).to eq(['navbar-dark', 'bg-primary', 'border-bottom'])
end

it 'can be configured' do
RailsAdmin.config do |config|
config.navbar_css_classes = %w[navbar-light border-bottom]
end
visit dashboard_path
is_expected.to have_css('nav.navbar.navbar-light.border-bottom')
end
end

describe '_current_user' do # https://github.com/railsadminteam/rails_admin/issues/549
it 'is accessible from the list view' do
RailsAdmin.config Player do
Expand Down

0 comments on commit 99708e0

Please sign in to comment.