hyrax 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +3 -0
  3. data/app/assets/javascripts/hyrax/editor/controlled_vocabulary.es6 +38 -5
  4. data/app/assets/stylesheets/hyrax/_file_upload.scss +6 -0
  5. data/app/assets/stylesheets/hyrax/controlled_vocabulary.scss +2 -2
  6. data/app/controllers/hyrax/file_sets_controller.rb +1 -1
  7. data/app/controllers/hyrax/single_use_links_viewer_controller.rb +9 -2
  8. data/app/models/collection.rb +13 -1
  9. data/app/models/hyrax/model_registry.rb +1 -1
  10. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
  11. data/app/presenters/hyrax/work_show_presenter.rb +2 -2
  12. data/app/services/hyrax/file_set_file_service.rb +10 -1
  13. data/app/services/hyrax/listeners/file_listener.rb +39 -0
  14. data/app/services/hyrax/listeners/file_metadata_listener.rb +0 -30
  15. data/app/services/hyrax/lock_manager.rb +2 -2
  16. data/app/services/hyrax/valkyrie_upload.rb +5 -2
  17. data/app/views/hyrax/uploads/_js_templates.html.erb +9 -9
  18. data/app/views/hyrax/uploads/_js_templates_branding.html.erb +3 -3
  19. data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +1 -1
  20. data/chart/hyrax/Chart.yaml +1 -1
  21. data/chart/hyrax/templates/deployment.yaml +12 -0
  22. data/chart/hyrax/values.yaml +10 -0
  23. data/documentation/developing-your-hyrax-based-app.md +4 -4
  24. data/hyrax.gemspec +2 -8
  25. data/lib/hyrax/publisher.rb +11 -0
  26. data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_work.rb +11 -0
  27. data/lib/hyrax/transactions/steps/delete_all_file_metadata.rb +4 -5
  28. data/lib/hyrax/version.rb +1 -1
  29. data/template.rb +1 -1
  30. metadata +44 -78
  31. data/spec/support/book_resource.rb +0 -36
  32. data/spec/support/can_can_overrides.rb +0 -43
  33. data/spec/support/clean_solr.rb +0 -7
  34. data/spec/support/controller_level_helpers.rb +0 -27
  35. data/spec/support/factory_helpers.rb +0 -94
  36. data/spec/support/fakes/fake_actor.rb +0 -22
  37. data/spec/support/fakes/fake_authority.rb +0 -14
  38. data/spec/support/fakes/fake_search_builder_scope.rb +0 -44
  39. data/spec/support/fakes/indexing_adapter.rb +0 -17
  40. data/spec/support/fakes/test_hydra_group_service.rb +0 -55
  41. data/spec/support/features/batch_edit_actions.rb +0 -37
  42. data/spec/support/features/session_helpers.rb +0 -15
  43. data/spec/support/features/workflow.rb +0 -10
  44. data/spec/support/features.rb +0 -11
  45. data/spec/support/form_with_validations.rb +0 -15
  46. data/spec/support/input_support.rb +0 -12
  47. data/spec/support/logging_formatter.rb +0 -67
  48. data/spec/support/matchers/api_responses.rb +0 -27
  49. data/spec/support/matchers/collection_type_property_matchers.rb +0 -30
  50. data/spec/support/matchers/embargo.rb +0 -9
  51. data/spec/support/matchers/lease.rb +0 -9
  52. data/spec/support/matchers/match_valkyrie_ids_with_af_ids.rb +0 -12
  53. data/spec/support/matchers/pcdm_matchers.rb +0 -34
  54. data/spec/support/matchers/permission.rb +0 -31
  55. data/spec/support/matchers/response_matchers.rb +0 -8
  56. data/spec/support/optional_example.rb +0 -17
  57. data/spec/support/rake.rb +0 -42
  58. data/spec/support/selectors.rb +0 -112
  59. data/spec/support/shared_examples_for_collection_presenter.rb +0 -44
  60. data/spec/support/simple_work.rb +0 -28
  61. data/spec/support/spec_statistic.rb +0 -24
  62. data/spec/support/speedup.rb +0 -7
  63. data/spec/support/statistic_helper.rb +0 -10
  64. data/spec/support/valkyrie_indexing.rb +0 -2
  65. data/spec/support/wings_models.rb +0 -9
  66. /data/{spec → lib/hyrax/specs/shared_specs}/factories/access_control.rb +0 -0
  67. /data/{spec → lib/hyrax/specs/shared_specs}/factories/admin_sets.rb +0 -0
  68. /data/{spec → lib/hyrax/specs/shared_specs}/factories/admin_sets_lw.rb +0 -0
  69. /data/{spec → lib/hyrax/specs/shared_specs}/factories/administrative_sets.rb +0 -0
  70. /data/{spec → lib/hyrax/specs/shared_specs}/factories/api_items.rb +0 -0
  71. /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_branding_infos.rb +0 -0
  72. /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_type_participants.rb +0 -0
  73. /data/{spec → lib/hyrax/specs/shared_specs}/factories/collection_types.rb +0 -0
  74. /data/{spec → lib/hyrax/specs/shared_specs}/factories/collections.rb +0 -0
  75. /data/{spec → lib/hyrax/specs/shared_specs}/factories/collections_factory.rb +0 -0
  76. /data/{spec → lib/hyrax/specs/shared_specs}/factories/content_blocks.rb +0 -0
  77. /data/{spec → lib/hyrax/specs/shared_specs}/factories/counter_metrics.rb +0 -0
  78. /data/{spec → lib/hyrax/specs/shared_specs}/factories/featured_works.rb +0 -0
  79. /data/{spec → lib/hyrax/specs/shared_specs}/factories/file_sets.rb +0 -0
  80. /data/{spec → lib/hyrax/specs/shared_specs}/factories/generic_works.rb +0 -0
  81. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_collection.rb +0 -0
  82. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_default_admin_set.rb +0 -0
  83. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_embargo.rb +0 -0
  84. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_file_metadata.rb +0 -0
  85. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_file_set.rb +0 -0
  86. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_lease.rb +0 -0
  87. /data/{spec → lib/hyrax/specs/shared_specs}/factories/hyrax_resource.rb +0 -0
  88. /data/{spec → lib/hyrax/specs/shared_specs}/factories/object_id.rb +0 -0
  89. /data/{spec → lib/hyrax/specs/shared_specs}/factories/operations.rb +0 -0
  90. /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission.rb +0 -0
  91. /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission_template_accesses.rb +0 -0
  92. /data/{spec → lib/hyrax/specs/shared_specs}/factories/permission_templates.rb +0 -0
  93. /data/{spec → lib/hyrax/specs/shared_specs}/factories/proxy_deposit_requests.rb +0 -0
  94. /data/{spec → lib/hyrax/specs/shared_specs}/factories/single_use_links.rb +0 -0
  95. /data/{spec → lib/hyrax/specs/shared_specs}/factories/sipity_entities.rb +0 -0
  96. /data/{spec → lib/hyrax/specs/shared_specs}/factories/uploaded_files.rb +0 -0
  97. /data/{spec → lib/hyrax/specs/shared_specs}/factories/users.rb +0 -0
  98. /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflow_actions.rb +0 -0
  99. /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflow_states.rb +0 -0
  100. /data/{spec → lib/hyrax/specs/shared_specs}/factories/workflows.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 238652072010e0112f31139f4a0fd08b8cfffa834d059fe6f1a09a785dbbb95b
