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

Backport #2979 #2983

Open
wants to merge 2 commits into
base: release-7.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/blacklight/response/sort_component.rb
Expand Up @@ -2,8 +2,8 @@

module Blacklight
module Response
class SortComponent < ViewComponent::Base
def initialize(param: 'sort', choices: {}, search_state:, id: 'sort-dropdown', classes: [], selected: nil)
class SortComponent < Blacklight::Componant
def initialize(search_state:, param: 'sort', choices: {}, id: 'sort-dropdown', classes: [], selected: nil)
@param = param
@choices = choices
@search_state = search_state
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/response/spellcheck_component.rb
Expand Up @@ -3,7 +3,7 @@
module Blacklight
module Response
# Render spellcheck results for a search query
class SpellcheckComponent < ViewComponent::Base
class SpellcheckComponent < Blacklight::Component
# @param [Blacklight::Response] response
# @param [Array<String>] options explicit spellcheck options to render
def initialize(response:, options: nil)
Expand Down
Expand Up @@ -3,7 +3,7 @@
module Blacklight
module Response
# Render spellcheck results for a search query
class ViewTypeButtonComponent < ViewComponent::Base
class ViewTypeButtonComponent < Blacklight::Component
with_collection_parameter :view
# @param [Blacklight::Configuration::View] view
def initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon')
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/response/view_type_component.rb
Expand Up @@ -3,7 +3,7 @@
module Blacklight
module Response
# Render spellcheck results for a search query
class ViewTypeComponent < ViewComponent::Base
class ViewTypeComponent < Blacklight::Component
renders_many :views, 'Blacklight::Response::ViewTypeButtonComponent'

# @param [Blacklight::Response] response
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/system/dropdown_component.rb
Expand Up @@ -2,7 +2,7 @@

module Blacklight
module System
class DropdownComponent < ViewComponent::Base
class DropdownComponent < Blacklight::Component
renders_one :button, (lambda do |classes:, label:|
button_tag class: classes, aria: { expanded: false }, data: { toggle: 'dropdown', 'bs-toggle': 'dropdown' } do
safe_join([label, content_tag(:span, '', class: 'caret')])
Expand Down
Expand Up @@ -2,7 +2,7 @@

module Blacklight
module System
class FlashMessageComponent < ViewComponent::Base
class FlashMessageComponent < Blacklight::Component
renders_one :message

with_collection_parameter :message
Expand Down
3 changes: 1 addition & 2 deletions app/components/blacklight/system/modal_component.rb
Expand Up @@ -2,9 +2,8 @@

module Blacklight
module System
class ModalComponent < ViewComponent::Base
class ModalComponent < Blacklight::Component
include Blacklight::ContentAreasShim

renders_one :prefix
renders_one :header
renders_one :title
Expand Down
8 changes: 8 additions & 0 deletions spec/features/component_template_override_spec.rb
@@ -0,0 +1,8 @@
# frozen_string_literal: true

RSpec.describe 'Generated test application template at default path' do
it 'unobtrusively overrides default top navbar component template' do
visit root_path
expect(page).to have_css 'nav[data-template-override="top_navbar_component"]'
end
end
8 changes: 8 additions & 0 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
Expand Up @@ -27,4 +27,12 @@ def run_test_support_generator

generate 'blacklight:test_support'
end

def add_component_template_override
src_template = File.join(Blacklight::Engine.root, 'app', 'components', 'blacklight', 'top_navbar_component.html.erb')
target_template = File.join('app', 'components', 'blacklight', 'top_navbar_component.html.erb')
create_file(target_template) do
File.read(src_template).gsub('role="navigation"', 'role="navigation" data-template-override="top_navbar_component"')
end
end
end