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

[HOLD] Upgrade to blacklight 8.0 #2857

Open
wants to merge 14 commits into
base: main
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ gem "zip_tricks", "5.3.1" # 5.3.1 is required as 5.4+ breaks the download all fe
gem "openapi_parser", "< 1.0"

# Stanford related gems
gem "blacklight", "~> 7.25"
gem "blacklight", "~> 8.0"
gem "blacklight-hierarchy", "~> 6.1"
gem "dor-services-client", "~> 12.5"
gem "dor-workflow-client", "~> 4.0"
Expand Down
10 changes: 4 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ GEM
parser (>= 2.4)
smart_properties
bindex (0.8.1)
blacklight (7.33.1)
deprecation
blacklight (8.0.0)
globalid
hashdiff
i18n (>= 1.7.0)
jbuilder (~> 2.7)
kaminari (>= 0.15)
ostruct (>= 0.3.2)
rails (>= 5.1, < 7.1)
view_component (~> 2.66)
rails (>= 6.1, < 8)
view_component (>= 2.66, < 3.1)
blacklight-hierarchy (6.1.2)
blacklight (>= 7.18, < 9)
deprecation
Expand Down Expand Up @@ -613,7 +611,7 @@ PLATFORMS

DEPENDENCIES
barby
blacklight (~> 7.25)
blacklight (~> 8.0)
blacklight-hierarchy (~> 6.1)
bootsnap (>= 1.4.2)
byebug
Expand Down
4 changes: 2 additions & 2 deletions app/components/blacklight_modal_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="modal-header">
<h3 class="modal-title"><%= header %></h3>
<button type='button' class='btn-close' data-bs-dismiss='modal' aria-hidden='true'></button>
<button type='button' class='btn-close' data-bl-dismiss='modal' aria-hidden='true'></button>
</div>

<div class="modal-body">
Expand All @@ -9,5 +9,5 @@

<div class="modal-footer">
<%= footer %>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-secondary" data-bl-dismiss="modal">Cancel</button>
</div>
6 changes: 6 additions & 0 deletions app/components/search/sidebar_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<%= render Blacklight::Search::SidebarComponent.new(blacklight_config: blacklight_config,
response: response,
view_config: view_config) %>
<% unless helpers.has_search_parameters? || params[:all] %>
<%= link_to 'Show more facets', root_path(all: true), class: 'btn btn-primary' %>
<% end %>
11 changes: 11 additions & 0 deletions app/components/search/sidebar_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class Search::SidebarComponent < Blacklight::Component
def initialize(blacklight_config:, response:, view_config:)
@blacklight_config = blacklight_config
@response = response
@view_config = view_config
end

attr_reader :blacklight_config, :response, :view_config
end
2 changes: 1 addition & 1 deletion app/controllers/bulk_jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def self.local_prefixes
private

def find(id)
search_service.fetch(id).last
search_service.fetch(id)
end

# Given a DRUID, loads any metadata bulk upload information associated with that DRUID into a hash.
Expand Down
55 changes: 26 additions & 29 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class CatalogController < ApplicationController
# When we test with solr 6 we can have:
# config.document_solr_path = 'get'
config.index.document_presenter_class = ArgoIndexPresenter
config.index.sidebar_component = Search::SidebarComponent

config.show.document_presenter_class = ArgoShowPresenter

