projectblacklight / blacklight

Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr) index.
http://projectblacklight.org/
Other
757 stars 256 forks source link

Unsupported ViewComponent slots in SMS and Email tools #3102

Closed body-clock closed 6 months ago

body-clock commented 8 months ago

The gemspec for Blacklight specifies a version of ViewComponent that is '>= 2.66', '< 4'. In my project, with ViewComponent 3.0, the SMS and Email tools were not rendering correctly. Per the ViewComponent changelog, ViewComponent 3.0 contains the following breaking changes:

The SMS and Email tools are still rendered using the deprecated setter methods. Here's the SMS code for example:

<%= render Blacklight::System::ModalComponent.new do |component| %>
  <% component.title { t('blacklight.sms.form.title') } %>

  <% component.body do %>
    <%= render 'sms_form' %>
  <% end %>
<% end %>

This code can be fixed by updating it to the following:

<%= render Blacklight::System::ModalComponent.new do |component| %>
  <% component.with_title { t('blacklight.sms.form.title') } %>

  <% component.with_body do %>
    <%= render 'sms_form' %>
  <% end %>
<% end %>

The alternative solution is to limit the ViewComponent version to something < 3.0, but it seems like transition to the newer setter methods has been started.

jrochkind commented 8 months ago

Can you say what version of Blacklight you are using please? What version this is broken with, and what version you were previously using that it worked with?

It sounds like maybe we don't have tests covering those components. :(

jrochkind commented 8 months ago

As a workaround until this is fixed, you can probably get things to work by continuing to use view_component 2.x in your app. If the version of BL you are using supports both 2.x and 3.x, you can use 2.x in your app simply by adding this to your local app Gemfile:

gem "view_component", "~> 2.0"

That will make your app restrict to 2.x, even though BL says it supports either 2.x or 3.x -- since you have apparently discovered that certain features are actually broken with 3.x.

body-clock commented 8 months ago

I'm using Blacklight 8.0.1. I don't have previous experience with Blacklight, so that's all the info I have. I was able to fix this temporarily by adding the following to my gemfile:

gem 'view_component', '~> 2.66'

Thanks for your quick reply.