From 6bc3f19b2fb7f19b48a09e4ff783fa840f8f37ee Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Thu, 6 Apr 2023 13:42:05 -0700 Subject: [PATCH 01/30] add support for Rails 6, Hyrax 4, and Blacklight 7 this makes no attempt to ensure UI-layer support for BL7 and whatever bootstrap versions it requires (excepting whatever is tested by RSpec). the scope here is simply to make it *possible* for a Hyrax 4 application to install and use Bulkrax. --- Gemfile | 5 +++-- app/factories/bulkrax/object_factory.rb | 2 +- app/jobs/bulkrax/create_relationships_job.rb | 3 ++- app/services/bulkrax/remove_relationships_for_importer.rb | 3 ++- spec/test_app/app/controllers/application_controller.rb | 4 ++-- spec/test_app/config/application.rb | 1 - 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 30071446e..d8f99f28f 100644 --- a/Gemfile +++ b/Gemfile @@ -12,11 +12,11 @@ gemspec # Git. Remember to move these dependencies to your gemspec before releasing # your gem to rubygems.org. -gem 'blacklight', '~> 6.25.0' +gem 'blacklight' gem 'bootstrap-sass', '~> 3.4.1' gem 'coderay' gem 'factory_bot_rails' -gem 'hyrax', '>= 2.3' +gem 'hyrax', '>= 2.3', '< 4.999' gem 'oai' gem 'rsolr', '>= 1.0' gem 'rspec-rails' @@ -29,6 +29,7 @@ group :development, :test do gem 'pry-byebug' gem 'solargraph' gem 'solr_wrapper', '>= 0.3' + gem 'sqlite3', '~> 1.4' end group :lint do diff --git a/app/factories/bulkrax/object_factory.rb b/app/factories/bulkrax/object_factory.rb index dd5d37705..ca0ba791a 100644 --- a/app/factories/bulkrax/object_factory.rb +++ b/app/factories/bulkrax/object_factory.rb @@ -123,7 +123,7 @@ def search_by_identifier def create attrs = transform_attributes @object = klass.new - object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if object.respond_to?(:reindex_extent) + object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if defined?(Hyrax::Adapters::NestingIndexAdapter) && object.respond_to?(:reindex_extent) run_callbacks :save do run_callbacks :create do if klass == Collection diff --git a/app/jobs/bulkrax/create_relationships_job.rb b/app/jobs/bulkrax/create_relationships_job.rb index 6e9eb77b8..e6e0415cb 100644 --- a/app/jobs/bulkrax/create_relationships_job.rb +++ b/app/jobs/bulkrax/create_relationships_job.rb @@ -158,7 +158,8 @@ def process(relationship:, importer_run_id:, parent_record:, ability:) end def add_to_collection(child_record, parent_record) - parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) + parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if + defined?(Hyrax::Adapters::NestingIndexAdapter) child_record.member_of_collections << parent_record child_record.save! end diff --git a/app/services/bulkrax/remove_relationships_for_importer.rb b/app/services/bulkrax/remove_relationships_for_importer.rb index 784b5ed07..10fa92e40 100644 --- a/app/services/bulkrax/remove_relationships_for_importer.rb +++ b/app/services/bulkrax/remove_relationships_for_importer.rb @@ -63,7 +63,8 @@ def break_relationships! remove_relationships_from_work(obj) end - obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if defined?(Hyrax) + obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if + defined?(Hyrax::Adapters::NestingIndexAdapter) obj.save! end end diff --git a/spec/test_app/app/controllers/application_controller.rb b/spec/test_app/app/controllers/application_controller.rb index 354ff36df..62e308956 100644 --- a/spec/test_app/app/controllers/application_controller.rb +++ b/spec/test_app/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base include Blacklight::Controller include Hyrax::ThemedLayoutController with_themed_layout '1_column' - skip_after_action :discard_flash_if_xhr + skip_after_action :discard_flash_if_xhr if + Rails.version.split('.').first.to_i < 6 protect_from_forgery with: :exception - end diff --git a/spec/test_app/config/application.rb b/spec/test_app/config/application.rb index 16c5c5d6b..af0ed0959 100644 --- a/spec/test_app/config/application.rb +++ b/spec/test_app/config/application.rb @@ -19,7 +19,6 @@ module TestApp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.1 - config.active_record.sqlite3.represent_boolean_as_integer = true # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. From 74f1e76b951ff27b2367c8a6ed5b84dfabe70ec8 Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Mon, 24 Apr 2023 10:46:45 -0700 Subject: [PATCH 02/30] include current Hyrax CSS class and onclick in sidebar additions --- .../sidebar/_bulkrax_sidebar_additions.html.erb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb b/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb index e92a8c47b..0adfd539f 100644 --- a/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb +++ b/app/views/hyrax/dashboard/sidebar/_bulkrax_sidebar_additions.html.erb @@ -1,12 +1,20 @@ <% if current_ability.can_import_works? %> - <%= menu.nav_link(bulkrax.importers_path, - title: t('bulkrax.admin.sidebar.importers')) do %> + <%= menu.nav_link( + bulkrax.importers_path, + title: t('bulkrax.admin.sidebar.importers'), + class: "nav-link", + onclick: "dontChangeAccordion(event);") + ) do %> <%= t('bulkrax.admin.sidebar.importers') %> <% end %> <% end %> <% if current_ability.can_export_works? %> - <%= menu.nav_link(bulkrax.exporters_path, - title: t('bulkrax.admin.sidebar.exporters')) do %> + <%= menu.nav_link( + bulkrax.exporters_path, + title: t('bulkrax.admin.sidebar.exporters'), + class: "nav-link", + onclick: "dontChangeAccordion(event);") + ) do %> <%= t('bulkrax.admin.sidebar.exporters') %> <% end %> <% end %> From 6a165421dcbc12f86b14b4421af0755ad07e613a Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Mon, 15 May 2023 11:48:33 -0700 Subject: [PATCH 03/30] change `.hidden` css classes to `.d-none` --- app/assets/javascripts/bulkrax/exporters.js | 10 +++++----- app/views/bulkrax/exporters/_form.html.erb | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/bulkrax/exporters.js b/app/assets/javascripts/bulkrax/exporters.js index 829ceb47b..67944d41a 100644 --- a/app/assets/javascripts/bulkrax/exporters.js +++ b/app/assets/javascripts/bulkrax/exporters.js @@ -14,7 +14,7 @@ function hideUnhide(field) { } }; -function addRequired(selectedSource) { +function addRequired(selectedSource) { selectedSource.addClass('required').attr('required', 'required'); selectedSource.parent().addClass('required'); } @@ -26,14 +26,14 @@ function removeRequired(allSources) { // hide all export_source function hide(allSources) { - allSources.addClass('hidden'); - allSources.find('#exporter_export_source').addClass('hidden').attr('type', 'hidden'); + allSources.addClass('d-none'); + allSources.find('#exporter_export_source').addClass('.d-none').attr('type', 'd-none'); } // unhide selected export_source function unhideSelected(selectedSource) { - selectedSource.removeClass('hidden').removeAttr('type'); - selectedSource.parent().removeClass('hidden').removeAttr('type'); + selectedSource.removeClass('d-none').removeAttr('type'); + selectedSource.parent().removeClass('d-none').removeAttr('type'); }; // add the autocomplete javascript diff --git a/app/views/bulkrax/exporters/_form.html.erb b/app/views/bulkrax/exporters/_form.html.erb index 4e54215b2..df3af0b38 100644 --- a/app/views/bulkrax/exporters/_form.html.erb +++ b/app/views/bulkrax/exporters/_form.html.erb @@ -33,8 +33,8 @@ label: t('bulkrax.exporter.labels.importer'), required: true, prompt: 'Select from the list', - label_html: { class: 'importer export-source-option hidden' }, - input_html: { class: 'importer export-source-option hidden form-control' }, + label_html: { class: 'importer export-source-option d-none' }, + input_html: { class: 'importer export-source-option d-none form-control' }, collection: form.object.importers_list.sort %> <%= form.input :export_source_collection, @@ -42,9 +42,9 @@ label: t('bulkrax.exporter.labels.collection'), required: true, placeholder: @collection&.title&.first, - label_html: { class: 'collection export-source-option hidden' }, + label_html: { class: 'collection export-source-option d-none' }, input_html: { - class: 'collection export-source-option hidden form-control', + class: 'collection export-source-option d-none form-control', data: { 'autocomplete-url' => '/authorities/search/collections', 'autocomplete' => 'collection' @@ -56,8 +56,8 @@ label: t('bulkrax.exporter.labels.worktype'), required: true, prompt: 'Select from the list', - label_html: { class: 'worktype export-source-option hidden' }, - input_html: { class: 'worktype export-source-option hidden form-control' }, + label_html: { class: 'worktype export-source-option d-none' }, + input_html: { class: 'worktype export-source-option d-none form-control' }, collection: Bulkrax.curation_concerns.map { |cc| [cc.to_s, cc.to_s] } %> <%= form.input :limit, @@ -80,7 +80,7 @@ as: :boolean, label: t('bulkrax.exporter.labels.filter_by_date') %> -