From 75ff9998f9558d3d6826147a4f12cd9c97822b34 Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Fri, 22 Sep 2023 13:48:39 -0700 Subject: [PATCH 1/2] Upgrade to Blacklight 8 --- Gemfile | 2 +- Gemfile.lock | 10 +- .../blacklight_modal_component.html.erb | 13 -- app/components/blacklight_modal_component.rb | 8 -- app/components/document_component.rb | 2 +- app/components/edit_modal_component.rb | 3 +- .../search/sidebar_component.html.erb | 6 + app/components/search/sidebar_component.rb | 11 ++ app/controllers/bulk_jobs_controller.rb | 2 +- app/controllers/catalog_controller.rb | 68 +++++----- app/controllers/manage_releases_controller.rb | 2 +- app/controllers/registrations_controller.rb | 5 - app/controllers/report_controller.rb | 2 +- app/controllers/workflows_controller.rb | 2 +- app/forms/apo_form.rb | 1 - app/helpers/argo_helper.rb | 11 ++ app/helpers/items_helper.rb | 11 -- app/javascript/application.js | 36 +++-- app/javascript/argo.js | 27 ++-- .../bulk_upload_jobs_controller.js | 2 +- app/javascript/controllers/tokens.js | 3 +- app/models/report.rb | 13 +- app/models/solr_document.rb | 124 +++++++++--------- .../bulk_jobs/_bulk_index_table.html.erb | 21 +-- app/views/bulk_jobs/show.html.erb | 2 +- app/views/bulk_jobs/status_help.html.erb | 44 +++---- app/views/catalog/_search_sidebar.html.erb | 5 - app/views/catalog/_show_main_content.html.erb | 28 ++++ app/views/catalog/facet.html.erb | 29 ++-- app/views/catalog/show.html.erb | 37 ------ app/views/files/index.html.erb | 30 +++-- app/views/items/file.html.erb | 10 +- app/views/metadata/descriptive.html.erb | 14 +- app/views/metadata/full_dc.html.erb | 34 ++--- app/views/metadata/full_dc_xml.html.erb | 10 +- app/views/shared/_modal.html.erb | 5 +- app/views/uploads/new.html.erb | 2 +- app/views/workflows/history.html.erb | 10 +- app/views/workflows/show.html.erb | 18 +-- package.json | 2 +- .../blacklight_modal_component_spec.rb | 17 --- spec/forms/apo_form_spec.rb | 2 +- spec/requests/registration_spec.rb | 2 +- spec/requests/view_full_dublin_core_spec.rb | 4 +- spec/requests/workflow_grid_spec.rb | 4 +- spec/views/items/file.html.erb_spec.rb | 2 +- spec/views/workflows/history.html.erb_spec.rb | 2 +- spec/views/workflows/show.html.erb_spec.rb | 2 +- yarn.lock | 20 +-- 49 files changed, 341 insertions(+), 379 deletions(-) delete mode 100644 app/components/blacklight_modal_component.html.erb delete mode 100644 app/components/blacklight_modal_component.rb create mode 100644 app/components/search/sidebar_component.html.erb create mode 100644 app/components/search/sidebar_component.rb delete mode 100644 app/views/catalog/_search_sidebar.html.erb create mode 100644 app/views/catalog/_show_main_content.html.erb delete mode 100644 app/views/catalog/show.html.erb delete mode 100644 spec/components/blacklight_modal_component_spec.rb diff --git a/Gemfile b/Gemfile index 70d968a5d..19c39802e 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ gem "view_component", "~> 2.74.1" # TODO: ?? Unpin when bug in 2.75.0 is fixed gem "zip_tricks" # Stanford related gems -gem "blacklight", "~> 7.25" +gem "blacklight", "~> 8.0" gem "blacklight-hierarchy", "~> 6.1" gem "dor-services-client", "~> 12.18" gem "dor-workflow-client", "~> 6.0" diff --git a/Gemfile.lock b/Gemfile.lock index 6da630d1a..2cdbb7c57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,16 +83,14 @@ GEM parser (>= 2.4) smart_properties bindex (0.8.1) - blacklight (7.33.1) - deprecation + blacklight (8.0.1) 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 @@ -633,7 +631,7 @@ PLATFORMS DEPENDENCIES barby - blacklight (~> 7.25) + blacklight (~> 8.0) blacklight-hierarchy (~> 6.1) bootsnap (>= 1.4.2) byebug diff --git a/app/components/blacklight_modal_component.html.erb b/app/components/blacklight_modal_component.html.erb deleted file mode 100644 index b2a68645a..000000000 --- a/app/components/blacklight_modal_component.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/app/components/blacklight_modal_component.rb b/app/components/blacklight_modal_component.rb deleted file mode 100644 index c74d359fd..000000000 --- a/app/components/blacklight_modal_component.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Designed to use bootstrap styles to fill within the Blacklight modal -class BlacklightModalComponent < ViewComponent::Base - renders_one :header - renders_one :body - renders_one :footer -end diff --git a/app/components/document_component.rb b/app/components/document_component.rb index e373ef4ce..b9ad75260 100644 --- a/app/components/document_component.rb +++ b/app/components/document_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class DocumentComponent < Blacklight::DocumentComponent - def initialize(document: nil, **kwargs) + def initialize(document: nil, document_counter: nil, **kwargs) super end diff --git a/app/components/edit_modal_component.rb b/app/components/edit_modal_component.rb index e75f4ec06..2e4ebb8f7 100644 --- a/app/components/edit_modal_component.rb +++ b/app/components/edit_modal_component.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true # This models the component that appears when you click one of the blue buttons to modify an object. -# It does not depend on the BlacklightModalComponent, which has a bunch of jquery javascript for -# doing the ajax. That javascript prevents us from showing errors after a form is submitted. +# It does not depend on the Blacklight::System::ModalComponent, which does not use Turbo. class EditModalComponent < ApplicationComponent renders_one :header renders_one :body diff --git a/app/components/search/sidebar_component.html.erb b/app/components/search/sidebar_component.html.erb new file mode 100644 index 000000000..7fa10a578 --- /dev/null +++ b/app/components/search/sidebar_component.html.erb @@ -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 %> diff --git a/app/components/search/sidebar_component.rb b/app/components/search/sidebar_component.rb new file mode 100644 index 000000000..fc9b26743 --- /dev/null +++ b/app/components/search/sidebar_component.rb @@ -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 diff --git a/app/controllers/bulk_jobs_controller.rb b/app/controllers/bulk_jobs_controller.rb index 53129a9e7..c230073b5 100644 --- a/app/controllers/bulk_jobs_controller.rb +++ b/app/controllers/bulk_jobs_controller.rb @@ -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. diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 726a269fc..db31ed705 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -2,8 +2,8 @@ class CatalogController < ApplicationController include Blacklight::Catalog - helper ArgoHelper include DateFacetConfigurations + include ArgoHelper before_action :limit_facets_on_home_page, only: [:index] @@ -15,8 +15,12 @@ class CatalogController < ApplicationController # https://github.com/projectblacklight/blacklight/issues/1324 and more recent issues in Aug 2021 with large solr queries being sent over GET config.http_method = :post - # Configure the SearchState to know that "druids_only", is part of the state we care about. - config.search_state_fields << :druids_only + # Configure the SearchState to know which params are part of the state we care about. + config.search_state_fields += %i[druids_only id commit registration apo_id + size item_id time apo description druids all raw access_location + controlled_digital_lending download_access view_access workflow_id csv_file + new_apo_id current_resource_type new_content_type new_resource_type + viewing_direction collection data tag to what who] # common helper method since search results and reports share most of this config BlacklightConfigHelper.add_common_default_solr_params_to_config! config @@ -26,6 +30,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 @@ -59,19 +65,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", @@ -95,7 +100,6 @@ class CatalogController < ApplicationController } } config.add_facet_field "released_to_searchworks", - component: true, query: { week: { label: "Last week", @@ -130,23 +134,20 @@ class CatalogController < ApplicationController limit: 9999, home: false - config.add_facet_field "metadata_source_ssim", label: "Metadata Source", home: false, - component: true + config.add_facet_field "metadata_source_ssim", label: "Metadata Source", home: false # common method since search results and reports all do the same configuration 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 "identifiers", label: "Identifiers", - component: true, query: { has_orcids: {label: "Has contributor ORCIDs", fq: "+contributor_orcids_ssim:*"}, has_doi: {label: "Has DOI", fq: "+doi_ssim:*"}, @@ -154,20 +155,19 @@ class CatalogController < ApplicationController } config.add_facet_field "empties", label: "Empty Fields", home: false, - component: true, query: { no_mods_typeOfResource_ssim: {label: "No MODS typeOfResource", fq: "-mods_typeOfResource_ssim:*"}, no_sw_format: {label: "No SW Resource Type", fq: "-sw_format_ssim:*"} } - 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 @@ -210,8 +210,8 @@ def index end def lazy_tag_facet - (response,) = search_service.search_results - facet_config = facet_configuration_for_field("exploded_tag_ssim") + response = search_service.search_results + 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" @@ -219,7 +219,7 @@ def lazy_tag_facet 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_lite(params[:id], structural: false) flash[:alert] = "Warning: this object cannot currently be represented in the Cocina model." if @cocina.instance_of?(NilModel) @@ -257,7 +257,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 diff --git a/app/controllers/manage_releases_controller.rb b/app/controllers/manage_releases_controller.rb index c0f06f1cd..20d9b1c56 100644 --- a/app/controllers/manage_releases_controller.rb +++ b/app/controllers/manage_releases_controller.rb @@ -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| diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index bb9fbe794..30fc0ddcf 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -114,11 +114,6 @@ def form_create def csv_create @registration_form = CsvRegistrationForm.new(nil) if @registration_form.validate(create_params) && @registration_form.save - # # strip the CSRF token, and the parameters that happened to be in the bulk job creation form - # # this can be removed when this is resolved: https://github.com/projectblacklight/blacklight/issues/2683 - # search_state_subset = search_state.to_h.except(:authenticity_token, :druids, :druids_only, :description) - # path_params = Blacklight::Parameters.sanitize(search_state_subset) - # redirect_to bulk_actions_path(path_params), status: :see_other, notice: success_message redirect_to bulk_actions_path, status: :see_other, notice: "Register druids job was successfully created." else prepopulate diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb index 1d5d3097a..25478be5c 100644 --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -73,7 +73,7 @@ def reset # This draws the full page that supports the workflow grid def workflow_grid - (@response, _deprecated_document_list) = search_service.search_results + @response = search_service.search_results return unless request.headers["X-Requester"] == "frontend" # This is triggered by javascript that refreshes the data every 10s diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb index 114f26e27..2876c151c 100644 --- a/app/controllers/workflows_controller.rb +++ b/app/controllers/workflows_controller.rb @@ -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 # !request.xhr? end format.xml { render xml: } end diff --git a/app/forms/apo_form.rb b/app/forms/apo_form.rb index 33d01e06c..b0cd371f9 100644 --- a/app/forms/apo_form.rb +++ b/app/forms/apo_form.rb @@ -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 diff --git a/app/helpers/argo_helper.rb b/app/helpers/argo_helper.rb index 2f0b599c7..a3d4d390f 100644 --- a/app/helpers/argo_helper.rb +++ b/app/helpers/argo_helper.rb @@ -2,9 +2,20 @@ # Overrides for Blacklight helpers module ArgoHelper + include Blacklight::DocumentHelperBehavior include BlacklightHelper include ValueHelper + def document_presenter(document) + super.tap do |presenter| + presenter.view_token = @verified_token_with_expiration if presenter.respond_to? :view_token + if presenter.respond_to? :cocina + presenter.cocina = @cocina + presenter.state_service = StateService.new(@cocina) + end + end + end + # This overrides a blacklight helper so that the page is full-width def container_classes return super if controller_name == "apo" diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index a246859de..f7ee38699 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -5,17 +5,6 @@ def stacks_url_full_size(druid, file_name) "#{Settings.stacks_file_url}/#{druid}/#{ERB::Util.url_encode(file_name)}" end - # Overriding blacklight so we can pass @cocina to the presenter - def document_presenter(document) - super.tap do |presenter| - presenter.view_token = @verified_token_with_expiration if presenter.respond_to? :view_token - if presenter.respond_to? :cocina - presenter.cocina = @cocina - presenter.state_service = StateService.new(@cocina) - end - end - end - def license_options [["none", ""]] + Constants::LICENSE_OPTIONS.map { |attributes| [attributes.fetch(:label), attributes.fetch(:uri)] } end diff --git a/app/javascript/application.js b/app/javascript/application.js index 808b18cff..6abc7d092 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,16 +1,32 @@ // Entry point for the build script in your package.json -import "jquery"; // Blacklight 7 needs jQuery. Remove when we upgrade to Blacklight 8? -import bootstrap from "bootstrap/dist/js/bootstrap"; -global.bootstrap = bootstrap; // Required for Blacklight 7 so it can manage the modals +import 'jquery' // Blacklight 7 needs jQuery. Remove when we upgrade to Blacklight 8? +import bootstrap from 'bootstrap/dist/js/bootstrap' +import Blacklight from 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight' -import "blacklight-frontend/app/assets/javascripts/blacklight/blacklight"; -import "./controllers"; +import './controllers' -import Argo from "./argo"; +import Argo from './argo' +import '@hotwired/turbo-rails' -document.addEventListener("turbo:load", async () => { +global.bootstrap = bootstrap + +// TODO: Figure out if the behavior we're altering in this patch is a bug in Blacklight's modal JS. +Blacklight.Modal.modalAjaxLinkClick = (e) => { + e.preventDefault() + const href = e.target.closest(`${Blacklight.Modal.triggerLinkSelector}, ${Blacklight.Modal.preserveLinkSelector}`).getAttribute('href') + fetch(href) + .then(response => { + if (!response.ok) { + throw new TypeError('Request failed') + } + return response.text() + }) + .then(data => Blacklight.Modal.receiveAjax(data)) + .catch(error => Blacklight.Modal.onFailure(error)) +} + +document.addEventListener('turbo:load', async () => { // Start argo after Turbo has been loaded - new Argo().initialize(); -}); -import "@hotwired/turbo-rails"; + new Argo().initialize() +}) diff --git a/app/javascript/argo.js b/app/javascript/argo.js index 0c9a22842..5974734f5 100644 --- a/app/javascript/argo.js +++ b/app/javascript/argo.js @@ -4,23 +4,16 @@ import ProjectAutocomplete from './modules/project_autocomplete' require('@github/time-elements') export default class Argo { - initialize() { - this.tagsAutocomplete() - this.projectAutocomplete() - this.blacklight() - } + initialize () { + this.tagsAutocomplete() + this.projectAutocomplete() + } - // Because blacklight doesn't yet support turbo, we need to manually initialize - // the features we care about. - blacklight() { - Blacklight.activate() - } + tagsAutocomplete () { + new TagsAutocomplete().initialize() + } - tagsAutocomplete() { - new TagsAutocomplete().initialize() - } - - projectAutocomplete() { - new ProjectAutocomplete().initialize() - } + projectAutocomplete () { + new ProjectAutocomplete().initialize() + } } diff --git a/app/javascript/controllers/bulk_upload_jobs_controller.js b/app/javascript/controllers/bulk_upload_jobs_controller.js index bc2c67899..e95b1d7ed 100644 --- a/app/javascript/controllers/bulk_upload_jobs_controller.js +++ b/app/javascript/controllers/bulk_upload_jobs_controller.js @@ -13,7 +13,7 @@ export default class extends Controller { // Replace the button every time the modal is open ensures there are no stale listeners. modalElement.querySelector('.modal-footer').innerHTML = ` - + ` modalElement.querySelector('#bulk-delete-confirm').addEventListener('click', () => formParent.submit()) } diff --git a/app/javascript/controllers/tokens.js b/app/javascript/controllers/tokens.js index 4da5a3e5d..0b93fa8e0 100644 --- a/app/javascript/controllers/tokens.js +++ b/app/javascript/controllers/tokens.js @@ -1,3 +1,4 @@ +import Blacklight from 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight' import { Controller } from '@hotwired/stimulus' export default class extends Controller { @@ -7,7 +8,7 @@ export default class extends Controller { fetch(this.data.get('url'), { method: 'POST', headers: { - 'X-CSRF-Token': Blacklight.csrfToken() // eslint-disable-line no-undef + 'X-CSRF-Token': Blacklight.SearchContext.csrfToken() } }).then(response => response.text()) .then(token => { diff --git a/app/models/report.rb b/app/models/report.rb index 34b61373f..11086ad5e 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -225,14 +225,14 @@ def initialize(params = {}, current_user: NullUser.new) REPORT_FIELDS end @params = params - (@response,) = search_results(@params) + @response = search_results(@params) @num_found = @response["response"]["numFound"].to_i end def druids(opts = {}) params[:page] = 1 params[:per_page] = ROWS_PER_PAGE - (@response,) = search_results(params) + @response = search_results(params) druids = [] until @response.documents.empty? report_data.each do |rec| @@ -249,7 +249,7 @@ def druids(opts = {}) end end params[:page] += 1 - (@response,) = search_results(params) + @response = search_results(params) end druids @@ -273,7 +273,7 @@ def to_csv yielder << CSV.generate_line(@fields.map { |field| record[field.fetch(:field)].to_s }, force_quotes: true) end @params[:page] += 1 - (@response,) = search_results(@params) + @response = search_results(@params) end end end @@ -293,11 +293,6 @@ def search_service(params) current_user:) end - # We can remove this when https://github.com/projectblacklight/blacklight/pull/2320 is merged into Blacklight - def search_service_class - Blacklight::SearchService - end - # @param [Array] docs # @param [Array] fields # @return [Array String)>] diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 452e83830..5d7c7752e 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -27,74 +27,68 @@ class SolrDocument FIELD_RELEASED_TO_SEARCHWORKS = :released_to_searchworks_dttsi FIELD_RELEASED_TO = :released_to_ssim - FIELD_TITLE = "sw_display_title_tesim" - FIELD_AUTHOR = "sw_author_tesim" - FIELD_LABEL = "obj_label_tesim" - FIELD_PLACE = "originInfo_place_placeTerm_tesim" - FIELD_PUBLISHER = "originInfo_publisher_tesim" - FIELD_MODS_CREATED_DATE = "originInfo_date_created_tesim" - FIELD_CURRENT_VERSION = "current_version_isi" - FIELD_STATUS = "status_ssi" - FIELD_ACCESS_RIGHTS = "rights_descriptions_ssim" - FIELD_DEFAULT_ACCESS_RIGHTS = "default_rights_descriptions_ssim" - FIELD_COPYRIGHT = "copyright_ssim" - FIELD_USE_STATEMENT = "use_statement_ssim" - FIELD_LICENSE = "use_license_machine_ssi" - FIELD_PROJECT_TAG = "project_tag_ssim" - FIELD_TAGS = "tag_ssim" - FIELD_SOURCE_ID = "source_id_ssim" - FIELD_BARCODE_ID = "barcode_id_ssim" - FIELD_WORKFLOW_ERRORS = "wf_error_ssim" - FIELD_CONSTITUENTS = "has_constituents_ssim" - - attribute :object_type, Blacklight::Types::String, FIELD_OBJECT_TYPE - attribute :content_type, Blacklight::Types::String, FIELD_CONTENT_TYPE - attribute :catkey, Blacklight::Types::String, FIELD_CATKEY_ID - attribute :folio_instance_hrid, Blacklight::Types::String, FIELD_FOLIO_INSTANCE_HRID - attribute :doi, Blacklight::Types::String, FIELD_DOI - attribute :orcids, Blacklight::Types::Array, FIELD_ORCIDS - attribute :current_version, Blacklight::Types::String, FIELD_CURRENT_VERSION - attribute :embargo_status, Blacklight::Types::String, FIELD_EMBARGO_STATUS - attribute :embargo_release_date, Blacklight::Types::Date, FIELD_EMBARGO_RELEASE_DATE - attribute :first_shelved_image, Blacklight::Types::String, :first_shelved_image_ss - - attribute :registered_date, Blacklight::Types::Date, FIELD_REGISTERED_DATE - attribute :accessioned_date, Blacklight::Types::Array, FIELD_LAST_ACCESSIONED_DATE - attribute :published_date, Blacklight::Types::Array, FIELD_LAST_PUBLISHED_DATE - attribute :submitted_date, Blacklight::Types::Array, FIELD_LAST_SUBMITTED_DATE - attribute :deposited_date, Blacklight::Types::Array, FIELD_LAST_DEPOSITED_DATE - 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 :released_to, Blacklight::Types::Array, FIELD_RELEASED_TO - - attribute :label, Blacklight::Types::String, FIELD_LABEL - attribute :sw_title, Blacklight::Types::Array, FIELD_TITLE - attribute :author, Blacklight::Types::String, FIELD_AUTHOR - attribute :place, Blacklight::Types::String, FIELD_PLACE - attribute :publisher, Blacklight::Types::String, FIELD_PUBLISHER - attribute :mods_created_date, Blacklight::Types::String, FIELD_MODS_CREATED_DATE - attribute :status, Blacklight::Types::String, FIELD_STATUS - attribute :access_rights, Blacklight::Types::Array, FIELD_ACCESS_RIGHTS - attribute :default_access_rights, Blacklight::Types::String, FIELD_DEFAULT_ACCESS_RIGHTS - attribute :copyright, Blacklight::Types::String, FIELD_COPYRIGHT - attribute :use_statement, Blacklight::Types::String, FIELD_USE_STATEMENT - attribute :license, Blacklight::Types::String, FIELD_LICENSE - attribute :project_tag, Blacklight::Types::String, FIELD_PROJECT_TAG - attribute :source_id, Blacklight::Types::String, FIELD_SOURCE_ID - attribute :barcode, Blacklight::Types::String, FIELD_BARCODE_ID - attribute :tags, Blacklight::Types::Array, FIELD_TAGS - attribute :constituents, Blacklight::Types::Array, FIELD_CONSTITUENTS + FIELD_TITLE = :sw_display_title_tesim + FIELD_AUTHOR = :sw_author_tesim + FIELD_LABEL = :obj_label_tesim + FIELD_PLACE = :originInfo_place_placeTerm_tesim + FIELD_PUBLISHER = :originInfo_publisher_tesim + FIELD_MODS_CREATED_DATE = :originInfo_date_created_tesim + FIELD_CURRENT_VERSION = :current_version_isi + FIELD_STATUS = :status_ssi + FIELD_ACCESS_RIGHTS = :rights_descriptions_ssim + FIELD_DEFAULT_ACCESS_RIGHTS = :default_rights_descriptions_ssim + FIELD_COPYRIGHT = :copyright_ssim + FIELD_USE_STATEMENT = :use_statement_ssim + FIELD_LICENSE = :use_license_machine_ssi + FIELD_PROJECT_TAG = :project_tag_ssim + FIELD_TAGS = :tag_ssim + FIELD_SOURCE_ID = :source_id_ssim + FIELD_BARCODE_ID = :barcode_id_ssim + FIELD_WORKFLOW_ERRORS = :wf_error_ssim + FIELD_CONSTITUENTS = :has_constituents_ssim + + attribute :object_type, :string, field: FIELD_OBJECT_TYPE + attribute :content_type, :string, field: FIELD_CONTENT_TYPE + attribute :catkey, :string, field: FIELD_CATKEY_ID + attribute :folio_instance_hrid, :string, field: FIELD_FOLIO_INSTANCE_HRID + attribute :doi, :string, field: FIELD_DOI + attribute :orcids, :array, field: FIELD_ORCIDS + attribute :current_version, :string, field: FIELD_CURRENT_VERSION + attribute :embargo_status, :string, field: FIELD_EMBARGO_STATUS + attribute :embargo_release_date, :date, field: FIELD_EMBARGO_RELEASE_DATE + attribute :first_shelved_image, :string, field: :first_shelved_image_ss + + attribute :registered_date, :date, field: FIELD_REGISTERED_DATE + attribute :accessioned_date, :array, field: FIELD_LAST_ACCESSIONED_DATE + attribute :published_date, :array, field: FIELD_LAST_PUBLISHED_DATE + attribute :submitted_date, :array, field: FIELD_LAST_SUBMITTED_DATE + attribute :deposited_date, :array, field: FIELD_LAST_DEPOSITED_DATE + attribute :modified_date, :array, field: FIELD_LAST_MODIFIED_DATE + attribute :created_date, :date, field: FIELD_CREATED_DATE + attribute :opened_date, :array, field: FIELD_LAST_OPENED_DATE + attribute :preservation_size, :value, field: FIELD_PRESERVATION_SIZE + attribute :released_to, :array, field: FIELD_RELEASED_TO + + attribute :label, :string, field: FIELD_LABEL + attribute :sw_title, :array, field: FIELD_TITLE + attribute :author, :string, field: FIELD_AUTHOR + attribute :place, :string, field: FIELD_PLACE + attribute :publisher, :string, field: FIELD_PUBLISHER + attribute :mods_created_date, :string, field: FIELD_MODS_CREATED_DATE + attribute :status, :string, field: FIELD_STATUS + attribute :access_rights, :array, field: FIELD_ACCESS_RIGHTS + attribute :default_access_rights, :string, field: FIELD_DEFAULT_ACCESS_RIGHTS + attribute :copyright, :string, field: FIELD_COPYRIGHT + attribute :use_statement, :string, field: FIELD_USE_STATEMENT + attribute :license, :string, field: FIELD_LICENSE + attribute :project_tag, :string, field: FIELD_PROJECT_TAG + attribute :source_id, :string, field: FIELD_SOURCE_ID + attribute :barcode, :string, field: FIELD_BARCODE_ID + attribute :tags, :array, field: FIELD_TAGS + attribute :constituents, :array, field: FIELD_CONSTITUENTS # self.unique_key = 'id' - # Email uses the semantic field mappings below to generate the body of an email. - SolrDocument.use_extension(Blacklight::Document::Email) - - # SMS uses the semantic field mappings below to generate the body of an SMS email. - SolrDocument.use_extension(Blacklight::Document::Sms) - # DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document # Semantic mappings of solr stored fields. Fields may be multi or # single valued. See Blacklight::Document::ExtendableClassMethods#field_semantics diff --git a/app/views/bulk_jobs/_bulk_index_table.html.erb b/app/views/bulk_jobs/_bulk_index_table.html.erb index 1d44cb027..270765fd4 100644 --- a/app/views/bulk_jobs/_bulk_index_table.html.erb +++ b/app/views/bulk_jobs/_bulk_index_table.html.erb @@ -1,7 +1,7 @@ - @@ -21,7 +21,7 @@ - <% if(job.key?('dir')) %> + <% if job.key?('dir') %> <% druid_and_time = job["dir"].split(%r{/}) %> @@ -43,17 +43,18 @@ <% end %>
WhenWhoFile NameNoteStatus <%= link_to status_help_apo_bulk_jobs_path, aria: {label: "Status information"}, + Status <%= link_to status_help_apo_bulk_jobs_path(@document.id), aria: {label: "Status information"}, data: {blacklight_modal: "trigger", ajax_modal_title: "Status Information"} do %> <% end %><%= job["argo.bulk_metadata.bulk_log_record_count"] %> <%= job["argo.bulk_metadata.bulk_log_druids_loaded"] %><%= link_to("Log", show_apo_bulk_jobs_path(druid_and_time[0], druid_and_time[1]), data: {blacklight_modal: "trigger", ajax_modal_title: "MODS Bulk Load Log"}) %> <%= link_to("XML", show_apo_bulk_jobs_path(druid_and_time[0], druid_and_time[1], format: :xml)) %>
- + diff --git a/app/views/bulk_jobs/show.html.erb b/app/views/bulk_jobs/show.html.erb index a4c804e62..5c009ba4c 100644 --- a/app/views/bulk_jobs/show.html.erb +++ b/app/views/bulk_jobs/show.html.erb @@ -63,7 +63,7 @@
- +
diff --git a/app/views/bulk_jobs/status_help.html.erb b/app/views/bulk_jobs/status_help.html.erb index bd951929c..01e71965b 100644 --- a/app/views/bulk_jobs/status_help.html.erb +++ b/app/views/bulk_jobs/status_help.html.erb @@ -1,25 +1,25 @@ -
- <%= render BlacklightModalComponent.new do |component| %> - <% component.header { "Status Help" } %> - <% component.body do %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "Status Help" } %> + <% component.with_body do %> + <% end %> -
+<% end %> diff --git a/app/views/catalog/_search_sidebar.html.erb b/app/views/catalog/_search_sidebar.html.erb deleted file mode 100644 index 0a1423c4f..000000000 --- a/app/views/catalog/_search_sidebar.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= render "facets" %> - -<% unless has_search_parameters? || params[:all] %> - <%= link_to "Show more facets", root_path(all: true), class: "btn btn-primary" %> -<% end %> diff --git a/app/views/catalog/_show_main_content.html.erb b/app/views/catalog/_show_main_content.html.erb new file mode 100644 index 000000000..e0466d9e9 --- /dev/null +++ b/app/views/catalog/_show_main_content.html.erb @@ -0,0 +1,28 @@ +<%# + We override this Blacklight partial for two reasons: + + 1. to force the document title of the catalog/show page to use an H1 element instead of the default H3 element (line 11); + 2. to inject the edit-modal dialog (lines 22-27) +%> + +<%= render blacklight_config.track_search_session.item_pagination_component.new(search_context: @search_context, search_session: search_session, current_document: @document) if blacklight_config.track_search_session.item_pagination_component %> +<% @page_title = t("blacklight.search.show.title", document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %> +<% content_for(:head) { render_link_rel_alternates } %> + +<% document_component = blacklight_config.view_config(:show).document_component -%> +<%= render document_component.new(document_component.collection_parameter => document_presenter(@document), :component => :div, :show => true, :title_component => :h1, :partials => blacklight_config.view_config(:show).partials) do |component| %> + <% component.with_title(as: "h1", classes: "", link_to_document: false, actions: false) %> + <% component.with_footer do %> + <% if @document.respond_to?(:export_as_openurl_ctx_kev) %> + + + <% end %> + <% end %> +<% end %> + + + + diff --git a/app/views/catalog/facet.html.erb b/app/views/catalog/facet.html.erb index d1b03f3cc..0b224148c 100644 --- a/app/views/catalog/facet.html.erb +++ b/app/views/catalog/facet.html.erb @@ -1,18 +1,23 @@ -
- <%= render "facet_pagination" %> -
-
- <%= 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? %> -
- <%= render_facet_limit(@display_facet, layout: false) %> + <%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_prefix do %> +
+ <%= render "facet_pagination" %>
<% end %> - <% component.footer do %> -
+ + <% component.with_title { facet_field_label(@facet.key) } %> + + <%= render "facet_index_navigation" if @facet.index_range && @display_facet.index? %> + +
+ <%= render Blacklight::FacetComponent.new(display_facet: @display_facet, + blacklight_config: blacklight_config, + layout: false) %> +
+ + <% component.with_footer do %> +
diff --git a/app/views/catalog/show.html.erb b/app/views/catalog/show.html.erb deleted file mode 100644 index ff0957a40..000000000 --- a/app/views/catalog/show.html.erb +++ /dev/null @@ -1,37 +0,0 @@ - - -<% @page_title = t("blacklight.search.show.title", document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %> -<% content_for(:head) { render_link_rel_alternates } %> -<%= render (blacklight_config.view_config(:show).document_component || Blacklight::DocumentComponent).new(presenter: document_presenter(@document), component: :div, title_component: :h1, show: true) do |component| %> - <% component.footer do %> - <% if @document.respond_to?(:export_as_openurl_ctx_kev) %> - - - <% end %> - <% end %> - <%# Use :body for complete backwards compatibility (overriding the component body markup), - but if the app explicitly opted-in to components, make the partials data available as :partials to ease migrations pain %> - <% component.public_send((blacklight_config.view_config(:show).document_component.blank? && blacklight_config.view_config(:show).partials.any?) ? :body : :partial) do %> -
- <%= render_document_partials @document, blacklight_config.view_config(:show).partials, component: component %> -
- <% end %> -<% end %> - - diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index c8ec17275..fc079bbcb 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,17 +1,19 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "File Availability" } %> - <% component.body do %> - <% if @file.administrative.shelve %> -

