-
Notifications
You must be signed in to change notification settings - Fork 253
Upgrading to Blacklight 8
Justin Coyne edited this page Nov 22, 2021
·
47 revisions
Blacklight 8 includes some backwards-incompatible changes. Follow this guide to upgrade a Blacklight 7 application to Blacklight 8.
-
Ensure your local application has a passing test suite. If needed, add automated tests for any important functionality, to make it obvious when something is broken.
-
Upgrade to the latest 7.x release so you can see any recent deprecation warnings.
-
Take note of any deprecation warnings originating from Blacklight in the logs and make the suggested changes.
-
@document_listis no longer provided by Blacklight, becauseBlacklight::SearchService#search_resultsnow returns a single value rather than a tuple: https://github.com/projectblacklight/blacklight/blob/2430033de0f8c54ef7407e28228b3702f1fd3e0a/app/services/blacklight/search_service.rb#L24 This instance variable was previously aActiveSupport::Deprecation::DeprecatedObjectProxy -
Blacklight::SearchService#fetchnow returns a single value rather than two values. - Remove
component: trueconfiguration fromadd_facet_fieldinCatalogController - If you previously used a partials configuration in
CatalogControllerlike this:config.show.partials = [:index_header, :thumbnail, :index]and some of the partials were provided by Blacklight, this may no longer work as the partials have been replaced by theDocumentComponent(https://github.com/projectblacklight/blacklight/blob/main/app/components/blacklight/document_component.rb) You can replace theDocumentComponentby settingconfig.show.document_component = MyDocumentComponent. You could also copy the partials from the release-7.x branch into your local application. - If you override
app/views/catalog/_show_main_content.html.erb, please note that it has changed significantly. Notably, it now renders theDocumentComponentand no longer callsrender_document_partials - If you override
app/views/catalog/facet.html.erb, please note that it has changed significantly. Notably, it now renders theBlacklight::FacetComponentand no longer callsrender_facet_limit -
app/views/catalog/_constraints_element.html.erbis no longer present. Overriding it has no effect. - Explicitly pass the documents to the render_document_index method:
- Deprecation warning: https://github.com/projectblacklight/blacklight/pull/2530/files
Accumulate backwards breaking changes here so they can be turned into upgrade path steps in the document above
- "constraints" is what Blacklight calls the area above search results that tells you all the queries/limits/filters at play in your search, and lets you remove them individually. Sometimes called a kind of "breadcrumbs".
- Plugins often want to add elements to this "constraints" area.
- They have traditionally done this by over-riding helper methods either
render_constraintsorrender_constraints_filtersto callsuperand concatenate their own additional content. - Multiple different plugins can and have done this simultaneously without stepping on each others toes, each adding something to
super. - This will no longer work in Blacklight 8, those methods are not available for over-riding.
- Additionally, when a plugin wants to supply it's own "constraint", it has often traditionaly called the
render_constraint_elementhelper method, to say "render this constraint in whatever the application style is, even if it's been customized". That method is also no longer available.
- They have traditionally done this by over-riding helper methods either
- Examples:
- Upgrade Path:
- In BL 8 all the constraints are rendered by app/view/catalog/_constraints.html.erb That renders the following components:
-
Blacklight::ConstraintsComponentthis used to berender_constraints -
Blacklight::ConstraintLayoutComponentthis used to berender_constraints_element - We could override the view partial to render a new subclass of
Blacklight::ConstraintsComponent - Another possibility is to move the
ConstraintsComponentclass to a configuration variable and have the partial use that variable.
- Unlike "adding element to constraints" above, only one thing at a time can do this, there's only one "query" constraint. But plugins have sometimes done this, and so have local apps.
- By over-riding the
render_constraints_queryhelper method -- this is no longer available. - Examples:
- Upgrade Path:
- In BL 8 the constraints query is rendered by the query_constraint_component argument (default
Blacklight::ConstraintLayoutComponent), which is passed into the Blacklight::Constrains component: https://github.com/projectblacklight/blacklight/blob/fd33c74a378d164a571174fa0054c25b70ef09d1/app/components/blacklight/constraints_component.rb#L11 . To customize, provide a different component.
- In BL 8 the constraints query is rendered by the query_constraint_component argument (default
- A plugin or app may want to render search constraints on it's own new page.
- Previously, it could call the helper method
render_constraintsto render the constraints including any customizations added by plugins or local app, as above. - This is no longer available as a method.
- Examples:
- Upgrade Path: ??