hyrax 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +22 -0
  3. data/.dassie/Gemfile +10 -5
  4. data/.dassie/config/initializers/hyrax.rb +5 -0
  5. data/.dockerignore +3 -0
  6. data/.env +0 -1
  7. data/.rubocop.yml +4 -0
  8. data/CONTAINERS.md +1 -1
  9. data/Dockerfile +12 -6
  10. data/Gemfile +21 -27
  11. data/app/actors/hyrax/actors/base_actor.rb +1 -1
  12. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
  13. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  14. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
  15. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  16. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  17. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
  18. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  19. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
  20. data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
  21. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  22. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  23. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
  24. data/app/forms/hyrax/forms/collection_form.rb +7 -3
  25. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
  26. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  27. data/app/forms/hyrax/forms/permission.rb +23 -0
  28. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  29. data/app/forms/hyrax/forms/resource_form.rb +10 -17
  30. data/app/forms/hyrax/forms/work_form.rb +5 -2
  31. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  32. data/app/helpers/hyrax/collections_helper.rb +88 -2
  33. data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
  34. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  35. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  36. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  37. data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
  38. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  39. data/app/jobs/attach_files_to_work_job.rb +19 -10
  40. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  41. data/app/jobs/inherit_permissions_job.rb +9 -5
  42. data/app/models/admin_set.rb +6 -25
  43. data/app/models/concerns/hyrax/ability.rb +3 -1
  44. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  45. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  46. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
  47. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  48. data/app/models/concerns/hyrax/user.rb +9 -3
  49. data/app/models/hyrax/file_set.rb +6 -0
  50. data/app/models/hyrax/pcdm_collection.rb +1 -0
  51. data/app/models/hyrax/permission_template.rb +98 -12
  52. data/app/models/hyrax/virus_scanner.rb +27 -18
  53. data/app/models/sipity/agent.rb +1 -0
  54. data/app/models/sipity/entity.rb +30 -8
  55. data/app/models/sipity/workflow.rb +1 -0
  56. data/app/models/sipity.rb +42 -0
  57. data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
  58. data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
  59. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  60. data/app/presenters/hyrax/collection_presenter.rb +31 -6
  61. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  62. data/app/presenters/hyrax/file_usage.rb +3 -2
  63. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  64. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  65. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  66. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  67. data/app/presenters/hyrax/version_presenter.rb +3 -2
  68. data/app/presenters/hyrax/work_show_presenter.rb +25 -4
  69. data/app/presenters/hyrax/work_usage.rb +5 -3
  70. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  71. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  72. data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
  73. data/app/services/hyrax/admin_set_create_service.rb +3 -1
  74. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  75. data/app/services/hyrax/collections/collection_member_service.rb +112 -27
  76. data/app/services/hyrax/collections/migration_service.rb +4 -2
  77. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  78. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  79. data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
  80. data/app/services/hyrax/contextual_path.rb +23 -0
  81. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  82. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  83. data/app/services/hyrax/edit_permissions_service.rb +27 -20
  84. data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
  85. data/app/services/hyrax/multiple_membership_checker.rb +51 -31
  86. data/app/services/hyrax/resource_status.rb +7 -0
  87. data/app/services/hyrax/search_service.rb +4 -2
  88. data/app/services/hyrax/solr_query_builder_service.rb +29 -6
  89. data/app/services/hyrax/solr_query_service.rb +224 -0
  90. data/app/services/hyrax/solr_service.rb +8 -1
  91. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  92. data/app/services/hyrax/work_uploads_handler.rb +17 -2
  93. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  94. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  95. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  96. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  97. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  98. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  99. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  100. data/app/views/hyrax/base/_guts4form.html.erb +2 -2
  101. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  102. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  103. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
  104. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  105. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  106. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  107. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  108. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  109. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  110. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  111. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  112. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  113. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  114. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  115. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  116. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  117. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  118. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  119. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  120. data/bin/solrcloud-assign-configset.sh +8 -5
  121. data/bin/solrcloud-upload-configset.sh +4 -2
  122. data/chart/hyrax/Chart.yaml +3 -3
  123. data/chart/hyrax/README.md +47 -1
  124. data/chart/hyrax/templates/_helpers.tpl +1 -1
  125. data/chart/hyrax/templates/configmap-env.yaml +1 -3
  126. data/chart/hyrax/templates/deployment-worker.yaml +6 -3
  127. data/chart/hyrax/templates/deployment.yaml +8 -3
  128. data/chart/hyrax/values.yaml +12 -0
  129. data/config/brakeman.ignore +2 -2
  130. data/config/locales/hyrax.de.yml +1 -1
  131. data/config/locales/hyrax.en.yml +1 -1
  132. data/config/locales/hyrax.es.yml +1 -1
  133. data/config/locales/hyrax.fr.yml +1 -1
  134. data/config/locales/hyrax.it.yml +1 -1
  135. data/config/locales/hyrax.pt-BR.yml +1 -1
  136. data/config/locales/hyrax.zh.yml +1 -1
  137. data/docker-compose.yml +1 -0
  138. data/documentation/developing-your-hyrax-based-app.md +1 -1
  139. data/documentation/legacyREADME.md +1 -1
  140. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
  141. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  142. data/lib/hyrax/configuration.rb +8 -0
  143. data/lib/hyrax/engine.rb +1 -0
  144. data/lib/hyrax/errors.rb +2 -0
  145. data/lib/hyrax/specs/capybara.rb +3 -1
  146. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  147. data/lib/hyrax/transactions/container.rb +21 -0
  148. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  149. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  150. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  151. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  152. data/lib/hyrax/transactions/work_create.rb +2 -1
  153. data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
  154. data/lib/hyrax/version.rb +1 -1
  155. data/lib/hyrax.rb +9 -0
  156. data/lib/tasks/collection_type_global_id.rake +1 -1
  157. data/lib/tasks/regenerate_derivatives.rake +12 -0
  158. data/lib/wings/orm_converter.rb +18 -2
  159. data/lib/wings/setup.rb +1 -0
  160. data/lib/wings/valkyrie/storage.rb +56 -1
  161. data/template.rb +1 -1
  162. metadata +17 -2