- Stacks: <%= link_to params[:file], stacks_url_full_size(params[:item_id], params[:id]) %> -

- <% end %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "File Availability" } %> + <% component.with_body do %> + <% end %> <% end %> diff --git a/app/views/items/file.html.erb b/app/views/items/file.html.erb index 0194980b7..4a291f0f3 100644 --- a/app/views/items/file.html.erb +++ b/app/views/items/file.html.erb @@ -1,4 +1,8 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "Files" } %> - <% component.body { render "file" } %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "Files" } %> + <% component.with_body do %> + + <% end %> <% end %> diff --git a/app/views/metadata/descriptive.html.erb b/app/views/metadata/descriptive.html.erb index a576bce01..ba618c04c 100644 --- a/app/views/metadata/descriptive.html.erb +++ b/app/views/metadata/descriptive.html.erb @@ -1,7 +1,9 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "View descriptive metadata" } %> - <% component.body do - render ModsDisplay::RecordComponent.new(record: @mods_display, - fields: [:title] + ModsDisplay::RecordComponent::DEFAULT_FIELDS - [:subTitle]) - end %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "View descriptive metadata" } %> + <% component.with_body do %> + + <% end %> <% end %> diff --git a/app/views/metadata/full_dc.html.erb b/app/views/metadata/full_dc.html.erb index 0823fa0b7..a7ef60d0e 100644 --- a/app/views/metadata/full_dc.html.erb +++ b/app/views/metadata/full_dc.html.erb @@ -1,19 +1,21 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "Dublin Core (derived from MODS)" } %> - <% component.body do %> - -
- +
diff --git a/app/views/workflows/history.html.erb b/app/views/workflows/history.html.erb index 3f1f2f557..b91c65fc4 100644 --- a/app/views/workflows/history.html.erb +++ b/app/views/workflows/history.html.erb @@ -1,4 +1,8 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "Workflow history" } %> - <% component.body { render "history" } %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "Workflow history" } %> + <% component.with_body do %> + + <% end %> <% end %> diff --git a/app/views/workflows/show.html.erb b/app/views/workflows/show.html.erb index 45174738e..da7eae61d 100644 --- a/app/views/workflows/show.html.erb +++ b/app/views/workflows/show.html.erb @@ -1,10 +1,12 @@ -<%= render BlacklightModalComponent.new do |component| %> - <% component.header { "Workflow view" } %> - <% component.body do %> - <% if params[:raw] %> - <%= @presenter.pretty_xml %> - <% else %> - <%= render "show" %> - <% end %> +<%= render Blacklight::System::ModalComponent.new do |component| %> + <% component.with_title { "Workflow view" } %> + <% component.with_body do %> + <% end %> <% end %> diff --git a/package.json b/package.json index 07fed7a4d..cf8a3cf5a 100644 --- a/package.json +++ b/package.json @@ -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.1", "blacklight-hierarchy": "^6.0.2", "bootstrap": "^5.1.0", "esbuild": "^0.12.28", diff --git a/spec/components/blacklight_modal_component_spec.rb b/spec/components/blacklight_modal_component_spec.rb deleted file mode 100644 index b0d477b15..000000000 --- a/spec/components/blacklight_modal_component_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -RSpec.describe BlacklightModalComponent, type: :component do - it "renders the bootstrap modal" do - render_inline(described_class.new) do |component| - component.header { "header" } - component.body { "body" } - component.footer { "footer" } - end - expect(page).to have_css(".btn-close") - expect(page).to have_content("header") - expect(page).to have_content("body") - expect(page).to have_content("footer") - end -end diff --git a/spec/forms/apo_form_spec.rb b/spec/forms/apo_form_spec.rb index 6eced1f2a..71e15d12f 100644 --- a/spec/forms/apo_form_spec.rb +++ b/spec/forms/apo_form_spec.rb @@ -307,7 +307,7 @@ instance_double(SolrDocument, label:) end end - let(:search_service_result) { [nil, default_collection_objects] } + let(:search_service_result) { default_collection_objects } let(:search_service) { instance_double(Blacklight::SearchService) } before do diff --git a/spec/requests/registration_spec.rb b/spec/requests/registration_spec.rb index bdd1517d8..b0d700893 100644 --- a/spec/requests/registration_spec.rb +++ b/spec/requests/registration_spec.rb @@ -119,7 +119,7 @@ end let(:solr_doc) do { - "sw_display_title_tesim" => [ + sw_display_title_tesim: [ "Annual report of the State Corporation Commission showing the condition " \ "of the incorporated state banks and other institutions operating in " \ "Virginia at the close of business" diff --git a/spec/requests/view_full_dublin_core_spec.rb b/spec/requests/view_full_dublin_core_spec.rb index 65e3764ca..a28b50373 100644 --- a/spec/requests/view_full_dublin_core_spec.rb +++ b/spec/requests/view_full_dublin_core_spec.rb @@ -22,7 +22,7 @@ expect(response).to be_successful rendered = Capybara::Node::Simple.new(response.body) expect(rendered) - .to have_css ".modal-header h3.modal-title", text: "Dublin Core (derived from MODS)" + .to have_css ".modal-header h1.modal-title", text: "Dublin Core (derived from MODS)" expect(rendered).to have_css ".modal-body", text: "Kurdish Democratic Party" end end @@ -33,7 +33,7 @@ expect(response).to be_successful rendered = Capybara::Node::Simple.new(response.body) expect(rendered) - .to have_css ".modal-header h3.modal-title", text: "Dublin Core (derived from MODS)" + .to have_css ".modal-header h1.modal-title", text: "Dublin Core (derived from MODS)" expect(rendered).to have_css ".modal-body", text: "Kurdish Democratic Party" end end diff --git a/spec/requests/workflow_grid_spec.rb b/spec/requests/workflow_grid_spec.rb index 2acca7731..65ec2b5bc 100644 --- a/spec/requests/workflow_grid_spec.rb +++ b/spec/requests/workflow_grid_spec.rb @@ -7,8 +7,8 @@ Capybara::Node::Simple.new(response.body) end let(:user) { create(:user) } - let(:service) { instance_double(Blacklight::SearchService, search_results: [results, nil]) } - let(:results) { Blacklight::Solr::Response.new(solr_response, nil, {}) } + let(:service) { instance_double(Blacklight::SearchService, search_results:) } + let(:search_results) { Blacklight::Solr::Response.new(solr_response, nil, blacklight_config: Blacklight::Configuration.new) } let(:solr_response) do { "response" => {"docs" => []}, diff --git a/spec/views/items/file.html.erb_spec.rb b/spec/views/items/file.html.erb_spec.rb index bdaa45afa..dc2238c58 100644 --- a/spec/views/items/file.html.erb_spec.rb +++ b/spec/views/items/file.html.erb_spec.rb @@ -6,7 +6,7 @@ it "renders the template" do stub_template "items/_file.html.erb" => "stubbed_file" render - expect(rendered).to have_css ".modal-header h3.modal-title", text: "Files" + expect(rendered).to have_css ".modal-header h1.modal-title", text: "Files" expect(rendered).to have_css ".modal-body", text: "stubbed_file" end end diff --git a/spec/views/workflows/history.html.erb_spec.rb b/spec/views/workflows/history.html.erb_spec.rb index 4e83e31c0..6147b1615 100644 --- a/spec/views/workflows/history.html.erb_spec.rb +++ b/spec/views/workflows/history.html.erb_spec.rb @@ -6,7 +6,7 @@ it "renders the HS template" do stub_template "workflows/_history.html.erb" => "stubbed_wf_history_view" render - expect(rendered).to have_css ".modal-header h3.modal-title", text: "Workflow history" + expect(rendered).to have_css ".modal-header h1.modal-title", text: "Workflow history" expect(rendered).to have_css ".modal-body", text: "stubbed_wf_history_view" end end diff --git a/spec/views/workflows/show.html.erb_spec.rb b/spec/views/workflows/show.html.erb_spec.rb index 7ee81e66d..c1e7caf46 100644 --- a/spec/views/workflows/show.html.erb_spec.rb +++ b/spec/views/workflows/show.html.erb_spec.rb @@ -7,7 +7,7 @@ stub_template "workflows/_show.html.erb" => "stubbed_workflow_view" render expect(rendered) - .to have_css ".modal-header h3.modal-title", text: "Workflow view" + .to have_css ".modal-header h1.modal-title", text: "Workflow view" expect(rendered).to have_css ".modal-body", text: "stubbed_workflow_view" end end diff --git a/yarn.lock b/yarn.lock index c294daa4e..a885500ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -270,22 +270,13 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -"blacklight-frontend@>=7.1 || 8.0": +"blacklight-frontend@>=7.1 || 8.0", blacklight-frontend@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/blacklight-frontend/-/blacklight-frontend-8.0.1.tgz#20c923ea45e0d9c774ad3d23ef0bed2e31a12c71" integrity sha512-KVQ4txligEJb3RZx4LpGEx/YDWRWgSDP7xdJOzudFLFwZ8eJAwbwc7L5ErXvuNwdSz0o6v5vf6IIr66Hpbg5TA== dependencies: bootstrap ">=4.3.1 <6.0.0" -blacklight-frontend@^7.20.2: - version "7.33.1" - resolved "https://registry.yarnpkg.com/blacklight-frontend/-/blacklight-frontend-7.33.1.tgz#fd1728f7635b2fccd9be8623d56432f576abcc30" - integrity sha512-lYEg5Rr9QfcBwMdyAhnr8yFx86mSPp77oSRB4DpgXWyk4njfAhllkWNQOqodfk0IRMqsOBV0odTAYOcjUXNOFg== - dependencies: - bootstrap ">=4.3.1 <6.0.0" - jquery "^3.5.1" - typeahead.js "^0.11.1" - blacklight-hierarchy@^6.0.2: version "6.1.2" resolved "https://registry.yarnpkg.com/blacklight-hierarchy/-/blacklight-hierarchy-6.1.2.tgz#55d12c167268345b4e7412d38314c51e0a1204eb" @@ -1252,7 +1243,7 @@ iterator.prototype@^1.1.2: reflect.getprototypeof "^1.0.4" set-function-name "^2.0.1" -jquery@>=1.7, jquery@>=3.0, jquery@^3.5.1: +jquery@>=3.0: version "3.7.1" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de" integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg== @@ -1922,13 +1913,6 @@ type-fest@^0.3.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1" integrity sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ== -typeahead.js@^0.11.1: - version "0.11.1" - resolved "https://registry.yarnpkg.com/typeahead.js/-/typeahead.js-0.11.1.tgz#4e64e671b22310a8606f4aec805924ba84b015b8" - integrity sha512-yGaLzGjVHyryZdNfrWz2NHXUwEO7hrlVmGMGCo5+6mH3nEEhcQ0Te3mK3G60uRnxfERu8twOWSU4WmwScbwhMg== - dependencies: - jquery ">=1.7" - typed-array-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" From eeb743e8e9dcd84688d1232c9daaec5ecbeffae2 Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Mon, 25 Sep 2023 14:06:30 -0700 Subject: [PATCH 2/2] Remove jquery entirely --- app/javascript/application.js | 1 - app/javascript/jquery-shim.js | 4 ---- package.json | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 app/javascript/jquery-shim.js diff --git a/app/javascript/application.js b/app/javascript/application.js index 6abc7d092..c6d07223b 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,6 +1,5 @@ // Entry point for the build script in your package.json -import 'jquery' // Blacklight 7 needs jQuery. Remove when we upgrade to Blacklight 8? import bootstrap from 'bootstrap/dist/js/bootstrap' import Blacklight from 'blacklight-frontend/app/assets/javascripts/blacklight/blacklight' diff --git a/app/javascript/jquery-shim.js b/app/javascript/jquery-shim.js deleted file mode 100644 index ad2d6a3cf..000000000 --- a/app/javascript/jquery-shim.js +++ /dev/null @@ -1,4 +0,0 @@ -import jquery from 'jquery' - -window.jQuery = jquery // for jquery-ui -window.$ = jquery; \ No newline at end of file diff --git a/package.json b/package.json index cf8a3cf5a..cc65153d2 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "license": "Apache-2.0", "scripts": { - "build": "esbuild app/javascript/*.* --bundle --inject:app/javascript/jquery-shim.js --define:global=window --outdir=app/assets/builds", + "build": "esbuild app/javascript/*.* --bundle --define:global=window --outdir=app/assets/builds", "build:css": "sass ./app/assets/stylesheets/application.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules", "lint": "standard app/javascript/**/*.js", "lint_fix": "standard --fix app/javascript/**/*.js"