config.index.display_type_field = SolrDocument::FIELD_CONTENT_TYPE
Expand Down Expand Up @@ -59,19 +61,18 @@ class CatalogController < ApplicationController
config.add_facet_field "exploded_tag_ssim", label: "Tag", limit: 9999,
component: LazyTagFacetComponent,
unless: ->(controller, _config, _response) { controller.params[:no_tags] }
config.add_facet_field "objectType_ssim", label: "Object Type", component: true, limit: 10
config.add_facet_field SolrDocument::FIELD_CONTENT_TYPE, label: "Content Type", component: true, limit: 10
config.add_facet_field "content_file_mimetypes_ssim", label: "MIME Types", component: true, limit: 10, home: false
config.add_facet_field "content_file_roles_ssim", label: "File Role", component: true, limit: 10, home: false
config.add_facet_field "rights_descriptions_ssim", label: "Access Rights", component: true, limit: 1000, sort: "index", home: false
config.add_facet_field SolrDocument::FIELD_LICENSE, label: "License", component: true, limit: 10, home: false
config.add_facet_field SolrDocument::FIELD_COLLECTION_TITLE, label: "Collection", component: true, limit: 10, more_limit: 9999, sort: "index"
config.add_facet_field "nonhydrus_apo_title_ssim", label: "Admin Policy", component: true, limit: 10, more_limit: 9999, sort: "index"
config.add_facet_field "hydrus_apo_title_ssim", label: "Hydrus Admin Policy", component: true, limit: 10, more_limit: 9999, sort: "index", home: false
config.add_facet_field SolrDocument::FIELD_CURRENT_VERSION, label: "Version", component: true, limit: 10, home: false
config.add_facet_field "processing_status_text_ssi", label: "Processing Status", component: true, limit: 10, home: false
config.add_facet_field "objectType_ssim", label: "Object Type", limit: 10
config.add_facet_field SolrDocument::FIELD_CONTENT_TYPE, label: "Content Type", limit: 10
config.add_facet_field "content_file_mimetypes_ssim", label: "MIME Types", limit: 10, home: false
config.add_facet_field "content_file_roles_ssim", label: "File Role", limit: 10, home: false
config.add_facet_field "rights_descriptions_ssim", label: "Access Rights", limit: 1000, sort: "index", home: false
config.add_facet_field SolrDocument::FIELD_LICENSE, label: "License", limit: 10, home: false
config.add_facet_field SolrDocument::FIELD_COLLECTION_TITLE, label: "Collection", limit: 10, more_limit: 9999, sort: "index"
config.add_facet_field "nonhydrus_apo_title_ssim", label: "Admin Policy", limit: 10, more_limit: 9999, sort: "index"
config.add_facet_field "hydrus_apo_title_ssim", label: "Hydrus Admin Policy", limit: 10, more_limit: 9999, sort: "index", home: false
config.add_facet_field SolrDocument::FIELD_CURRENT_VERSION, label: "Version", limit: 10, home: false
config.add_facet_field "processing_status_text_ssi", label: "Processing Status", limit: 10, home: false
config.add_facet_field "released_to_earthworks",
component: true,
query: {
week: {
label: "Last week",
Expand All @@ -95,7 +96,6 @@ class CatalogController < ApplicationController
}
}
config.add_facet_field "released_to_searchworks",
component: true,
query: {
week: {
label: "Last week",
Expand Down Expand Up @@ -130,8 +130,7 @@ class CatalogController < ApplicationController
limit: 9999,
home: false

config.add_facet_field "metadata_source_ssi", label: "Metadata Source", home: false,
component: true
config.add_facet_field "metadata_source_ssi", label: "Metadata Source", home: false

if Settings.enabled_features.multivalued_metadata_sources
config.add_facet_field "metadata_source_ssim", label: "Metadata Source (Multi)", home: false,
Expand All @@ -142,16 +141,14 @@ class CatalogController < ApplicationController
add_common_date_facet_fields_to_config! config

config.add_facet_field SolrDocument::FIELD_CONSTITUENTS, label: "Virtual Objects", home: false,
component: true,
query: {
has_constituents: {label: "Virtual Objects", fq: "#{SolrDocument::FIELD_CONSTITUENTS}:*"}
}

# This will help us find records that need to be fixed before we can move to cocina.
config.add_facet_field "data_quality_ssim", label: "Data Quality", home: false, component: true
config.add_facet_field "data_quality_ssim", label: "Data Quality", home: false

config.add_facet_field "empties", label: "Empty Fields", home: false,
component: true,
query: {
no_source_id: {label: "No Source ID", fq: "-source_id_ssim:*"},
no_rights_characteristics: {label: "No Rights Characteristics", fq: "-rights_characteristics_ssim:*"},
Expand All @@ -173,14 +170,14 @@ class CatalogController < ApplicationController
no_use_statement: {label: "No Use & Reproduction Statement", fq: "-#{SolrDocument::FIELD_USE_STATEMENT}:*"}
}

config.add_facet_field "sw_format_ssim", label: "SW Resource Type", component: true, limit: 10, home: false
config.add_facet_field "sw_pub_date_facet_ssi", label: "SW Date", component: true, limit: 10, home: false
config.add_facet_field "topic_ssim", label: "SW Topic", component: true, limit: 10, home: false
config.add_facet_field "sw_subject_geographic_ssim", label: "SW Region", component: true, limit: 10, home: false
config.add_facet_field "sw_subject_temporal_ssim", label: "SW Era", component: true, limit: 10, home: false
config.add_facet_field "sw_genre_ssim", label: "SW Genre", component: true, limit: 10, home: false
config.add_facet_field "sw_language_ssim", label: "SW Language", component: true, limit: 10, home: false
config.add_facet_field "mods_typeOfResource_ssim", label: "MODS Resource Type", component: true, limit: 10, home: false
config.add_facet_field "sw_format_ssim", label: "SW Resource Type", limit: 10, home: false
config.add_facet_field "sw_pub_date_facet_ssi", label: "SW Date", limit: 10, home: false
config.add_facet_field "topic_ssim", label: "SW Topic", limit: 10, home: false
config.add_facet_field "sw_subject_geographic_ssim", label: "SW Region", limit: 10, home: false
config.add_facet_field "sw_subject_temporal_ssim", label: "SW Era", limit: 10, home: false
config.add_facet_field "sw_genre_ssim", label: "SW Genre", limit: 10, home: false
config.add_facet_field "sw_language_ssim", label: "SW Language", limit: 10, home: false
config.add_facet_field "mods_typeOfResource_ssim", label: "MODS Resource Type", limit: 10, home: false
# Adding the facet field allows it to be queried (e.g., from value_helper)
config.add_facet_field "is_governed_by_ssim", if: false
config.add_facet_field "is_member_of_collection_ssim", if: false
Expand Down Expand Up @@ -224,15 +221,15 @@ def index

def lazy_tag_facet
(response,) = search_service.search_results
facet_config = facet_configuration_for_field("exploded_tag_ssim")
facet_config = helpers.facet_configuration_for_field("exploded_tag_ssim")
display_facet = response.aggregations[facet_config.field]
@facet_field_presenter = facet_config.presenter.new(facet_config, display_facet, view_context)
render partial: "lazy_tag_facet"
end

def show
params[:id] = Druid.new(params[:id]).with_namespace
_deprecated_response, @document = search_service.fetch(params[:id])
@document = search_service.fetch(params[:id])

@cocina = Repository.find(params[:id])
flash[:alert] = "Warning: this object cannot currently be represented in the Cocina model." if @cocina.instance_of?(NilModel)
Expand Down Expand Up @@ -271,7 +268,7 @@ def limit_facets_on_home_page
end

# do not add the druids_only search param to the blacklight search history (used in bulk actions only)
def blacklisted_search_session_params
def nonpersisted_search_session_params
super << :druids_only
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manage_releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ManageReleasesController < ApplicationController
def show
cocina = Repository.find(params[:item_id])
authorize! :update, cocina
_, @document = search_service.fetch params[:item_id]
@document = search_service.fetch params[:item_id]
@bulk_action = BulkAction.new

respond_to do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def show
respond_to do |format|
format.html do
@presenter = build_show_presenter(workflow)
render "show", layout: !request.xhr?
render "show", layout: false
end
format.xml { render xml: }
end
Expand Down
1 change: 0 additions & 1 deletion app/forms/apo_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def default_collection_objects
@default_collection_objects ||=
@search_service
.fetch(default_collections, rows: default_collections.size)
.last
.sort_by do |solr_doc|
solr_doc.label.downcase
end
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'jquery'
import bootstrap from "bootstrap/dist/js/bootstrap"
global.bootstrap = bootstrap // Required for Blacklight 7 so it can manage the modals

import 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight'
import Blacklight from 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight'
import "./controllers"

import Argo from './argo'
Expand All @@ -15,4 +15,4 @@ document.addEventListener("turbo:load", async () => {
// Start argo after free-jqgrid has been loaded
new Argo().initialize()
})
import '@hotwired/turbo-rails'
import '@hotwired/turbo-rails'
7 changes: 0 additions & 7 deletions app/javascript/argo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ export default class Argo {
this.tagsAutocomplete()
this.projectAutocomplete()
this.report()
this.blacklight()
}

// Because blacklight doesn't yet support turbo, we need to manually initialize
// the features we care about.
blacklight() {
Blacklight.activate()
}

report() {
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/controllers/tokens.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller } from '@hotwired/stimulus'
import Blacklight from 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight'

export default class extends Controller {
static targets = [ "output", "result", "button" ]
Expand All @@ -7,7 +8,7 @@ export default class extends Controller {
fetch(this.data.get("url"), {
method: 'POST',
headers: {
"X-CSRF-Token": Blacklight.csrfToken(),
"X-CSRF-Token": Blacklight.Core.csrfToken(),
}
}).then(response => response.text())
.then(token => {
Expand Down
2 changes: 1 addition & 1 deletion app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SolrDocument
attribute :modified_date, Blacklight::Types::Array, FIELD_LAST_MODIFIED_DATE
attribute :created_date, Blacklight::Types::Date, FIELD_CREATED_DATE
attribute :opened_date, Blacklight::Types::Array, FIELD_LAST_OPENED_DATE
attribute :preservation_size, Blacklight::Types::String, FIELD_PRESERVATION_SIZE
attribute :preservation_size, :value, FIELD_PRESERVATION_SIZE
attribute :released_to, Blacklight::Types::Array, FIELD_RELEASED_TO

attribute :label, Blacklight::Types::String, FIELD_LABEL
Expand Down
4 changes: 2 additions & 2 deletions app/views/bulk_jobs/_bulk_index_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<% end %>
</table>

<div class="modal fade" id="confirm-delete-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<dialog class="modal" id="confirm-delete-modal">
<div class="modal-dialog">
<div class="modal-content">
<%= render BlacklightModalComponent.new do |component| %>
Expand All @@ -56,4 +56,4 @@
<% end %>
</div>
</div>
</div>
</dialog>
5 changes: 0 additions & 5 deletions app/views/catalog/_search_sidebar.html.erb

This file was deleted.

27 changes: 16 additions & 11 deletions app/views/catalog/facet.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<div class="facet-pagination top row justify-content-between">
<%= render 'facet_pagination' %>
</div>

<div data-controller="facet-filter">
<%= render BlacklightModalComponent.new do |component| %>
<% component.header { facet_field_label(@facet.key) } %>
<% component.body do %>
<%= render 'facet_index_navigation' if @facet.index_range && @display_facet.index? %>
<div data-facet-filter-target="list">
<%= render_facet_limit(@display_facet, layout: false) %>
<%= render Blacklight::System::ModalComponent.new do |component| %>
<% component.prefix do %>
<div class="facet-pagination top row justify-content-between">
<%= render 'facet_pagination' %>
</div>
<% end %>

<% component.title { facet_field_label(@facet.key) } %>

<%= render 'facet_index_navigation' if @facet.index_range && @display_facet.index? %>

<div class="facet-extended-list" data-facet-filter-target="list">
<%= render Blacklight::FacetComponent.new(display_facet: @display_facet,
blacklight_config: blacklight_config,
layout: false) %>
</div>

<% component.footer do %>
<div class="facet_pagination bottom row">
<div class="facet-pagination bottom row justify-content-between">
<div class="col-sm-4">
<input type="text" id="filterInput" data-action="keyup->facet-filter#filter" placeholder="Filter..." class="form-control form-control-sm">
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/catalog/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<% end %>
<% end %>

<div id="edit-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
<dialog id="edit-modal" class="modal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
</div>
</div>
</div>
</dialog>
5 changes: 2 additions & 3 deletions app/views/shared/_modal.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!-- the 'data-backdrop="static"' and 'data-keyboard="false"' attributes keep the modal from closing on clickaway or escape, respectively -->
<div id="blacklight-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<dialog id="blacklight-modal" class="modal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
</div>
</div>
</div>
</dialog>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@hotwired/turbo-rails": "^7.0.1",
"@popperjs/core": "^2.10.2",
"autocomplete.js": "^0.37.1",
"blacklight-frontend": "^7.20.2",
"blacklight-frontend": "^8.0.0-beta.5",
"blacklight-hierarchy": "^6.0.2",
"bootstrap": "^5.1.0",
"esbuild": "^0.12.28",
Expand Down
15 changes: 15 additions & 0 deletions spec/components/search/sidebar_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Search::SidebarComponent, type: :component do
pending "add some examples to (or delete) #{__FILE__}"

# it "renders something useful" do
# expect(
# render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html
# ).to include(
# "Hello, components!"
# )
# end
end
Loading