Skip to content

Commit

Permalink
Merge pull request #3344 from projectblacklight/view_config
Browse files Browse the repository at this point in the history
Assert that view_config will be not nil
  • Loading branch information
jcoyne authored Nov 21, 2024
2 parents 2c0fe7c + 22f68b9 commit db5d87f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/components/blacklight/document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class DocumentComponent < Blacklight::Component

# The document title with some reasonable default behavior
renders_one :title, (lambda do |*args, component: nil, **kwargs|
component ||= @presenter&.view_config&.title_component || Blacklight::DocumentTitleComponent
component ||= view_config.title_component || Blacklight::DocumentTitleComponent

component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
end)

renders_one :embed, (lambda do |static_content = nil, *args, component: nil, **kwargs|
next static_content if static_content.present?

component ||= @presenter.view_config&.embed_component
component ||= view_config.embed_component

next unless component

Expand All @@ -53,7 +53,7 @@ class DocumentComponent < Blacklight::Component
renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
next static_content if static_content.present?

component ||= @presenter&.view_config&.metadata_component || Blacklight::DocumentMetadataComponent
component ||= view_config.metadata_component || Blacklight::DocumentMetadataComponent

component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
end)
Expand All @@ -64,7 +64,7 @@ class DocumentComponent < Blacklight::Component
renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, *args, component: nil, **kwargs|
next image_options_or_static_content if image_options_or_static_content.is_a? String

component ||= @presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
component ||= view_config.thumbnail_component || Blacklight::Document::ThumbnailComponent

component.new(*args, document: @document, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
end)
Expand Down Expand Up @@ -134,6 +134,8 @@ def before_render

private

delegate :view_config, to: :@presenter

attr_reader :document_counter, :presenter, :view_partials

def show?
Expand Down

0 comments on commit db5d87f

Please sign in to comment.