Skip to content

Commit

Permalink
Merge pull request #4582 from pulibrary/Blacklight8-upgrade-v2
Browse files Browse the repository at this point in the history
Blacklight upgrade to 8.6.1
  • Loading branch information
sandbergja authored Dec 30, 2024
2 parents b79cbcd + 1c35b03 commit 13ebc1c
Show file tree
Hide file tree
Showing 21 changed files with 161 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem 'alma'
gem 'babel-transpiler'
gem 'bcrypt_pbkdf'
# Blacklight
gem 'blacklight', '~> 7.38.0'
gem 'blacklight', '~> 8.7.0'
gem 'blacklight_dynamic_sitemap'
gem 'blacklight-hierarchy'
gem 'blacklight-marc', '~>8.1'
Expand Down
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ GEM
parser (>= 2.4)
smart_properties
bigdecimal (3.1.8)
blacklight (7.38.0)
deprecation
blacklight (8.7.0)
globalid
hashdiff
i18n (>= 1.7.0)
jbuilder (~> 2.7)
kaminari (>= 0.15)
ostruct (>= 0.3.2)
rails (>= 5.1, < 7.3)
view_component (>= 2.66, < 4)
rails (>= 6.1, < 9)
view_component (>= 2.74, < 4)
zeitwerk
blacklight-hierarchy (6.4.0)
blacklight (>= 7.18, < 9)
deprecation
Expand Down Expand Up @@ -218,7 +217,7 @@ GEM
libddwaf (~> 1.15.0.0.0)
msgpack
datadog-ruby_core_source (3.3.6)
date (3.4.0)
date (3.4.1)
deprecation (1.1.0)
activesupport
descendants_tracker (0.0.4)
Expand Down Expand Up @@ -334,8 +333,8 @@ GEM
i18n (1.14.6)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
io-console (0.7.2)
irb (1.14.1)
io-console (0.8.0)
irb (1.14.2)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jaro_winkler (1.6.0)
Expand Down Expand Up @@ -414,7 +413,7 @@ GEM
racc (~> 1.7)
net-http (0.5.0)
uri
net-imap (0.5.1)
net-imap (0.5.2)
date
net-protocol
net-ldap (0.19.0)
Expand Down Expand Up @@ -466,7 +465,8 @@ GEM
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
psych (5.2.0)
psych (5.2.1)
date
stringio
public_suffix (6.0.1)
puma (6.4.3)
Expand Down Expand Up @@ -526,7 +526,7 @@ GEM
rake (13.2.1)
rbs (2.8.4)
rbtree (0.4.6)
rdoc (6.8.1)
rdoc (6.9.1)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand All @@ -538,7 +538,7 @@ GEM
rainbow (>= 2.0, < 4.0)
rexml (~> 3.1)
regexp_parser (2.9.2)
reline (0.5.11)
reline (0.6.0)
io-console (~> 0.5)
request_store (1.7.0)
rack (>= 1.4)
Expand Down Expand Up @@ -684,7 +684,7 @@ GEM
thread_safe (0.3.6)
tilt (2.4.0)
timecop (0.9.10)
timeout (0.4.2)
timeout (0.4.3)
tins (1.37.0)
bigdecimal
sync
Expand Down Expand Up @@ -758,7 +758,7 @@ DEPENDENCIES
axe-core-rspec
babel-transpiler
bcrypt_pbkdf
blacklight (~> 7.38.0)
blacklight (~> 8.7.0)
blacklight-hierarchy
blacklight-marc (~> 8.1)
blacklight_dynamic_sitemap
Expand Down
8 changes: 8 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@
//
//= require ./custom_range_limit.js
//= require ./orangelight.js

// Wait for the modal to open
document.addEventListener('show.blacklight.blacklight-modal', function () {
// Wait for the form to be submitted successfully
$('.modal_form').on('ajax:success', function () {
Blacklight.Modal.hide();
});
});

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ class CatalogController < ApplicationController
config.add_email_field 'pub_created_display', label: 'Published/Created'
config.add_email_field 'format', label: 'Format'
config.add_email_field 'electronic_access_1display', label: 'Online access', presenter: Orangelight::ElectronicAccessPlainTextPresenter
config.add_email_field 'electronic_portfolio_s', label: 'Online access', presenter: Orangelight::ElectronicPortfolioPlainTextPresenter