4
- data.tar.gz: a5a9237eb4c0444181113ae4666131b592d29f210550ed967854995cea3b5ca0
3
+ metadata.gz: 791fb1a29523524e62036fd25aed45e6297d4d010e4b20bbcd9abe468bb30278
4
+ data.tar.gz: fbfdf5b3523294fe5dff601c92412967da57fdd02ac6c28d2384f18e8033cb4e
5
5
  SHA512:
6
- metadata.gz: 112a9cfd288216b3ac82b7393190a2a3d5d77fe174497854d19d91a3503391fc179d1b28c00d94e91dabd3aa86c6a2d62b8e12f91f7b852e0e36edcb629ec9de
7
- data.tar.gz: 67fabd5262783627bf3aaf6587240922db90aeede162e2c2bcc20b8312bbee4f1e84113b09fecb9636d411b7c2e09ee48bafe000d3fc73af7eb9eeec8e7e6623
6
+ metadata.gz: 98fbab4485f2bb977cfb0fe755a05a98f39a2ba6f575420bae41a70d5e361aae482d81da902203afc49aa9171decafa3d4b87d6d58c0ee05e14a9ff8221f545b
7
+ data.tar.gz: 8846f839b4040ce79e52738da5fe3585fa176041cc6805c8c124724c8db006d6fee2ff30e5d286bfc0ca76de1e10a331bf608c9f88109208b6bdffc2d90d3023
@@ -18,6 +18,9 @@ export default class LinkedData {
18
18
  let result = this.element.select2("data")
19
19
  this.element.select2("destroy")
20
20
  this.element.val(result.label).attr("readonly", "readonly")
21
+ // Adding d-block class to the remove button to show it after a selection is made.
22
+ let removeButton = this.element.closest('.field-wrapper').find('.input-group-btn.field-controls .remove')
23
+ removeButton.addClass('d-block')
21
24
  this.setIdentifier(result.id)
22
25
  }
23
26
 
@@ -31,6 +31,8 @@ export default class ControlledVocabulary extends FieldManager {
31
31
  this.paramKey = paramKey
32
32
  this.fieldName = this.element.data('fieldName')
33
33
  this.searchUrl = this.element.data('autocompleteUrl')
34
+ // Used to prevent index collisions for existing words when removing and adding back in values.
35
+ this.postRemovalAdjustment = 0
34
36
  }