@@ -18,7 +18,7 @@ module Hyrax
18
18
 
19
19
  self.model_class = ::Collection
20
20
 
21
- self.membership_service_class = Collections::CollectionMemberService
21
+ self.membership_service_class = Collections::CollectionMemberSearchService
22
22
 
23
23
  delegate :blacklight_config, to: Hyrax::CollectionsController
24
24
 
@@ -123,6 +123,11 @@ module Hyrax
123
123
  collection_member_service.available_member_subcollections.documents
124
124
  end
125
125
 
126
+ ##
127
+ # @deprecated this implementation requires an extra db round trip, had a
128
+ # buggy cacheing mechanism, and was largely duplicative of other code.
129
+ # all versions of this code are replaced by
130
+ # {CollectionsHelper#available_parent_collections_data}.
126
131
  def available_parent_collections(scope:)
127
132
  return @available_parents if @available_parents.present?
128
133
 
@@ -130,8 +135,7 @@ module Hyrax
130
135
  colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
131
136
  @available_parents = colls.map do |col|
132
137
  { "id" => col.id, "title_first" => col.title.first }
133
- end
134
- @available_parents.to_json
138
+ end.to_json
135
139
  end
136
140
 
137
141
  private
@@ -32,18 +32,40 @@ module Hyrax
32
32
 
33
33
  def save
34
34
  return false unless valid?
35
- persistence_service.persist_nested_collection_for(parent: parent, child: child)
35
+ persistence_service.persist_nested_collection_for(parent: parent, child: child, user: context.current_user)
36
36
  end
37
37
 
38
+ ##
39
+ # @deprecated this method is unused by hyrax, and is effectively a
40
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
41
+ # if you want to be sure to use nested indexing to generate this list,
42
+ # use the query service directly.
43
+ #
38
44
  # For the given parent, what are all of the available collections that
39
45
  # can be added as sub-collection of the parent.
40
46
  def available_child_collections
47
+ Deprecation.warn "#{self.class}#available_child_collections " \
48
+ "is deprecated. the helper of the same name or " \
49
+ "Hyrax::Collections::NestedCollectionQueryService " \
50
+ "instead."
51
+
41
52
  query_service.available_child_collections(parent: parent, scope: context)
42
53
  end
43
54
 
55
+ ##
56
+ # @deprecated this method is unused by hyrax, and is effectively a
57
+ # delegation to `Hyrax::Collections::NestedCollectionQueryService`.
58
+ # if you want to be sure to use nested indexing to generate this list,
59
+ # use the query service directly.
60
+ #
44
61
  # For the given child, what are all of the available collections to
45
62
  # which the child can be added as a sub-collection.
46
63
  def available_parent_collections
64
+ Deprecation.warn "#{self.class}#available_parent_collections " \
65
+ "is deprecated. the helper of the same name or " \
66
+ "Hyrax::Collections::NestedCollectionQueryService " \
67
+ "instead."
68
+
47
69
  query_service.available_parent_collections(child: child, scope: context)
48
70
  end
49
71
 