# If there are more than this many search results, no spelling ("did you
# mean") suggestion is offered.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module Orangelight
# This class is responsible for presenting electonic access data from solr documents
# This class is responsible for presenting electronic access data from solr documents
# in a way suitable for plain text settings, like a plain text email
class ElectronicAccessPlainTextPresenter < Blacklight::FieldPresenter
def values
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
module Orangelight
# This class is responsible for presenting electronic portfolio data from solr documents
# in a way suitable for plain text settings, like a plain text email
class ElectronicPortfolioPlainTextPresenter < Blacklight::FieldPresenter
def values
super.map { |access_point| format_access_point(access_point) }
end

private

# :reek:DuplicateMethodCall
# :reek:UtilityFunction
def format_access_point(access_point)
portfolio = JSON.parse(access_point)
"\t#{portfolio['title']}: #{portfolio['url']}\n"
end
end
end
13 changes: 7 additions & 6 deletions app/views/catalog/_ask_a_question_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= render :partial=>'shared/flash_msg' %>
<%= simple_form_for(
form,
remote: true,
url: contact_question_path,
data: { blacklight_modal: 'trigger' },
html: {class: "modal_form"}
Expand All @@ -16,9 +17,9 @@
<%= f.input :context, as: :hidden %>
<%= f.input :title, as: :hidden %>
<%= f.input :feedback_desc, as: :hidden %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-question' %>
</div>
<% end %>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bl-dismiss="modal">Cancel</button>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-question' %>
</div>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/catalog/_report_biased_results_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<div class="modal-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>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-question' %>
</div>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/catalog/_report_harmful_language_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= render :partial=>'shared/flash_msg' %>
<%= simple_form_for(
form,
remote: true,
url: contact_report_harmful_language_path,
data: { blacklight_modal: 'trigger' },
html: { class: "modal_form" }
Expand Down Expand Up @@ -34,7 +35,7 @@
<%= f.input :feedback_desc, as: :hidden %>
</div>
<div class="modal-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>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-question' %>
</div>
<% end %>
12 changes: 6 additions & 6 deletions app/views/catalog/_suggest_correction_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%= render :partial=>'shared/flash_msg' %>
<%= simple_form_for(
form,
remote: true,
url: contact_suggestion_path,
data: { blacklight_modal: 'trigger' },
html: { class: "modal_form" }
Expand All @@ -18,10 +19,9 @@
<%= f.input :context, as: :hidden %>
<%= f.input :title, as: :hidden %>
<%= f.input :feedback_desc, as: :hidden %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bl-dismiss="modal">Cancel</button>
<%= f.submit "Send", class: "btn btn-primary", id: 'submit-suggestion' %>
</div>
<% end %>

</div>
<% end %>
</div>
4 changes: 2 additions & 2 deletions spec/components/index_document_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe IndexDocumentComponent, type: :component do
let(:blacklight_config) do
Blacklight::Configuration.new do |config|
config.track_search_session = false
config.track_search_session.storage = false
end
end
before do
Expand All @@ -16,7 +16,7 @@
end
subject do
document = SolrDocument.new(id: 'SCSB-1234')
presenter = Blacklight::DocumentPresenter.new(document, instance_double(ActionView::Base), blacklight_config)
presenter = Blacklight::DocumentPresenter.new(document, instance_double(ActionView::Base, action_name: 'show'), blacklight_config)
allow(presenter).to receive(:fields).and_return([])
allow(document).to receive(:export_as_openurl_ctx_kev).and_return 'ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.issn=1045-4438'
render_inline(described_class.new(document:, presenter:))
Expand Down
4 changes: 2 additions & 2 deletions spec/components/index_metadata_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def call
expect(render_inline(component).css('li').first.text.strip).to eq('Hello')
end
it 'renders multi-valued fields' do
expect(render_inline(component).search('./li/ul/li').length).to eq(2)
expect(render_inline(component).search('./li/ul/li').map(&:text).map(&:strip)).to eq(['Goodbye', 'Auf Wiedersehen'])
expect(render_inline(component).search('./li/ul/li/ul/li').length).to eq(2)
expect(render_inline(component).search('./li/ul/li/ul/li').map(&:text).map(&:strip)).to eq(['Goodbye', 'Auf Wiedersehen'])
end
context 'when the index field is configured to use a component' do
let(:blacklight_config) do
Expand Down
2 changes: 1 addition & 1 deletion spec/components/index_title_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
let(:blacklight_config) do
Blacklight::Configuration.new do |config|
config.track_search_session = false
config.track_search_session.storage = false
config.index.document_actions[:bookmark].partial = '/catalog/bookmark_control'
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/report_harmful_language_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
end

it 'gives an error when the email is invalid' do
pending 'see https://github.com/pulibrary/orangelight/issues/4655'
expect(page).to have_content 'Email is not a valid email address'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true
require 'rails_helper'

RSpec.describe Orangelight::ElectronicPortfolioPlainTextPresenter do
describe '#values' do
it 'is formatted nicely' do
document = SolrDocument.new({
electronic_portfolio_s: [
'{"desc":null,"title":"Full Text","url":"https://na05.alma.exlibrisgroup.com/view/uresolver/01PRI_INST/openurl?u.ignore_date_coverage=true&portfolio_pid=53827030770006421&Force_direct=true","start":null,"end":"latest"}',
'{"desc":null,"title":"Second Title","url":"https://example.com","start":null,"end":"latest"}'
]
})
field_config = Blacklight::Configuration::Field.new(label: 'Online access', field: 'electronic_portfolio_s')
# rubocop:disable RSpec/VerifiedDoubles
view_context = double('View context', should_render_field?: true)
# rubocop:enable RSpec/VerifiedDoubles
presenter = described_class.new(view_context, document, field_config)
expect(presenter.values[0]).to eq("\tFull Text: https://na05.alma.exlibrisgroup.com/view/uresolver/01PRI_INST/openurl?u.ignore_date_coverage=true&portfolio_pid=53827030770006421&Force_direct=true\n")
expect(presenter.values[1]).to eq("\tSecond Title: https://example.com\n")
end
end
end
19 changes: 19 additions & 0 deletions spec/system/ask_a_question_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@
expect(page).to have_text 'Your question has been submitted'
end
end
describe 'pressing the send button' do
before do
stub_libanswers_api
stub_holding_locations
visit '/catalog/99101035463506421'
scroll_to(:bottom) # needed when js: true
click_link 'Ask a Question'
fill_in 'ask_a_question_form_name', with: 'Agatha'
fill_in 'ask_a_question_form_email', with: '[email protected]'
fill_in 'ask_a_question_form_message', with: 'Murder on the Orient Express'
end
it 'closes the modal', js: true do
expect(page).to have_text('Ask a Question')
expect(page).to have_text('Message')
click_button 'Send'
expect(current_path).to eq '/catalog/99101035463506421'
expect(page).not_to have_text('Message')
end
end
end
16 changes: 16 additions & 0 deletions spec/system/report_harmful_language_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,20 @@
expect(page).to have_text 'Thank you for reporting problematic language in the Princeton University Library catalog'
end
end
describe 'pressing the send button' do
before do
stub_libanswers_api
stub_holding_locations
visit '/catalog/99105509673506421'
scroll_to(:bottom) # needed when js: true
click_link 'Report Harmful Language'
fill_in 'report_harmful_language_form_message', with: 'Please correct the harmful content of this record'
end
it 'closes the modal', js: true do
expect(page).to have_text('You are reporting the use of harmful language in this catalog record')
click_button 'Send'
expect(current_path).to eq '/catalog/99105509673506421'
expect(page).not_to have_text('You are reporting the use of harmful language in this catalog record')
end
end
end
Loading

0 comments on commit 13ebc1c

Please sign in to comment.