diff --git a/app/components/spotlight/bulk_action_component.html.erb b/app/components/spotlight/bulk_action_component.html.erb new file mode 100644 index 000000000..719afc5d4 --- /dev/null +++ b/app/components/spotlight/bulk_action_component.html.erb @@ -0,0 +1,8 @@ + diff --git a/app/components/spotlight/bulk_action_component.rb b/app/components/spotlight/bulk_action_component.rb new file mode 100644 index 000000000..1fb9faebc --- /dev/null +++ b/app/components/spotlight/bulk_action_component.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Spotlight + # Displays the "Bulk actions" button and dropdown + class BulkActionComponent < ViewComponent::Base + def initialize(bulk_actions:, button_classes: 'btn btn-secondary dropdown-toggle') + @bulk_actions = bulk_actions + @button_classes = button_classes + super + end + + attr_reader :button_classes, :bulk_actions + + def button + button_tag t(:'spotlight.bulk_actions.label'), id: 'bulk-actions-button', class: button_classes, + data: { toggle: 'dropdown', 'bs-toggle': 'dropdown' }, + aria: { haspopup: true, expanded: false } + end + end +end diff --git a/app/views/catalog/_bulk_actions.html.erb b/app/views/catalog/_bulk_actions.html.erb index 561856c07..4ba24fef3 100644 --- a/app/views/catalog/_bulk_actions.html.erb +++ b/app/views/catalog/_bulk_actions.html.erb @@ -1,12 +1,3 @@ - +<%= render Spotlight::BulkActionComponent.new(bulk_actions: blacklight_config.bulk_actions) %> <%= render_filtered_partials(blacklight_config.bulk_actions) %> diff --git a/spec/features/bulk_actions_spec.rb b/spec/features/bulk_actions_spec.rb index 5c2ae5043..b2c49acc1 100644 --- a/spec/features/bulk_actions_spec.rb +++ b/spec/features/bulk_actions_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -describe 'Bulk actions', type: :feature do +RSpec.describe 'Bulk actions', type: :feature do let(:exhibit) { FactoryBot.create(:exhibit) } let(:curator) { FactoryBot.create(:exhibit_curator, exhibit:) }