@@ -61,7 +83,7 @@ module Hyrax
61
83
 
62
84
  def remove
63
85
  if context.can? :edit, parent
64
- persistence_service.remove_nested_relationship_for(parent: parent, child: child)
86
+ persistence_service.remove_nested_relationship_for(parent: parent, child: child, user: context.current_user)
65
87
  else
66
88
  errors.add(:parent, :cannot_remove_relationship)
67
89
  false
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Forms
5
+ ##
6
+ # @api public
7
+ class FileSetForm < Hyrax::ChangeSet
8
+ include Hyrax::FormFields(:core_metadata)
9
+
10
+ class << self
11
+ ##
12
+ # @return [Array<Symbol>] list of required field names as symbols
13
+ def required_fields
14
+ definitions
15
+ .select { |_, definition| definition[:required] }
16
+ .keys.map(&:to_sym)
17
+ end
18
+ end
19
+
20
+ property :creator, required: true
21
+ property :license, required: true
22
+
23
+ property :based_near
24
+ property :contributor
25
+ property :date_created
26
+ property :description
27
+ property :identifier
28
+ property :keyword
29
+ property :language
30
+ property :publisher
31
+ property :related_url
32
+ property :subject
33
+
34
+ property :permissions, virtual: true
35
+ property :visibility, default: VisibilityIntention::PRIVATE
36
+
37
+ # virtual properties for embargo/lease;
38
+ property :embargo_release_date, virtual: true
39
+ property :visibility_after_embargo, virtual: true
40
+ property :visibility_during_embargo, virtual: true
41
+ property :lease_expiration_date, virtual: true
42
+ property :visibility_after_lease, virtual: true
43
+ property :visibility_during_lease, virtual: true
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Forms
4
+ ##
5
+ # Nested form for permissions.
6
+ #
7
+ # @note due to historical oddities with Hydra::AccessControls and Hydra
8
+ # Editor, Hyrax's views rely on `agent_name` and `access` as field
9
+ # names. we provide these as virtual fields and prepopulate these from
10
+ # `Hyrax::Permission`.
11
+ class Permission < Hyrax::ChangeSet
12
+ property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
13
+ property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
14
+
15
+ ##
16
+ # @note support a {#to_hash} method for compatibility with
17
+ # {Hydra::AccessControl::Permissions}
18
+ def to_hash
19
+ { name: agent_name, access: access }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -12,7 +12,13 @@ module Hyrax
12
12
  # @return [#to_s] the primary key of the associated admin_set or collection
13
13
  # def source_id (because you might come looking for this method)
14
14
  delegate :id, to: :source_model, prefix: :source
15
- delegate :reset_access_controls!, to: :source_model
15
+
16
+ ##
17
+ # @deprecated use PermissionTemplate#reset_access_controls instead.
18
+ def reset_access_controls!
19
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
20
+ source_model.reset_access_controls!
21
+ end
16
22
 
17
23
  # Stores which radio button under release "Varies" option is selected
18
24
  attr_accessor :release_varies
@@ -67,7 +73,7 @@ module Hyrax
67
73
  # Copy this access to the permissions of the Admin Set or Collection and to
68
74
  # the WorkflowResponsibilities of the active workflow if this is an Admin Set
69
75
  def update_access(remove_agent: false)
70
- reset_access_controls!
76
+ source_model.reset_access_controls!
71
77
  update_workflow_responsibilities(remove_agent: remove_agent) if source_model.is_a?(AdminSet)
72
78
  end
73
79
 
@@ -31,18 +31,6 @@ module Hyrax
31
31
  #
32
32
  # This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
33
33
  class ResourceForm < Hyrax::ChangeSet
34
- ##
35
- # Nested form for permissions.
36
- #
37
- # @note due to historical oddities with Hydra::AccessControls and Hydra
38
- # Editor, Hyrax's views rely on `agent_name` and `access` as field
39
- # names. we provide these as virtual fields and prepopulate these from
40
- # `Hyrax::Permission`.
41
- class Permission < Hyrax::ChangeSet
42
- property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
43
- property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
44
- end
45
-
46
34
  ##
47
35
  # @api private
48
36
  InWorksPopulator = lambda do |_options|