35
37
 
36
38
  // Overrides FieldManager, because field manager uses the wrong selector
@@ -49,6 +51,15 @@ export default class ControlledVocabulary extends FieldManager {
49
51
  // this._manageFocus()
50
52
  // }
51
53
 
54
+ // Overrides FieldManager in order to display Remove button for values that exist at initial load time
55
+ _createRemoveControl() {
56
+ if (this.element.find('input.multi-text-field').val()) {
57
+ this.remover.addClass('d-block')
58
+ this.remover.addClass('has-existing-value')
59
+ }
60
+ $(this.fieldWrapperClass + ' .field-controls', this.element).append(this.remover)
61
+ }
62
+
52
63
  // Overrides FieldManager in order to avoid doing a clone of the existing field
53
64
  createNewField($activeField) {
54
65
  let $newField = this._newFieldTemplate()
@@ -68,20 +79,24 @@ export default class ControlledVocabulary extends FieldManager {
68
79
  }
69
80
 
70
81
  _newFieldTemplate() {
71
- let index = this._maxIndex()
82
+ let index = this._maxIndex() + this.postRemovalAdjustment
72
83
  let rowTemplate = this._template()
73
84
  let controls = this.controls.clone()//.append(this.remover)
74
85
  let row = $(rowTemplate({ "paramKey": this.paramKey,
75
86
  "name": this.fieldName,
76
87
  "index": index,
77
- "class": "controlled_vocabulary" }))
88
+ "class": "controlled_vocabulary",
89
+ "placeholder": "Search for a location..." }))
78
90
  .append(controls)
91
+ let removeButton = row.find('.remove');
92
+ removeButton.removeClass('d-block')
93
+ removeButton.removeClass('has-existing-value')
79
94
  return row
80
95
  }
81
96
 
82
97
  get _source() {
83
98
  return "<li class=\"field-wrapper input-group input-append\">" +
84
- "<input class=\"string {{class}} optional form-control {{paramKey}}_{{name}} form-control multi-text-field\" name=\"{{paramKey}}[{{name}}_attributes][{{index}}][hidden_label]\" value=\"\" id=\"{{paramKey}}_{{name}}_attributes_{{index}}_hidden_label\" data-attribute=\"{{name}}\" type=\"text\">" +
99
+ "<input class=\"string {{class}} optional form-control {{paramKey}}_{{name}} form-control multi-text-field\" name=\"{{paramKey}}[{{name}}_attributes][{{index}}][hidden_label]\" value=\"\" id=\"{{paramKey}}_{{name}}_attributes_{{index}}_hidden_label\" data-attribute=\"{{name}}\" type=\"text\" placeholder=\"{{placeholder}}\">" +
85
100
  "<input name=\"{{paramKey}}[{{name}}_attributes][{{index}}][id]\" value=\"\" id=\"{{paramKey}}_{{name}}_attributes_{{index}}_id\" type=\"hidden\" data-id=\"remote\">" +
86
101
  "<input name=\"{{paramKey}}[{{name}}_attributes][{{index}}][_destroy]\" id=\"{{paramKey}}_{{name}}_attributes_{{index}}__destroy\" value=\"\" data-destroy=\"true\" type=\"hidden\"></li>"
87
102
  }
@@ -114,9 +129,27 @@ export default class ControlledVocabulary extends FieldManager {
114
129
  // '_destroy' hidden parameter
115
130
  removeFromList( event ) {
116
131
  event.preventDefault()
132
+ // Changing behavior of the remove button to add a new field if the last field is removed
133
+ // Using querySelector to find elements with data-attribute="based_near"
134
+ const inputElements = this.element.find('input' + this.inputTypeClass)
135
+ const parentsArray = Array.from(inputElements).map(element => element.parentElement)
136
+ const nonHiddenElements = parentsArray.filter(element => element.style.display !== 'none')
137
+ const nonHiddenCount = nonHiddenElements.length
138
+ if (nonHiddenCount < 2){
139
+ let $listing = $(event.target).closest(this.inputTypeClass).find(this.listClass)
140
+ let $activeField = $listing.children('li').last()
141
+ $listing.append(this.createNewField($activeField))
142
+ this.postRemovalAdjustment += 1
143
+ }
117
144
  let field = $(event.target).parents(this.fieldWrapperClass)
118
- field.find('[data-destroy]').val('true')
119
- field.hide()
145
+ // Removes field if a value hasn't been selected, otherwise marks it for destruction.
146
+ // Prevents bug caused by marking empty fields for destruction.
147
+ if (field.find('.has-existing-value').length > 0) {
148
+ field.find('[data-destroy]').val('true')
149
+ field.hide()
150
+ } else {
151
+ field.remove()
152
+ }
120
153
  this.element.trigger("managed_field:remove", field)
121
154
  }
122
155
  }
