diff --git a/app/controllers/hyrax/file_sets_controller.rb b/app/controllers/hyrax/file_sets_controller.rb index e7f1423666..31c63edaef 100644 --- a/app/controllers/hyrax/file_sets_controller.rb +++ b/app/controllers/hyrax/file_sets_controller.rb @@ -137,6 +137,7 @@ def parent(file_set: curation_concern) @parent ||= case file_set when Hyrax::FileSet + # TODO: Add Hyrax::FileSet#parent method Hyrax.query_service.find_parents(resource: file_set).first else file_set.parent diff --git a/app/controllers/hyrax/my/collections_controller.rb b/app/controllers/hyrax/my/collections_controller.rb index c1565485c2..787e09fd85 100644 --- a/app/controllers/hyrax/my/collections_controller.rb +++ b/app/controllers/hyrax/my/collections_controller.rb @@ -12,7 +12,7 @@ def self.configure_facets config.add_facet_field Hyrax.config.collection_type_index_field, helper_method: :collection_type_label, limit: 5, pivot: ['has_model_ssim', Hyrax.config.collection_type_index_field], - skip_item: ->(item) { item.value == Hyrax.config.collection_class.to_s }, + skip_item: ->(item) { Hyrax::ModelRegistry.collection_rdf_representations.include?(item.value) }, label: I18n.t('hyrax.dashboard.my.heading.collection_type') # This causes AdminSets to also be shown with the Collection Type label config.add_facet_field 'has_model_ssim', diff --git a/app/models/concerns/hyrax/ability.rb b/app/models/concerns/hyrax/ability.rb index da0408980c..b0cd0e1c7a 100644 --- a/app/models/concerns/hyrax/ability.rb +++ b/app/models/concerns/hyrax/ability.rb @@ -421,7 +421,7 @@ def user_is_depositor?(document_id) end def curation_concerns_models - [::FileSet, ::Hyrax::FileSet, Hyrax.config.collection_class] + Hyrax.config.curation_concerns + Hyrax::ModelRegistry.collection_classes + Hyrax::ModelRegistry.file_set_classes + Hyrax::ModelRegistry.work_classes end def can_review_submissions? diff --git a/app/models/concerns/hyrax/solr_document_behavior.rb b/app/models/concerns/hyrax/solr_document_behavior.rb index d77ad2a267..a39eaac2de 100644 --- a/app/models/concerns/hyrax/solr_document_behavior.rb +++ b/app/models/concerns/hyrax/solr_document_behavior.rb @@ -53,28 +53,25 @@ def to_model ## # @return [Boolean] def collection? - hydra_model == Hyrax.config.collection_class || - ("Collection".safe_constantize == hydra_model) + Hyrax::ModelRegistry.collection_classes.include?(hydra_model) end ## # @return [Boolean] def file_set? - hydra_model == Hyrax::FileSet || - ("::FileSet".safe_constantize == hydra_model) + Hyrax::ModelRegistry.file_set_classes.include?(hydra_model) end ## # @return [Boolean] def admin_set? - (hydra_model == Hyrax.config.admin_set_class) || - ("AdminSet".safe_constantize == hydra_model) + Hyrax::ModelRegistry.admin_set_classes.include?(hydra_model) end ## # @return [Boolean] def work? - Hyrax.config.curation_concerns.include? hydra_model + Hyrax::ModelRegistry.work_classes.include?(hydra_model) end # Method to return the model @@ -89,6 +86,7 @@ def depositor(default = '') end def creator + # TODO: should we replace "hydra_model == AdminSet" with by #admin_set? solr_term = hydra_model == AdminSet ? "creator_ssim" : "creator_tesim" fetch(solr_term, []) end diff --git a/app/presenters/hyrax/pcdm_member_presenter_factory.rb b/app/presenters/hyrax/pcdm_member_presenter_factory.rb index 3bcd8155ca..5a791121d3 100644 --- a/app/presenters/hyrax/pcdm_member_presenter_factory.rb +++ b/app/presenters/hyrax/pcdm_member_presenter_factory.rb @@ -97,7 +97,7 @@ def work_presenters # @return def presenter_for(document:, ability:) case document['has_model_ssim'].first - when Hyrax::FileSet.name, ::FileSet.name # ActiveFedora FileSet within a Valkyrie Resource + when Hyrax::ModelRegistry.file_set_rdf_representations Hyrax::FileSetPresenter.new(document, ability) else Hyrax::WorkShowPresenter.new(document, ability) diff --git a/app/search_builders/hyrax/exposed_models_relation.rb b/app/search_builders/hyrax/exposed_models_relation.rb index e9f3daa298..4b00eb204a 100644 --- a/app/search_builders/hyrax/exposed_models_relation.rb +++ b/app/search_builders/hyrax/exposed_models_relation.rb @@ -3,7 +3,7 @@ module Hyrax # A relation that scopes to all user visible models (e.g. works + collections + file sets) class ExposedModelsRelation < AbstractTypeRelation def allowable_types - (Hyrax.config.curation_concerns + [Hyrax.config.collection_class, ::Collection, ::FileSet]).uniq + Hyrax::ModelRegistry.work_classes + Hyrax::ModelRegistry.collection_classes + Hyrax::ModelRegistry.file_set_classes end end end diff --git a/app/services/hyrax/edit_permissions_service.rb b/app/services/hyrax/edit_permissions_service.rb index 3858bda285..3880d3387c 100644 --- a/app/services/hyrax/edit_permissions_service.rb +++ b/app/services/hyrax/edit_permissions_service.rb @@ -215,7 +215,7 @@ def object_unauthorized_collection_ids # @todo Refactor inner working of code as there's lots of branching logic with potential hidden assumptions. def qualifies_as_unauthorized_collection?(resource:) case resource - when AdminSet, Hyrax::AdministrativeSet + when Hyrax::ModelRegistry.admin_set_classes # Prior to this refactor, we looked at AdminSet only; However with the advent of the # Hyrax::AdministrativeSet, we need to test both cases. true diff --git a/app/services/hyrax/statistics/collections/over_time.rb b/app/services/hyrax/statistics/collections/over_time.rb index a6d4427663..a9e6ba0c2d 100644 --- a/app/services/hyrax/statistics/collections/over_time.rb +++ b/app/services/hyrax/statistics/collections/over_time.rb @@ -7,7 +7,7 @@ class OverTime < Statistics::OverTime def relation AbstractTypeRelation - .new(allowable_types: [Hyrax.config.collection_class]) + .new(allowable_types: Hyrax::ModelRegistry.collection_classes) end end end diff --git a/lib/hyrax/resource_sync/change_list_writer.rb b/lib/hyrax/resource_sync/change_list_writer.rb index 57e177efb9..187d4f95fe 100644 --- a/lib/hyrax/resource_sync/change_list_writer.rb +++ b/lib/hyrax/resource_sync/change_list_writer.rb @@ -62,7 +62,7 @@ def build_changes(xml) def build_resources(xml, doc_set) doc_set.each do |doc| model = doc.fetch('has_model_ssim', []).first.safe_constantize - if model.try(:collection?) || model == Hyrax.config.collection_class + if model.try(:collection?) || Hyrax::ModelRegistry.collection_classes.include?(model) build_resource(xml, doc, model, hyrax_routes) else build_resource(xml, doc, model, main_app_routes) diff --git a/lib/hyrax/resource_sync/resource_list_writer.rb b/lib/hyrax/resource_sync/resource_list_writer.rb index fd8c212c42..9be15d7656 100644 --- a/lib/hyrax/resource_sync/resource_list_writer.rb +++ b/lib/hyrax/resource_sync/resource_list_writer.rb @@ -32,7 +32,7 @@ def builder end end - def build_collections(xml, searcher: AbstractTypeRelation.new(allowable_types: [::Collection, Hyrax.config.collection_class])) + def build_collections(xml, searcher: AbstractTypeRelation.new(allowable_types: Hyrax::ModelRegistry.collection_classes)) searcher.search_in_batches(public_access) do |doc_set| build_resources(xml, doc_set, hyrax_routes) end diff --git a/spec/features/dashboard/collection_spec.rb b/spec/features/dashboard/collection_spec.rb index d1aae175a9..1b35a85bca 100644 --- a/spec/features/dashboard/collection_spec.rb +++ b/spec/features/dashboard/collection_spec.rb @@ -35,8 +35,9 @@ it "has page title, does not have tabs, lists only user's collections, and displays number of collections in the respository" do expect(page).to have_content 'Collections' expect(page).not_to have_link 'All Collections' + within('section.tabs-row') do - expect(page).not_to have_link 'Your Collections' + expect(page).to have_link 'Your Collections' end expect(page).to have_link(collection1.title.first) expect(page).to have_link(collection2.title.first)