@@ -94,7 +82,7 @@ module Hyrax
94
82
  collection(:permissions,
95
83
  virtual: true,
96
84
  default: [],
97
- form: Permission,
85
+ form: Hyrax::Forms::Permission,
98
86
  populator: :permission_populator,
99
87
  prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
100
88
 
@@ -136,10 +124,15 @@ module Hyrax
136
124
  # @example
137
125
  # monograph = Monograph.new
138
126
  # change_set = Hyrax::Forms::ResourceForm.for(monograph)
139
- def for(work)
140
- "#{work.class}Form".constantize.new(work)
127
+ def for(resource)
128
+ "#{resource.class.name}Form".constantize.new(resource)
141
129
  rescue NameError => _err
142
- Hyrax::Forms::ResourceForm(work.class).new(work)
130
+ case resource
131
+ when Hyrax::FileSet
132
+ Hyrax::Forms::FileSetForm.new(resource)
133
+ else
134
+ Hyrax::Forms::ResourceForm(resource.class).new(resource)
135
+ end
143
136
  end
144
137
 
145
138
  ##
@@ -208,7 +201,7 @@ module Hyrax
208
201
 
209
202
  # https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
210
203
  def permission_populator(collection:, index:, **)
211
- Permission.new(collection[index])
204
+ Hyrax::Forms::Permission.new(collection[index])
212
205
  end
213
206
 
214
207
  def _form_field_definitions
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # rubocop:disable Metrics/ClassLength
3
2
  module Hyrax
4
3
  module Forms
5
4
  # @abstract
6
- class WorkForm
5
+ class WorkForm # rubocop:disable Metrics/ClassLength
7
6
  include HydraEditor::Form
8
7
  include HydraEditor::Form::Permissions
9
8
  attr_accessor :current_ability
@@ -176,6 +175,10 @@ module Hyrax
176
175
  based_near_attributes: [:id, :_destroy],
177
176
  member_of_collections_attributes: [:id, :_destroy],
178
177
  work_members_attributes: [:id, :_destroy]
178
+ },
179
+ {
180
+ file_set: [:visibility, :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
181
+ :visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :uploaded_file_id]
179
182
  }
180
183
  ]
181
184
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
- # View Helpers for Hydra Batch Edit functionality
2
+
3
3
  module Hyrax
4
+ ##
5
+ # View Helpers for Hydra Batch Edit functionality
4
6
  module BatchEditsHelper
5
7
  # Displays the delete button for batch editing
6
8
  def batch_delete
@@ -1,6 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- module CollectionsHelper
3
+ module CollectionsHelper # rubocop:disable Metrics/ModuleLength
4
+ ##
5
+ # @since 3.1.0
6
+ # @return [Array<SolrDocument>]
7
+ def available_child_collections(collection:)
8
+ Hyrax::Collections::NestedCollectionQueryService
9
+ .available_child_collections(parent: collection, scope: controller, limit_to_id: nil)
10
+ end
11
+
12
+ ##
13
+ # @since 3.1.0
14
+ #
15
+ # @note provides data for handleAddToCollection javascript
16
+ #
17
+ # @return [String] JSON document containing id/title pairs for eligible
18
+ # parent collections to be displayed in an "Add to Collection" dropdown
19
+ def available_parent_collections_data(collection:)
20
+ Hyrax::Collections::NestedCollectionQueryService
21
+ .available_parent_collections(child: collection, scope: controller, limit_to_id: nil)
22
+ .map do |result|
23
+ { "id" => result.id, "title_first" => result.title.first }
24
+ end.to_json
25
+ end
26
+
4
27
  ##
5
28
  # @since 3.0.0
6
29
  # @return [#to_s]
@@ -97,6 +120,69 @@ module Hyrax
97
120
  single_item_action_form_fields(form, document, 'remove')
98
121
  end
99
122
 
123
+ ##
124
+ # @param collection [Object]
125
+ def collection_type_label_for(collection:)
126
+ case collection
127
+ when Valkyrie::Resource
128
+ CollectionType
129
+ .find_by_gid!(collection.collection_type_gid)
130
+ .title
131
+ else
132
+ collection.collection_type.title
133
+ end
134
+ end
135
+
136
+ ##
137
+ # @param collection [Object]
138
+ #
139
+ # @return [Boolean]
140
+ def collection_brandable?(collection:)
141
+ case collection
142
+ when Valkyrie::Resource
143
+ CollectionType
144
+ .find_by_gid!(collection.collection_type_gid)
145
+ .brandable?
146
+ else
147
+ collection.try(:brandable?)
148
+ end
149
+ end
150
+
151
+ ##
152
+ # @param collection [Object]
153
+ #
154
+ # @return [Boolean]
155
+ def collection_discoverable?(collection:)
156
+ case collection
157
+ when Valkyrie::Resource
158
+ CollectionType
159
+ .find_by_gid!(collection.collection_type_gid)
160
+ .discoverable?
161
+ else
162
+ collection.try(:discoverable?)
163
+ end
164
+ end
165
+
166
+ ##
167
+ # @param collection [Object]
168
+ #
169
+ # @return [Boolean]
170
+ def collection_sharable?(collection:)
171
+ case collection
172
+ when Valkyrie::Resource
173
+ CollectionType
174
+ .find_by_gid!(collection.collection_type_gid)
175
+ .sharable?
176
+ else
177
+ collection.try(:sharable?)
178
+ end
179
+ end
180
+
181
+ ##
182
+ # @note this helper is primarily intended for use with blacklight facet
183
+ # fields. it assumes we index a `collection_type_gid` and the helper
184
+ # can be passed as as a `helper_method:` to `add_facet_field`.
185
+ #
100
186
  # @param collection_type_gid [String] The gid of the CollectionType to be looked up