@@ -34,3 +34,9 @@
34
34
  padding-bottom: 10px;
35
35
  }
36
36
  }
37
+
38
+ // fix blueimp jQuery-File-Upload display problems under Bootstrap 4+
39
+ // found here: https://stackoverflow.com/a/48162651
40
+ .fade.in {
41
+ opacity: 1
42
+ }
@@ -1,7 +1,7 @@
1
1
  .controlled_vocabulary {
2
2
  @extend .multi_value;
3
3
 
4
- .listing li:only-of-type .remove {
5
- display: block;
4
+ .listing li .remove {
5
+ display: none;
6
6
  }
7
7
  }
@@ -292,7 +292,7 @@ module Hyrax
292
292
  end
293
293
 
294
294
  def file_metadata
295
- @file_metadata ||= Hyrax.query_service.custom_queries.find_file_metadata_by(id: curation_concern.original_file_id)
295
+ @file_metadata ||= Hyrax.config.file_set_file_service.primary_file_for(file_set: file_set)
296
296
  end
297
297
 
298
298
  # Override this method to add additional response formats to your local app
@@ -84,7 +84,13 @@ module Hyrax
84
84
  end
85
85
 
86
86
  def current_ability
87
- @current_ability ||= SingleUseLinksViewerController::Ability.new current_user, single_use_link
87
+ link_instance = nil
88
+ begin
89
+ link_instance = single_use_link
90
+ rescue ActiveRecord::RecordNotFound
91
+ Rails.logger.debug("Single user link was not found while getting current ability")
92
+ end
93
+ @current_ability ||= SingleUseLinksViewerController::Ability.new current_user, link_instance
88
94
  end
89
95
 
90
96
  def render_single_use_error(exception)
@@ -102,9 +108,10 @@ module Hyrax
102
108
  include CanCan::Ability
103
109
 
104
110
  attr_reader :single_use_link
111
+ attr_reader :current_user
105
112
 
106
113
  def initialize(user, single_use_link)
107
- @user = user || ::User.new
114
+ @current_user = user || ::User.new
108
115
  return unless single_use_link
109
116
 
110
117
  @single_use_link = single_use_link
@@ -2,4 +2,16 @@
2
2
 
3
3
  # Provide plain collection model if not defined by the application.
4
4
  # Needed until Hyrax internals do not assume its existence.
5
- class ::Collection < Hyrax.config.collection_class; end unless '::Collection'.safe_constantize
5
+ class ::Collection < Hyrax.config.collection_class; end unless ActiveSupport::Dependencies.then do |deps|
6
+ # In autoloading environments, when referencing +::Collection+ from the
7
+ # initializer, make sure that +safe_constantize+ wouldn’t just try loading
8
+ # this file again (which would produce a runtime error). Do this by manually
9
+ # searching for the file which should define +::Collection+ and checking if it
10
+ # is the one being currently loaded.
11
+ break true if Object.const_defined?(:Collection)
12
+ file_path = deps.search_for_file("collection")
13
+ expanded = File.expand_path(file_path)
14
+ expanded.delete_suffix!(".rb")
15
+ break false if deps.loading.include?(expanded)
16
+ '::Collection'.safe_constantize
17
+ end
@@ -99,7 +99,7 @@ module Hyrax
99
99
  end
100
100
 
101
101
  def self.classes_from(strings)
102
- strings.map(&:safe_constantize).flatten.uniq
102
+ strings.map(&:safe_constantize).compact.uniq
103
103
  end
104
104
  private_class_method :classes_from
105
105
 
@@ -98,9 +98,9 @@ module Hyrax
98
98
  def presenter_for(document:, ability:)
99
99
  case document['has_model_ssim'].first
100
100
  when *Hyrax::ModelRegistry.file_set_rdf_representations
101
- Hyrax::FileSetPresenter.new(document, ability)
101
+ file_presenter_class.new(document, ability)
102
102
  else
103
- Hyrax::WorkShowPresenter.new(document, ability)
103
+ work_presenter_class.new(document, ability)
104
104
  end
105
105
  end
106
106
 
@@ -63,10 +63,10 @@ module Hyrax
63
63
 
64
64
  # @return [Boolean] render a IIIF viewer
65
65
  def iiif_viewer?
66
- representative_id.present? &&
66
+ Hyrax.config.iiif_image_server? &&
67
+ representative_id.present? &&
67
68
  representative_presenter.present? &&
68
69
  representative_presenter.image? &&
69
- Hyrax.config.iiif_image_server? &&
70
70
  members_include_viewable_image?
71
71
  end
72
72
 
@@ -32,7 +32,16 @@ module Hyrax
32
32
  end
33
33
 
34
34
  ##
35
- # Return the Hyrax::FileMetadata which should be considered “primary” for
35
+ # Return the {Hyrax::FileMetadata} which should be considered “primary” for
36
+ # indexing and version‐tracking.
37
+ #
38
+ # @return [Hyrax::FileMetadata]
39
+ def self.primary_file_for(file_set:, query_service: Hyrax.query_service)
40
+ new(file_set: file_set, query_service: query_service).primary_file
41
+ end
42
+
43
+ ##
44
+ # Return the {Hyrax::FileMetadata} which should be considered “primary” for
36
45
  # indexing and version‐tracking.
37
46
  #
38
47
  # If +file_set.original_file_id+ is defined, it will be used; otherwise,
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hyrax
4
+ module Listeners
5
+ ##
6
+ # Listens for events related to Files ({Valkyrie::StorageAdapter::File})
7
+ class FileListener
8
+ ##
9
+ # Called when 'file.characterized' event is published;
10
+ # allows post-characterization handling, like derivatives generation.
11
+ #
12
+ # @param [Dry::Events::Event] event
13
+ # @return [void]
14
+ def on_file_characterized(event)
15
+ file_set = event[:file_set]
16
+
17
+ case file_set
18
+ when ActiveFedora::Base # ActiveFedora
19
+ CreateDerivativesJob
20
+ .perform_later(file_set, event[:file_id], event[:path_hint])
21
+ else
22
+ ValkyrieCreateDerivativesJob
23
+ .perform_later(file_set.id.to_s, event[:file_id])
24
+ end
25
+ end
26
+
27
+ ##
28
+ # Called when 'file.uploaded' event is published
29
+ # @param [Dry::Events::Event] event
30
+ # @return [void]
31
+ def on_file_uploaded(event)
32
+ # Run characterization for original file only
33
+ return unless event[:metadata]&.original_file?
34
+
35
+ ValkyrieCharacterizationJob.perform_later(event[:metadata].id.to_s)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -5,25 +5,6 @@ module Hyrax
5
5
  ##
6
6
  # Listens for events related to {Hyrax::FileMetadata}
7
7
  class FileMetadataListener
8
- ##
9
- # Called when 'file.characterized' event is published;
10
- # allows post-characterization handling, like derivatives generation.
11
- #
12
- # @param [Dry::Events::Event] event
13
- # @return [void]
14
- def on_file_characterized(event)
15
- file_set = event[:file_set]
16
-
17
- case file_set
18
- when ActiveFedora::Base # ActiveFedora
19
- CreateDerivativesJob
20
- .perform_later(file_set, event[:file_id], event[:path_hint])
21
- else
22
- ValkyrieCreateDerivativesJob
23
- .perform_later(file_set.id.to_s, event[:file_id])
24
- end
25
- end
26
-
27
8
  ##
28
9
  # Called when 'file.metadata.updated' event is published; reindexes a
29
10
  # {Hyrax::FileSet} when a file claiming to be its `pcdm_use:OriginalFile`
@@ -41,17 +22,6 @@ module Hyrax
41
22
  "encountered an error #{err.message}. should this " \
42
23
  "object be in a FileSet #{event[:metadata]}"
43
24
  end
44
-
45
- ##
46
- # Called when 'file.uploaded' event is published
47
- # @param [Dry::Events::Event] event
48
- # @return [void]
49
- def on_file_uploaded(event)
50
- # Run characterization for original file only
51
- return unless event[:metadata]&.original_file?
52
-
53
- ValkyrieCharacterizationJob.perform_later(event[:metadata].id.to_s)
54
- end
55
25
  end
56
26
  end
57
27
  end
@@ -30,8 +30,8 @@ module Hyrax
30
30
  rescue ConnectionPool::TimeoutError => err
31
31
  Hyrax.logger.error(err.message)
32
32
  raise(ConnectionPool::TimeoutError,
33
- "Failed to aquire a lock from Redlock due to a Redis connection " /
34
- "timeout: #{err}. If you are using Redis via `ConnectionPool` " /
33
+ "Failed to acquire a lock from Redlock due to a Redis connection " \
34
+ "timeout: #{err}. If you are using Redis via `ConnectionPool` " \
35
35
  "you may wish to increase the pool size.")
36
36
  end
37
37
 
@@ -30,8 +30,10 @@ class Hyrax::ValkyrieUpload
30
30
  attr_reader :storage_adapter
31
31
  ##
32
32
  # @param [Valkyrie::StorageAdapter] storage_adapter
33
- def initialize(storage_adapter: Hyrax.storage_adapter)
33
+ # @param [Class] file_set_file_service implementer of {Hyrax::FileSetFileService}
34
+ def initialize(storage_adapter: Hyrax.storage_adapter, file_set_file_service: Hyrax.config.file_set_file_service)
34
35
  @storage_adapter = storage_adapter
36
+ @file_set_file_service = file_set_file_service
35
37
  end
36
38
 
37
39
  def upload(filename:, file_set:, io:, use: Hyrax::FileMetadata::Use::ORIGINAL_FILE, user: nil, mime_type: nil) # rubocop:disable Metrics/AbcSize
@@ -67,7 +69,8 @@ class Hyrax::ValkyrieUpload
67
69
  end
68
70
 
69
71
  def version_upload(file_set:, io:, user:)
70
- file_metadata = Hyrax.query_service.custom_queries.find_file_metadata_by(id: file_set.original_file_id)
72
+ file_metadata = @file_set_file_service.primary_file_for(file_set: file_set)
73
+
71
74
  Hyrax::VersioningService.create(file_metadata, user, io)
72
75
  Hyrax.publisher.publish("file.uploaded", metadata: file_metadata)
73
76
  ContentNewVersionEventJob.perform_later(file_set, user)
@@ -1,20 +1,20 @@
1
1
  <!-- The template to display files available for upload -->
2
- <% fade_class_if_not_test = Rails.env.test? ? 'show' : 'fade show' %>
2
+ <% fade_class_if_not_test = Rails.env.test? ? '' : 'fade' %>
3
3
  <script id="template-upload" type="text/x-tmpl">
4
4
  {% for (var i=0, file; file=o.files[i]; i++) { %}
5
5
  <tr class="template-upload <%= fade_class_if_not_test %>">
6
- <span>
6
+ <td>
7
7
  <span class="preview"></span>
8
- </span>
9
- <span>
8
+ </td>
9
+ <td>
10
10
  <p class="name">{%=file.name%}</p>
11
11
  <strong class="error text-danger"></strong>
12
- </span>
13
- <span>
12
+ </td>
13
+ <td>
14
14
  <p class="size">Processing...</p>
15
15
  <div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="progress-bar progress-bar-striped progress-bar-animated bg-success" style="width:0%;"></div></div>
16
- </span>
17
- <span class="text-right">
16
+ </td>
17
+ <td class="text-right">
18
18
  {% if (!i && !o.options.autoUpload) { %}
19
19
  <button class="btn btn-primary start" disabled>
20
20
  <span class="fa fa-upload"></span>
@@ -27,7 +27,7 @@
27
27
  <span><%= t('helpers.action.cancel') %></span>
28
28
  </button>
29
29
  {% } %}
30
- </span>
30
+ </td>
31
31
  </tr>
32
32
  {% } %}
33
33
  </script>
@@ -1,7 +1,7 @@
1
1
  <!-- The template to display files available for upload -->
2
2
  <script id="template-upload" type="text/x-tmpl">
3
3
  {% for (var i=0, file; file=o.files[i]; i++) { %}
4
- <tr class="template-upload fade show">
4
+ <tr class="template-upload fade">
5
5
  <td>
6
6
  <span class="preview"></span>
7
7
  </td>
@@ -37,7 +37,7 @@
37
37
  <!-- The template to display the banner once upload is complete -->
38
38
  <script id="template-download" type="text/x-tmpl">
39
39
  {% for (var i=0, file; file=o.files[i]; i++) { %}
40
- <span class="template-download fade show">
40
+ <span class="template-download fade">
41
41
  <div id="banner">
42
42
  <div class="row branding-banner-row">
43
43
  <div class="col-sm-3">
@@ -69,7 +69,7 @@
69
69
  <!-- The template to display logo in the table once upload is complete -->
70
70
  <script id="logo-template-download" type="text/x-tmpl">
71
71
  {% for (var i=0, file; file=o.files[i]; i++) { %}
72
- <span class="template-download fade show">
72
+ <span class="template-download fade">
73
73
  <div class="row branding-logo-row">
74
74
  <div class="col-sm-3">
75
75
  <span class="preview">
@@ -1,5 +1,5 @@
1
1
  <!-- The template to display files available for upload -->
2
- <% fade_class_if_not_test = Rails.env.test? ? 'show' : 'fade show' %>
2
+ <% fade_class_if_not_test = Rails.env.test? ? '' : 'fade' %>
3
3
  <script id="versioning-template-upload" type="text/x-tmpl">
4
4
  {% for (var i=0, file; file=o.files[i]; i++) { %}
5
5
  <tr class="template-upload <%= fade_class_if_not_test %>">
@@ -2,7 +2,7 @@ apiVersion: v2
2
2
  name: hyrax
3
3
  description: An open-source, Samvera-powered digital repository system
4
4
  type: application
5
- version: 3.6.0
5
+ version: 3.7.0
6
6
  appVersion: 5.0.0
7
7
  dependencies:
8
8
  - name: fcrepo
@@ -112,6 +112,18 @@ spec:
112
112
  - name: http
113
113
  containerPort: 3000
114
114
  protocol: TCP
115
+ {{- if .Values.startupProbe.enabled }}
116
+ startupProbe:
117
+ initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds | default 5 }}
118
+ timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds | default 5 }}
119
+ failureThreshold: {{ .Values.startupProbe.failureThreshold | default 3 }}
120
+ periodSeconds: {{ .Values.startupProbe.periodSeconds | default 10}}
121
+ successThreshold: {{ .Values.startupProbe.successThreshold | default 1 }}
122
+ httpGet:
123
+ scheme: "HTTP"
124
+ path: {{ .Values.startupProbe.path | default "/" }}
125
+ port: 3000
126
+ {{- end }}
115
127
  {{- if .Values.livenessProbe.enabled }}
116
128
  livenessProbe:
117
129
  initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds | default 5 }}
