Skip to content

Commit e9e59a2

Browse files
committed
Replace search_sidebar partial override
with a view_component
1 parent 5bc8a5f commit e9e59a2

5 files changed

Lines changed: 34 additions & 5 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<%= render Blacklight::Search::SidebarComponent.new(blacklight_config: blacklight_config,
2+
response: response,
3+
view_config: view_config) %>
4+
<% unless helpers.has_search_parameters? || params[:all] %>
5+
<%= link_to 'Show more facets', root_path(all: true), class: 'btn btn-primary' %>
6+
<% end %>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class Search::SidebarComponent < Blacklight::Component
4+
def initialize(blacklight_config:, response:, view_config:)
5+
@blacklight_config = blacklight_config
6+
@response = response
7+
@view_config = view_config
8+
end
9+
10+
attr_reader :blacklight_config, :response, :view_config
11+
end

app/controllers/catalog_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class CatalogController < ApplicationController
2626
# When we test with solr 6 we can have:
2727
# config.document_solr_path = 'get'
2828
config.index.document_presenter_class = ArgoIndexPresenter
29+
config.index.sidebar_component = Search::SidebarComponent
30+
2931
config.show.document_presenter_class = ArgoShowPresenter
3032

3133
config.index.display_type_field = SolrDocument::FIELD_CONTENT_TYPE

app/views/catalog/_search_sidebar.html.erb

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require "rails_helper"
4+
5+
RSpec.describe Search::SidebarComponent, type: :component do
6+
pending "add some examples to (or delete) #{__FILE__}"
7+
8+
# it "renders something useful" do
9+
# expect(
10+
# render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html
11+
# ).to include(
12+
# "Hello, components!"
13+
# )
14+
# end
15+
end

0 commit comments

Comments
 (0)