101
187
  # @return [String] The CollectionType's title if found, else the gid
102
188
  def collection_type_label(collection_type_gid)
@@ -112,4 +198,4 @@ module Hyrax
112
198
  render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
113
199
  end
114
200
  end
115
- end
201
+ end # rubocop:enable Metrics/ModuleLength
@@ -12,7 +12,7 @@ module Hyrax
12
12
  def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
13
13
  field_pairs = field_pairs(user)
14
14
  field_pairs.merge!(where)
15
- count(Hyrax::SolrQueryBuilderService.construct_query(field_pairs))
15
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs).count
16
16
  rescue RSolr::Error::ConnectionRefused
17
17
  'n/a'
18
18
  end
@@ -20,7 +20,7 @@ module Hyrax
20
20
  # @param user [User]
21
21
  # @return [Integer] number of FileSets the user deposited
22
22
  def number_of_files(user = current_user)
23
- count(Hyrax::SolrQueryBuilderService.construct_query_for_model(::FileSet, field_pairs(user)))
23
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
24
24
  rescue RSolr::Error::ConnectionRefused
25
25
  'n/a'
26
26
  end
@@ -28,7 +28,7 @@ module Hyrax
28
28
  # @param user [User]
29
29
  # @return [Integer] number of Collections the user created
30
30
  def number_of_collections(user = current_user)
31
- count(Hyrax::SolrQueryBuilderService.construct_query_for_model(::Collection, field_pairs(user)))
31
+ Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
32
32
  rescue RSolr::Error::ConnectionRefused
33
33
  'n/a'
34
34
  end
@@ -38,9 +38,5 @@ module Hyrax
38
38
  def field_pairs(user)
39
39
  { DepositSearchBuilder.depositor_field => user.user_key }
40
40
  end
41
-
42
- def count(query)
43
- Hyrax::SolrService.count(query)
44
- end
45
41
  end
46
42
  end
@@ -1,5 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax::FileSetHelper
3
+ ##
4
+ # @todo inline the "workflow restriction" into the `can?(:download)` check.
5
+ #
6
+ # @param file_set [#id]
7
+ #
8
+ # @return [Boolean] whether to display the download link for the given file
9
+ # set
10
+ def display_media_download_link?(file_set:)
11
+ Hyrax.config.display_media_download_link? &&
12
+ can?(:download, file_set) &&
13
+ !workflow_restriction?(file_set.try(:parent))
14
+ end
15
+
3
16
  def parent_path(parent)
4
17
  if parent.is_a?(::Collection)
5
18
  main_app.collection_path(parent)
@@ -8,12 +21,19 @@ module Hyrax::FileSetHelper
8
21
  end
9
22
  end
10
23
 
11
- # REVIEW: Since this media display could theoretically work for
12
- # any object that inplements to_s and the Mime Type methos (image? audio? ...),
13
- # Should this really be in file_set or could it be in it's own helper class like media_helper?
24
+ ##
25
+ # @deprecated use render(media_display_partial(file_set), file_set: file_set)
26
+ # instead
27
+ #
28
+ # @param presenter [Object]
29
+ # @param locals [Hash{Symbol => Object}]
14
30
  def media_display(presenter, locals = {})
15
- render media_display_partial(presenter),
16
- locals.merge(file_set: presenter)
31
+ Deprecation.warn("the helper `media_display` renders a partial name " \
32
+ "provided by `media_display_partial`. Callers " \
33
+ "should render `media_display_partial(file_set) directly
34
+ instead.")
35
+
36
+ render(media_display_partial(presenter), locals.merge(file_set: presenter))
17
37
  end
18
38
 
19
39
  def media_display_partial(file_set)
@@ -32,5 +52,4 @@ module Hyrax::FileSetHelper
32
52
  'default'
33
53
  end
34
54
  end
35
- # rubocop:enable Metrics/MethodLength
36
55
  end