Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor label classes to badges #3503

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/views/layouts/rails_admin/_secondary_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<% end %>
<% if logout_path.present? %>
<li class="nav-item">
<%= link_to t('admin.misc.log_out'), logout_path, method: logout_method, class: 'nav-link label label-danger', data: {turbo: 'false'} %>
<%= link_to logout_path, method: logout_method, class: 'nav-link', data: {turbo: 'false'} do %>
<span class="badge bg-danger"><%= t('admin.misc.log_out') %></span>
<% end %>
</li>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/config/fields/types/boolean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Boolean < RailsAdmin::Config::Fields::Base
end

register_instance_option :pretty_value do
%(<span class="label label-#{css_classes[form_value]}">#{labels[form_value]}</span>).html_safe
%(<span class="badge bg-#{css_classes[form_value]}">#{labels[form_value]}</span>).html_safe
end

register_instance_option :export_value do
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/rails_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
is_expected.to have_content 'Log out'
end

it 'has label-danger class on log out link' do
it 'has bg-danger class on log out link' do
visit dashboard_path
is_expected.to have_selector('.label-danger')
is_expected.to have_selector('.bg-danger')
end

it 'has links for actions which are marked as show_in_navigation' do
Expand Down
6 changes: 3 additions & 3 deletions spec/rails_admin/config/fields/types/boolean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

describe '#pretty_value' do
{
false => %(<span class="label label-danger"><span class="fas fa-times"></span></span>),
true => %(<span class="label label-success"><span class="fas fa-check"></span></span>),
nil => %(<span class="label label-default"><span class="fas fa-minus"></span></span>),
false => %(<span class="badge bg-danger"><span class="fas fa-times"></span></span>),
true => %(<span class="badge bg-success"><span class="fas fa-check"></span></span>),
nil => %(<span class="badge bg-default"><span class="fas fa-minus"></span></span>),
}.each do |field_value, expected_result|
context "when field value is '#{field_value.inspect}'" do
let(:test_object) { FieldTest.new(boolean_field: field_value) }
Expand Down