@@ -188,6 +188,16 @@ readinessProbe:
188
188
  # failureThreshold: 6
189
189
  # successThreshold: 1
190
190
 
191
+ # consider enabling if you are experiencing slow startup times
192
+ startupProbe:
193
+ enabled: false
194
+ # path: "/healthz"
195
+ # initialDelaySeconds: 30
196
+ # periodSeconds: 30
197
+ # timeoutSeconds: 5
198
+ # failureThreshold: 3
199
+ # successThreshold: 1
200
+
191
201
  resources: {}
192
202
 
193
203
  worker:
@@ -32,7 +32,7 @@ You can also try [Running Hyrax-based application in local VM](https://github.co
32
32
  During development, running only the dependent services in a container environment may be beneficial. This avoids potential headaches concerning file permissions and eases the use of debugging tools. The application generation instructions below use [Lando](https://lando.dev) to achieve this setup.
33
33
 
34
34
  This document contains instructions specific to setting up an app with __Hyrax
35
- v5.0.0__. If you are looking for instructions on installing a different
35
+ v5.0.1__. If you are looking for instructions on installing a different
36
36
  version, be sure to select the appropriate branch or tag from the drop-down
37
37
  menu above.
38
38
 
@@ -130,7 +130,7 @@ Rails requires that you have a JavaScript runtime installed (e.g. nodejs or ruby
130
130
  Create a new Hyrax-based application by following these steps in order.
131
131
 
132
132
  **NOTE:** Starting with Hyrax v5, the generated application will use [Valkyrie](https://github.com/samvera/valkyrie) for repository persistence.
133
- Use of [ActiveFedora](https://github.com/samvera/active_fedora) (instead of Valkyrie) is deprecated, but it should still be possible to reconfigure the generated application to use it.
133
+ Use of [ActiveFedora](https://github.com/samvera/active_fedora) (instead of Valkyrie) is deprecated, but it should still be possible to reconfigure the generated application to use it.
134
134
 
135
135
  ### Development Prerequisites
136
136
 
@@ -145,10 +145,10 @@ These instructions assume the use of [Lando](https://lando.dev) and [Docker](htt
145
145
 
146
146
  Generate a new Rails application using the template.
147
147
 
148
- **NOTE:** `HYRAX_SKIP_WINGS` is needed here to avoid loading the Wings compatibility layer during the application generation process.
148
+ **NOTE:** `HYRAX_SKIP_WINGS` is needed here to avoid loading the Wings compatibility layer during the application generation process.
149
149
 
150
150
  ```shell
151
- HYRAX_SKIP_WINGS=true rails _6.1.7.7_ new my_app --database=postgresql -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.0/template.rb
151
+ HYRAX_SKIP_WINGS=true rails _6.1.7.7_ new my_app --database=postgresql -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.1/template.rb
152
152
  ```
153
153
 
154
154
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
data/hyrax.gemspec CHANGED
@@ -18,13 +18,7 @@ SUMMARY
18
18
  spec.homepage = "http://github.com/samvera/hyrax"
19
19
 
20
20
  spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR).reject do |f|
21
- f == 'bin/rails' ||
22
- # We want for downstream implementations to be able to leverage the various Hyrax factories.
23
- # As such we need them to be available in the .gem file. See `./lib/hyrax/spec/factories.rb`
24
- # for more details.
25
- (File.dirname(f) =~ %r{\A"?spec\/?} &&
26
- File.dirname(f) !~ %r{\A"?spec\/(factories|assets|support)\/?}
27
- )
21
+ f == 'bin/rails' || File.dirname(f) =~ %r{\A"?spec\/?}
28
22
  end
29
23
  spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
30
24
  spec.name = "hyrax"
@@ -91,7 +85,7 @@ SUMMARY
91
85
  spec.add_dependency 'tinymce-rails', '~> 5.10'
92
86
  spec.add_dependency 'valkyrie', '~> 3.1.1'
93
87
  spec.add_dependency 'view_component', '~> 2.74.1' # Pin until blacklight is updated with workaround for https://github.com/ViewComponent/view_component/issues/1565
94
- spec.add_dependency 'sprockets', '~> 3.7'
88
+ spec.add_dependency 'sprockets', '3.7.2' # 3.7.3 fails feature specs
95
89
  spec.add_dependency 'sass-rails', '~> 6.0'
96
90
  spec.add_dependency 'select2-rails', '~> 3.5'
97
91
 
@@ -124,6 +124,16 @@ module Hyrax
124
124
 
125
125
  # @since 3.5.0
126
126
  # @macro a_registered_event
127
+ # @note this event SHOULD be published file is characteried by the
128
+ # characterization service. Normally, this should happen close to
129
+ # when the `file.metadata.updated` event (since characterization
130
+ # typically involves updating the metadata). Listeners that intend
131
+ # to track updates to file metadata should listen on that event
132
+ # topic.
133
+ # The event payload MUST include a `:file_set` ({Hyrax::FileSet}),
134
+ # a `:file_id` (the id of the {Valkyrie::StorageAdapter::File}),
135
+ # and MAY have a `path_hint` for a local path / cache for the
136
+ # file.
127
137
  register_event('file.characterized')
128
138
 
129
139
  # @since 3.3.0
@@ -208,6 +218,7 @@ module Hyrax
208
218
  @default_listeners ||=
209
219
  [Hyrax::Listeners::ACLIndexListener.new,
210
220
  Hyrax::Listeners::BatchNotificationListener.new,
221
+ Hyrax::Listeners::FileListener.new,
211
222
  Hyrax::Listeners::FileMetadataListener.new,
212
223
  Hyrax::Listeners::FileSetLifecycleListener.new,
213
224
  Hyrax::Listeners::FileSetLifecycleNotificationListener.new,
@@ -66,6 +66,11 @@ FactoryBot.define do
66
66
  .assign_access_for(visibility: evaluator.visibility_setting)
67
67
  end
68
68
 
69
+ if evaluator.respond_to?(:admin_set) && evaluator.admin_set.present?
70
+ template = Hyrax::PermissionTemplate.find_by(source_id: evaluator.admin_set.id)
71
+ Hyrax::PermissionTemplateApplicator.apply(template).to(model: work) if template
72
+ end
73
+
69
74
  work.permission_manager.edit_groups = work.permission_manager.edit_groups.to_a + evaluator.edit_groups
70
75
  work.permission_manager.edit_users = work.permission_manager.edit_users.to_a + evaluator.edit_users
71
76
  work.permission_manager.read_users = work.permission_manager.read_users.to_a + evaluator.read_users
@@ -80,6 +85,12 @@ FactoryBot.define do
80
85
  .new(resource: work)
81
86
  .assign_access_for(visibility: evaluator.visibility_setting)
82
87
  end
88
+
89
+ if evaluator.respond_to?(:admin_set) && evaluator.admin_set.present?
90
+ template = Hyrax::PermissionTemplate.find_by(source_id: evaluator.admin_set.id)
91
+ Hyrax::PermissionTemplateApplicator.apply(template).to(model: work) if template
92
+ end
93
+
83
94
  work.permission_manager.edit_groups = work.permission_manager.edit_groups.to_a + evaluator.edit_groups
84
95
  work.permission_manager.edit_users = work.permission_manager.edit_users.to_a + evaluator.edit_users
85
96
  work.permission_manager.read_users = work.permission_manager.read_users.to_a + evaluator.read_users
@@ -14,8 +14,7 @@ module Hyrax
14
14
 
15
15
  ##
16
16
  # @params [#save] persister
17
- def initialize(property: :file_ids, query_service: Hyrax.query_service, persister: Hyrax.persister, publisher: Hyrax.publisher)
18
- @property = property
17
+ def initialize(query_service: Hyrax.query_service, persister: Hyrax.persister, publisher: Hyrax.publisher)
19
18
  @persister = persister
20
19
  @query_service = query_service
21
20
  @publisher = publisher
@@ -29,10 +28,10 @@ module Hyrax
29
28
  def call(resource)
30
29
  return Failure(:resource_not_persisted) unless resource.persisted?
31
30
 
32
- resource[@property].each do |file_id|
33
- return Failure[:failed_to_delete_file_metadata, file_id] unless
31
+ @query_service.custom_queries.find_files(file_set: resource).each do |file_metadata|
32
+ return Failure[:failed_to_delete_file_metadata, file_metadata.id] unless
34
33
  Hyrax::Transactions::Container['file_metadata.destroy']
35
- .call(@query_service.custom_queries.find_file_metadata_by(id: file_id))
34
+ .call(file_metadata)
36
35
  .success?
37
36
  rescue ::Ldp::Gone
38
37
  nil
data/lib/hyrax/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hyrax
3
- VERSION = '5.0.0'
3
+ VERSION = '5.0.1'
4
4
  end
data/template.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
- gem 'hyrax', '5.0.0'
2
+ gem 'hyrax', '5.0.1'
3
3
  run 'bundle install'
4
4
  generate 'hyrax:install', '-f'