hyrax 2.1.0.beta2 → 2.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODE_OF_CONDUCT.md +5 -5
  3. data/.github/CONTRIBUTING.md +2 -2
  4. data/.rubocop.yml +1 -0
  5. data/.rubocop_fixme.yml +2 -0
  6. data/Gemfile +1 -0
  7. data/README.md +3 -2
  8. data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -0
  9. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +4 -3
  10. data/app/actors/hyrax/actors/default_admin_set_actor.rb +9 -6
  11. data/app/assets/javascripts/hyrax.js +3 -0
  12. data/app/assets/javascripts/hyrax/app.js.erb +14 -0
  13. data/app/assets/javascripts/hyrax/batch_edit.js +2 -1
  14. data/app/assets/javascripts/hyrax/collection_types.es6 +97 -36
  15. data/app/assets/javascripts/hyrax/collections.js +15 -49
  16. data/app/assets/javascripts/hyrax/collections_utils.es6 +116 -0
  17. data/app/assets/javascripts/hyrax/collections_v2.es6 +57 -0
  18. data/app/assets/javascripts/hyrax/content_blocks.js +1 -13
  19. data/app/assets/javascripts/hyrax/nav_safety.js +41 -0
  20. data/app/assets/javascripts/hyrax/turbolinks_events.js +3 -0
  21. data/app/assets/stylesheets/hyrax/_collection_types.scss +46 -2
  22. data/app/assets/stylesheets/hyrax/_work-show.scss +6 -9
  23. data/app/assets/stylesheets/hyrax/dashboard.scss +2 -0
  24. data/app/assets/stylesheets/hyrax/sidebar.scss +4 -0
  25. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +10 -2
  26. data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -9
  27. data/app/controllers/hyrax/admin/collection_types_controller.rb +1 -1
  28. data/app/controllers/hyrax/batch_edits_controller.rb +30 -4
  29. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +1 -0
  30. data/app/controllers/hyrax/dashboard/collections_controller.rb +4 -1
  31. data/app/controllers/hyrax/downloads_controller.rb +7 -1
  32. data/app/forms/hyrax/forms/admin/collection_type_form.rb +1 -1
  33. data/app/indexers/hyrax/repository_reindexer.rb +1 -1
  34. data/app/jobs/attach_files_to_work_job.rb +8 -4
  35. data/app/jobs/import_url_job.rb +11 -5
  36. data/app/models/admin_set.rb +25 -3
  37. data/app/models/concerns/hyrax/collection_behavior.rb +23 -11
  38. data/app/models/concerns/hyrax/collection_nesting.rb +22 -3
  39. data/app/models/hyrax/permission_template_access.rb +7 -4
  40. data/app/presenters/hyrax/admin_set_presenter.rb +21 -0
  41. data/app/presenters/hyrax/collection_presenter.rb +23 -1
  42. data/app/presenters/hyrax/dashboard/user_presenter.rb +4 -0
  43. data/app/presenters/hyrax/presents_attributes.rb +6 -2
  44. data/app/presenters/hyrax/work_show_presenter.rb +4 -0
  45. data/app/renderers/hyrax/renderers/attribute_renderer.rb +14 -0
  46. data/app/services/hyrax/adapters/nesting_index_adapter.rb +19 -39
  47. data/app/services/hyrax/admin_set_create_service.rb +1 -1
  48. data/app/services/hyrax/collection_types/create_service.rb +4 -0
  49. data/app/services/hyrax/collections/migration_service.rb +25 -2
  50. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +8 -3
  51. data/app/services/hyrax/collections/nested_collection_query_service.rb +3 -3
  52. data/app/services/hyrax/default_middleware_stack.rb +3 -3
  53. data/app/services/hyrax/multiple_membership_checker.rb +4 -2
  54. data/app/views/catalog/_index_header_list_collection.html.erb +1 -1
  55. data/app/views/catalog/_search_form.html.erb +0 -4
  56. data/app/views/hyrax/admin/admin_sets/_show_actions.html.erb +27 -0
  57. data/app/views/hyrax/admin/admin_sets/show.html.erb +1 -25
  58. data/app/views/hyrax/admin/collection_types/_form.html.erb +17 -6
  59. data/app/views/hyrax/admin/collection_types/_form_appearance.html.erb +5 -0
  60. data/app/views/hyrax/admin/collection_types/_form_participant_table.html.erb +1 -1
  61. data/app/views/hyrax/admin/collection_types/_form_participants.html.erb +56 -52
  62. data/app/views/hyrax/admin/collection_types/edit.html.erb +9 -7
  63. data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
  64. data/app/views/hyrax/base/_attribute_rows.html.erb +15 -14
  65. data/app/views/hyrax/base/_form.html.erb +1 -0
  66. data/app/views/hyrax/base/_form_collections_error.html.erb +1 -0
  67. data/app/views/hyrax/base/_items.html.erb +3 -2
  68. data/app/views/hyrax/base/_metadata.html.erb +5 -7
  69. data/app/views/hyrax/base/_relationships.html.erb +3 -5
  70. data/app/views/hyrax/base/_relationships_parent_row.html.erb +4 -5
  71. data/app/views/hyrax/base/_relationships_parent_rows.html.erb +2 -1
  72. data/app/views/hyrax/base/_show_actions.html.erb +11 -1
  73. data/app/views/hyrax/batch_edits/edit.html.erb +57 -17
  74. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  75. data/app/views/hyrax/collections/show.html.erb +1 -1
  76. data/app/views/hyrax/content_blocks/_form.html.erb +8 -7
  77. data/app/views/hyrax/dashboard/_index_partials/_current_proxy_rights.html.erb +17 -0
  78. data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -3
  79. data/app/views/hyrax/dashboard/collections/_default_group.html.erb +30 -0
  80. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +2 -2
  81. data/app/views/hyrax/dashboard/collections/_form_for_select_collection.html.erb +1 -1
  82. data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
  83. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +13 -2
  84. data/app/views/hyrax/dashboard/show_user.html.erb +10 -9
  85. data/app/views/hyrax/my/collections/_list_collections.html.erb +10 -3
  86. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +1 -1
  87. data/app/views/hyrax/my/collections/_modal_add_to_collection.html.erb +1 -1
  88. data/app/views/hyrax/my/collections/_modal_delete_collections_deny.html.erb +14 -0
  89. data/app/views/hyrax/my/collections/index.html.erb +1 -0
  90. data/app/views/shared/_nav_safety_modal.html.erb +12 -0
  91. data/config/features.rb +4 -0
  92. data/config/initializers/samvera-nesting_indexer_initializer.rb +1 -0
  93. data/config/locales/hyrax.de.yml +26 -11
  94. data/config/locales/hyrax.en.yml +21 -6
  95. data/config/locales/hyrax.es.yml +17 -2
  96. data/config/locales/hyrax.fr.yml +17 -2
  97. data/config/locales/hyrax.it.yml +17 -2
  98. data/config/locales/hyrax.pt-BR.yml +17 -2
  99. data/config/locales/hyrax.zh.yml +17 -2
  100. data/config/locales/simple_form.en.yml +6 -27
  101. data/hyrax.gemspec +2 -2
  102. data/lib/generators/hyrax/assets_generator.rb +4 -0
  103. data/lib/generators/hyrax/install_generator.rb +10 -0
  104. data/lib/generators/hyrax/templates/app/assets/images/unauthorized.png +0 -0
  105. data/lib/generators/hyrax/templates/config/locales/hyrax.en.yml +6 -5
  106. data/lib/generators/hyrax/templates/config/tinymce.yml +12 -7
  107. data/lib/generators/hyrax/templates/db/migrate/20180406202557_add_badge_color_to_collection_types.rb.erb +5 -0
  108. data/lib/hyrax/configuration.rb +1 -1
  109. data/lib/hyrax/version.rb +1 -1
  110. data/spec/actors/hyrax/actors/collections_membership_actor_spec.rb +24 -0
  111. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +19 -1
  112. data/spec/actors/hyrax/actors/default_admin_set_actor_spec.rb +41 -8
  113. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +4 -12
  114. data/spec/actors/hyrax/actors/generic_work_actor_spec.rb +3 -7
  115. data/spec/controllers/hyrax/admin/strategies_controller_spec.rb +13 -2
  116. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +83 -8
  117. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +3 -0
  118. data/spec/controllers/hyrax/downloads_controller_spec.rb +26 -5
  119. data/spec/controllers/hyrax/file_sets_controller_spec.rb +3 -6
  120. data/spec/controllers/hyrax/generic_works_controller_json_spec.rb +4 -4
  121. data/spec/controllers/hyrax/generic_works_controller_spec.rb +3 -23
  122. data/spec/controllers/hyrax/transfers_controller_spec.rb +1 -1
  123. data/spec/factories/admin_sets_lw.rb +215 -0
  124. data/spec/factories/collections.rb +10 -10
  125. data/spec/factory_tests/adminsets_factory_spec.rb +132 -0
  126. data/spec/factory_tests/collections_factory_spec.rb +3 -3
  127. data/spec/features/batch_create_spec.rb +5 -8
  128. data/spec/features/batch_edit_spec.rb +49 -2
  129. data/spec/features/collection_multi_membership_spec.rb +29 -14
  130. data/spec/features/collection_type_spec.rb +9 -2
  131. data/spec/features/create_work_admin_spec.rb +1 -1
  132. data/spec/features/create_work_spec.rb +1 -1
  133. data/spec/features/dashboard/collection_spec.rb +16 -12
  134. data/spec/features/edit_content_block_admin_spec.rb +29 -12
  135. data/spec/features/embargo_spec.rb +55 -0
  136. data/spec/features/proxy_spec.rb +3 -1
  137. data/spec/features/work_show_spec.rb +20 -4
  138. data/spec/forms/hyrax/forms/admin/collection_type_form_spec.rb +1 -0
  139. data/spec/indexers/hyrax/repository_reindexer_spec.rb +1 -1
  140. data/spec/jobs/attach_files_to_work_job_spec.rb +15 -3
  141. data/spec/jobs/batch_create_job_spec.rb +6 -6
  142. data/spec/jobs/create_work_job_spec.rb +1 -1
  143. data/spec/models/admin_set_spec.rb +10 -8
  144. data/spec/models/collection_spec.rb +1 -1
  145. data/spec/models/concerns/hyrax/collection_nesting_spec.rb +6 -3
  146. data/spec/models/flipflop_spec.rb +8 -0
  147. data/spec/models/hyrax/work_behavior_spec.rb +1 -1
  148. data/spec/presenters/hyrax/admin_set_presenter_spec.rb +70 -0
  149. data/spec/presenters/hyrax/collection_presenter_spec.rb +66 -0
  150. data/spec/renderers/hyrax/renderers/attribute_renderer_spec.rb +19 -0
  151. data/spec/services/hyrax/adapters/nesting_index_adapter_spec.rb +31 -21
  152. data/spec/services/hyrax/collection_types/create_service_spec.rb +7 -4
  153. data/spec/services/hyrax/collections/migration_service_spec.rb +204 -17
  154. data/spec/services/hyrax/collections/nested_collection_persistence_service_spec.rb +1 -1
  155. data/spec/services/hyrax/collections/permissions_create_service_spec.rb +1 -1
  156. data/spec/services/hyrax/collections/permissions_service_spec.rb +4 -0
  157. data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -1
  158. data/spec/services/hyrax/multiple_membership_checker_spec.rb +4 -4
  159. data/spec/services/hyrax/workflow/grant_edit_to_depositor_spec.rb +1 -1
  160. data/spec/services/hyrax/workflow/grant_read_to_depositor_spec.rb +1 -1
  161. data/spec/services/hyrax/workflow/revoke_edit_from_depositor_spec.rb +1 -1
  162. data/spec/spec_helper.rb +35 -2
  163. data/spec/support/features/batch_edit_actions.rb +1 -1
  164. data/spec/support/selectors.rb +15 -0
  165. data/spec/views/hyrax/admin/admin_sets/_show_actions.html.erb_spec.rb +66 -0
  166. data/spec/views/hyrax/admin/admin_sets/show.html.erb_spec.rb +5 -34
  167. data/spec/views/hyrax/admin/collection_types/_form.html.erb_spec.rb +3 -1
  168. data/spec/views/hyrax/admin/collection_types/_form_appearance.html.erb_spec.rb +22 -0
  169. data/spec/views/hyrax/admin/collection_types/_form_participants.html.erb_spec.rb +11 -3
  170. data/spec/views/hyrax/base/_items.html.erb_spec.rb +46 -0
  171. data/spec/views/hyrax/base/_relationships.html.erb_spec.rb +1 -1
  172. data/spec/views/hyrax/base/_show_actions.html.erb_spec.rb +4 -2
  173. data/spec/views/hyrax/dashboard/collections/_default_group.html.erb_spec.rb +43 -0
  174. data/spec/views/hyrax/dashboard/collections/_list_collections.html.erb_spec.rb +51 -0
  175. data/spec/views/hyrax/dashboard/collections/show.html.erb_spec.rb +1 -0
  176. data/spec/views/hyrax/dashboard/show_user_spec.rb +5 -2
  177. data/spec/views/hyrax/my/collections/_list_collections.html.erb_spec.rb +2 -0
  178. data/template.rb +1 -1
  179. metadata +30 -13
  180. data/app/views/hyrax/content_blocks/_modal_content_block.html.erb +0 -15
@@ -1,8 +1,10 @@
1
1
  module Hyrax
2
2
  module Adapters
3
3
  module NestingIndexAdapter
4
- # @!group Providing interface for a Samvera::NestingIndexer::Adapter
4
+ FULL_REINDEX = "full".freeze
5
+ LIMITED_REINDEX = "limited".freeze
5
6
 
7
+ # @!group Providing interface for a Samvera::NestingIndexer::Adapter
6
8
  # @api public
7
9
  # @param id [String]
8
10
  # @return Samvera::NestingIndexer::Document::PreservationDocument
@@ -38,19 +40,10 @@ module Hyrax
38
40
  coerce_solr_document_to_index_document(original_solr_document: solr_document, id: id)
39
41
  end
40
42
 
41
- # @api public
42
- # @deprecated
43
- # @yield Samvera::NestingIndexer::Document::PreservationDocument
44
- # rubocop:disable Lint/UnusedMethodArgument
45
- def self.each_preservation_document(&block)
46
- raise NotImplementedError
47
- end
48
- # rubocop:enable Lint/UnusedMethodArgument
49
-
50
43
  # @api public
51
44
  # @yieldparam id [String]
52
45
  # @yieldparam parent_id [Array<String>]
53
- # Samvera::NestingIndexer.reindex_all!
46
+ # Samvera::NestingIndexer.reindex_all!(extent: FULL_REINDEX)
54
47
  # rubocop:disable Lint/UnusedMethodArgument
55
48
  def self.each_perservation_document_id_and_parent_ids(&block)
56
49
  ActiveFedora::Base.descendant_uris(ActiveFedora.fedora.base_uri, exclude_uri: true).each do |uri|
@@ -70,22 +63,6 @@ module Hyrax
70
63
  end
71
64
  # rubocop:enable Lint/UnusedMethodArgument
72
65
 
73
- # @api public
74
- # @deprecated
75
- #
76
- # From the given parameters, we will need to add them to the underlying SOLR document for the object
77
- #
78
- # @param id [String]
79
- # @param parent_ids [Array<String>]
80
- # @param ancestors [Array<String>]
81
- # @param pathnames [Array<String>]
82
- # @return Hash - the attributes written to the indexing layer
83
- # rubocop:disable Lint/UnusedMethodArgument
84
- def self.write_document_attributes_to_index_layer(id:, parent_ids:, ancestors:, pathnames:, deepest_nested_depth:)
85
- raise NotImplementedError, "This method is deprecated as of v1.0.0 of samvera-nesting_indexer, prefer instead .write_nesting_document_to_index_layer"
86
- end
87
- # rubocop:enable Lint/UnusedMethodArgument
88
-
89
66
  # @api public
90
67
  #
91
68
  # From the nesting_document, we will need to add the nesting attributes to the underlying SOLR document for the object
@@ -126,12 +103,14 @@ module Hyrax
126
103
 
127
104
  # @api public
128
105
  # @param document [Samvera::NestingIndexer::Documents::IndexDocument]
106
+ # @param extent [String] if not "full" or nil, doesn't yield children for reindexing
129
107
  # @param solr_field_name_for_ancestors [String] The SOLR field name we use to find children
130
108
  # @yield Samvera::NestingIndexer::Documents::IndexDocument
131
- def self.each_child_document_of(document:, &block)
109
+ def self.each_child_document_of(document:, extent:, &block)
132
110
  raw_child_solr_documents_of(parent_document: document).each do |solr_document|
133
111
  child_document = coerce_solr_document_to_index_document(original_solr_document: solr_document, id: solr_document.fetch('id'))
134
- block.call(child_document)
112
+ # during light reindexing, we want to reindex the child only if fields aren't already there
113
+ block.call(child_document) if full_reindex?(extent: extent) || child_document.pathnames.empty?
135
114
  end
136
115
  end
137
116
  # @!endgroup
@@ -165,14 +144,10 @@ module Hyrax
165
144
  end
166
145
 
167
146
  class << self
168
- delegate :solr_field_name_for_storing_pathnames, :solr_field_name_for_storing_ancestors, :solr_field_name_for_storing_parent_ids, to: :nesting_configuration
169
- end
170
-
171
- # <dynamicField name="*_isi" type="int" stored="true" indexed="true" multiValued="false"/>
172
- SOLR_FIELD_NAME_FOR_DEEPEST_NESTED_DEPTH = 'nesting_collection__deepest_nested_depth_isi'.freeze
173
-
174
- def self.solr_field_name_for_deepest_nested_depth
175
- SOLR_FIELD_NAME_FOR_DEEPEST_NESTED_DEPTH
147
+ delegate :solr_field_name_for_storing_pathnames,
148
+ :solr_field_name_for_storing_ancestors,
149
+ :solr_field_name_for_storing_parent_ids,
150
+ :solr_field_name_for_deepest_nested_depth, to: :nesting_configuration
176
151
  end
177
152
 
178
153
  # @api private
@@ -180,12 +155,17 @@ module Hyrax
180
155
  # @return [Hash] A raw response document from SOLR
181
156
  # @todo What is the appropriate suffix to apply to the solr_field_name?
182
157
  def self.raw_child_solr_documents_of(parent_document:)
183
- # query Solr for all of the documents included as a member_of_collection parent.
158
+ # query Solr for all of the documents included as a member_of_collection parent. Or up to 10000 of them.
184
159
  child_query = ActiveFedora::SolrQueryBuilder.construct_query(member_of_collection_ids_ssim: parent_document.id)
185
- ActiveFedora::SolrService.query(child_query)
160
+ ActiveFedora::SolrService.query(child_query, rows: 10_000.to_i)
186
161
  end
187
162
  private_class_method :raw_child_solr_documents_of
188
163
 
164
+ def self.full_reindex?(extent:)
165
+ return true if extent == FULL_REINDEX
166
+ false
167
+ end
168
+ private_class_method :full_reindex?
189
169
  # @!endgroup
190
170
  end
191
171
  end
@@ -120,7 +120,7 @@ module Hyrax
120
120
 
121
121
  # Gives deposit access to registered users to default AdminSet
122
122
  def create_default_access_for(permission_template:, workflow:)
123
- permission_template.access_grants.create(agent_type: 'group', agent_id: 'registered', access: Hyrax::PermissionTemplateAccess::DEPOSIT)
123
+ permission_template.access_grants.create(agent_type: 'group', agent_id: ::Ability.registered_group_name, access: Hyrax::PermissionTemplateAccess::DEPOSIT)
124
124
  deposit = Sipity::Role[Hyrax::RoleRegistry::DEPOSITING]
125
125
  workflow.update_responsibilities(role: deposit, agents: Hyrax::Group.new('registered'))
126
126
  end
@@ -22,6 +22,7 @@ module Hyrax
22
22
  require_membership: false,
23
23
  assigns_workflow: false,
24
24
  assigns_visibility: false,
25
+ badge_color: "#663333",
25
26
  participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS },
26
27
  { agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.registered_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }]
27
28
  }.freeze
@@ -39,6 +40,7 @@ module Hyrax
39
40
  require_membership: false,
40
41
  assigns_workflow: false,
41
42
  assigns_visibility: false,
43
+ badge_color: "#663333",
42
44
  participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS },
43
45
  { agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.registered_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }]
44
46
  }.freeze
@@ -56,6 +58,7 @@ module Hyrax
56
58
  require_membership: true,
57
59
  assigns_workflow: true,
58
60
  assigns_visibility: true,
61
+ badge_color: "#663333",
59
62
  participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS },
60
63
  { agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }]
61
64
  }.freeze
@@ -78,6 +81,7 @@ module Hyrax
78
81
  # with allow_multiple_membership=false, works can belong to one and only one collection of this type.
79
82
  # @option options [Boolean] :assigns_workflow if true, collections of this type can be used to assign a workflow to a work
80
83
  # @option options [Boolean] :assigns_visibility if true, collections of this type can be used to assign initial visibility to a work
84
+ # @option options [String] :badge_color a color for the badge to show the user when selecting the collection type
81
85
  # @return [Hyrax::CollectionType] the newly created collection type instance
82
86
  def self.create_collection_type(machine_id:, title:, options: {})
83
87
  opts = DEFAULT_OPTIONS.merge(options).except(:participants)
@@ -13,6 +13,11 @@ module Hyrax
13
13
  migrate_collection(col)
14
14
  Rails.logger.info " migrating collection - id: #{col.id}, title: #{col.title}"
15
15
  end
16
+
17
+ AdminSet.all.each do |adminset|
18
+ migrate_adminset(adminset)
19
+ Rails.logger.info " migrating adminset - id: #{adminset.id}, title: #{adminset.title}"
20
+ end
16
21
  Rails.logger.info "--- Migration Complete"
17
22
  end
18
23
 
@@ -30,6 +35,20 @@ module Hyrax
30
35
  end
31
36
  private_class_method :migrate_collection
32
37
 
38
+ # @api private
39
+ #
40
+ # Migrate a single adminset to grant depositors and viewers read access to the admin set unless the grant is for
41
+ # registered (authenticated users) or public (anyone) groups. The adjustment is being made to adminsets created
42
+ # before Hyrax 2.1.0. Migrating twice will not adversely impact the adminset.
43
+ #
44
+ # @param adminset [AdminSet] adminset object to be migrated
45
+ def self.migrate_adminset(adminset)
46
+ Hyrax::PermissionTemplateAccess.find_or_create_by(permission_template_id: adminset.permission_template.id,
47
+ agent_type: "group", agent_id: "admin", access: "manage")
48
+ adminset.reset_access_controls!
49
+ end
50
+ private_class_method :migrate_adminset
51
+
33
52
  # @api public
34
53
  #
35
54
  # Validate that migrated collections have both the collection type gid assigned and the permission template with
@@ -39,9 +58,13 @@ module Hyrax
39
58
  Rails.logger.info "*** Repairing migrated collections"
40
59
  Collection.all.each do |col|
41
60
  repair_migrated_collection(col)
42
- Rails.logger.info " migrating collection - id: #{col.id}, title: #{col.title}"
61
+ Rails.logger.info " repairing collection - id: #{col.id}, title: #{col.title}"
43
62
  end
44
- Rails.logger.info "--- Migration Complete"
63
+ AdminSet.all.each do |adminset|
64
+ migrate_adminset(adminset)
65
+ Rails.logger.info " repairing adminset - id: #{adminset.id}, title: #{adminset.title}"
66
+ end
67
+ Rails.logger.info "--- Repairing Complete"
45
68
  end
46
69
 
47
70
  # @api private
@@ -11,14 +11,19 @@ module Hyrax
11
11
  # @note There is odd permission arrangement based on the NestedCollectionQueryService:
12
12
  # You can nest the child within a parent if you can edit the parent and read the child.
13
13
  # See https://wiki.duraspace.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.
14
+ # @note Adding the member_of_collections method doesn't trigger reindexing of the child so we have to do it manually.
15
+ # However it save and reindexes the parent unnecessarily!!
14
16
  def self.persist_nested_collection_for(parent:, child:)
15
- child.member_of_collections << parent
16
- child.save
17
+ parent.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
18
+ child.member_of_collections.push(parent)
19
+ child.update_nested_collection_relationship_indices
17
20
  end
18
21
 
22
+ # @note Removing the member_of_collections method doesn't trigger reindexing of the child so we have to do it manually.
23
+ # However it doesn't save and reindex the parent, as it does when a parent is added!!
19
24
  def self.remove_nested_relationship_for(parent:, child:)
20
25
  child.member_of_collections.delete(parent)
21
- child.save
26
+ child.update_nested_collection_relationship_indices
22
27
  true
23
28
  end
24
29
  end
@@ -20,7 +20,7 @@ module Hyrax
20
20
  @parents = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_parent_ids]
21
21
  @pathnames = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_pathnames]
22
22
  @ancestors = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_storing_ancestors]
23
- @depth = collection_doc[Hyrax::Adapters::NestingIndexAdapter.solr_field_name_for_deepest_nested_depth]
23
+ @depth = collection_doc[Samvera::NestingIndexer.configuration.solr_field_name_for_deepest_nested_depth]
24
24
  end
25
25
  end
26
26
 
@@ -154,13 +154,13 @@ module Hyrax
154
154
  # note: We need to include works in this search. They are included in the depth validations in
155
155
  # the indexer, so we do NOT use collection search builder here.
156
156
  builder = Hyrax::SearchBuilder.new(scope).where("#{Samvera::NestingIndexer.configuration.solr_field_name_for_storing_pathnames}:/.*#{child.id}.*/")
157
- builder.query[:sort] = "#{Hyrax::Adapters::NestingIndexAdapter.solr_field_name_for_deepest_nested_depth} desc"
157
+ builder.query[:sort] = "#{Samvera::NestingIndexer.configuration.solr_field_name_for_deepest_nested_depth} desc"
158
158
  builder.query[:rows] = 1
159
159
  query = clean_lucene_error(builder: builder)
160
160
  response = scope.repository.search(query).documents.first
161
161
 
162
162
  # Now we have the largest nesting depth for all paths containing this collection
163
- descendant_depth = response[Hyrax::Adapters::NestingIndexAdapter.solr_field_name_for_deepest_nested_depth]
163
+ descendant_depth = response[Samvera::NestingIndexer.configuration.solr_field_name_for_deepest_nested_depth]
164
164
 
165
165
  # => 2) Then we get the stored depth of the child collection itself to eliminate the collections above this one from our count, and add 1 to add back in this collection itself
166
166
  child_depth = NestingAttributes.new(id: child.id, scope: scope).depth
@@ -28,6 +28,9 @@ module Hyrax
28
28
  # Set the order of the children (works or file_sets)
29
29
  middleware.use Hyrax::Actors::ApplyOrderActor
30
30
 
31
+ # Sets the default admin set if they didn't supply one
32
+ middleware.use Hyrax::Actors::DefaultAdminSetActor
33
+
31
34
  # Decode the private/public/institution on the form into permisisons on
32
35
  # the model
33
36
  middleware.use Hyrax::Actors::InterpretVisibilityActor
@@ -35,9 +38,6 @@ module Hyrax
35
38
  # Handles transfering ownership of works from one user to another
36
39
  middleware.use Hyrax::Actors::TransferRequestActor
37
40
 
38
- # Sets the default admin set if they didn't supply one
39
- middleware.use Hyrax::Actors::DefaultAdminSetActor
40
-
41
41
  # Copies default permissions from the PermissionTemplate to the work
42
42
  middleware.use Hyrax::Actors::ApplyPermissionTemplateActor
43
43
 
@@ -60,9 +60,11 @@ module Hyrax
60
60
 
61
61
  def build_error_message(problematic_collections)
62
62
  error_message_clauses = problematic_collections.map do |gid, list|
63
- "#{collection_type_title_from_gid(gid)} (#{collection_titles_from_list(list)})"
63
+ I18n.t('hyrax.admin.collection_types.multiple_membership_checker.error_type_and_collections',
64
+ type: collection_type_title_from_gid(gid),
65
+ collections: collection_titles_from_list(list))
64
66
  end
65
- "#{I18n.t('hyrax.admin.collection_types.multiple_membership_checker.error_preamble')}: #{error_message_clauses.join('; ')}"
67
+ "#{I18n.t('hyrax.admin.collection_types.multiple_membership_checker.error_preamble')}#{error_message_clauses.join('; ')}"
66
68
  end
67
69
 
68
70
  def collection_type_title_from_gid(gid)
@@ -1,4 +1,4 @@
1
1
  <div class="search-results-title-row">
2
2
  <h4 class="search-result-title"><%= link_to document.title_or_label, [hyrax, document] %></h4>
3
- <span class="label label-success"><%= Hyrax::CollectionPresenter.new(document, current_ability).collection_type_badge %></span>
3
+ <%= Hyrax::CollectionPresenter.new(document, current_ability).collection_type_badge %>
4
4
  </div>
@@ -29,10 +29,6 @@
29
29
  <%= link_to t("hyrax.search.form.option.my_collections.label_long"), "#",
30
30
  data: { "search-option" => hyrax.my_collections_path, "search-label" => t("hyrax.search.form.option.my_collections.label_short") } %>
31
31
  </li>
32
- <li>
33
- <%= link_to t("hyrax.search.form.option.my_shares.label_long"), "#",
34
- data: { "search-option" => hyrax.dashboard_shares_path, "search-label" => t("hyrax.search.form.option.my_shares.label_short") } %>
35
- </li>
36
32
  <% end %>
37
33
 
38
34
  </ul>
@@ -0,0 +1,27 @@
1
+ <% if can? :edit, presenter.solr_document %>
2
+ <div class="panel-heading">
3
+ <div class="row">
4
+ <div class="col-sm-8">
5
+ <h2 class="panel-title display-page"><%= presenter.to_s %></h2>
6
+ </div>
7
+ <div class="col-sm-4">
8
+ <div class="pull-right">
9
+ <%= link_to edit_admin_admin_set_path(presenter), class: 'btn btn-primary' do %>
10
+ <span class="fa fa-edit"></span> <%= t(:'helpers.action.edit') %>
11
+ <% end %>
12
+ <% if presenter.disable_delete? %>
13
+ <span title="<%= presenter.disabled_message %>">
14
+ <%= link_to admin_admin_set_path(presenter), class: 'btn btn-danger disabled' do %>
15
+ <span class="fa fa-remove"></span> <%= t(:'helpers.action.delete') %>
16
+ <% end %>
17
+ </span>
18
+ <% else %>
19
+ <%= link_to admin_admin_set_path(presenter), class: 'btn btn-danger', data: { confirm: t('.confirm_delete'), method: :delete } do %>
20
+ <span class="fa fa-remove"></span> <%= t(:'helpers.action.delete') %>
21
+ <% end %>
22
+ <% end %>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ <% end %>
@@ -5,31 +5,7 @@
5
5
  <div class="row">
6
6
  <div class="col-md-12">
7
7
  <div class="panel panel-default">
8
- <div class="panel-heading">
9
- <div class="row">
10
- <div class="col-sm-8">
11
- <h2 class="panel-title display-page"><%= @presenter.to_s %></h2>
12
- </div>
13
- <div class="col-sm-4">
14
- <div class="pull-right">
15
- <%= link_to edit_admin_admin_set_path(@presenter), class: 'btn btn-primary' do %>
16
- <span class="fa fa-edit"></span> <%= t(:'helpers.action.edit') %>
17
- <% end %>
18
- <% if @presenter.disable_delete? %>
19
- <span title="<%= @presenter.disabled_message %>">
20
- <%= link_to admin_admin_set_path(@presenter), class: 'btn btn-danger disabled' do %>
21
- <span class="fa fa-remove"></span> <%= t(:'helpers.action.delete') %>
22
- <% end %>
23
- </span>
24
- <% else %>
25
- <%= link_to admin_admin_set_path(@presenter), class: 'btn btn-danger', data: { confirm: t('.confirm_delete'), method: :delete } do %>
26
- <span class="fa fa-remove"></span> <%= t(:'helpers.action.delete') %>
27
- <% end %>
28
- <% end %>
29
- </div>
30
- </div>
31
- </div>
32
- </div>
8
+ <%= render 'show_actions', presenter: @presenter %>
33
9
 
34
10
  <div class="panel-body admin-set row">
35
11
  <div class="col-md-2">
@@ -1,19 +1,23 @@
1
+ <%= render "shared/nav_safety_modal" %>
1
2
  <div class="panel panel-default tabs" id="collection-types-controls">
2
3
  <ul class="nav nav-tabs" role="tablist">
3
4
  <li class="active">
4
- <a href="#metadata" role="tab" data-toggle="tab"><%= t('hyrax.admin.collection_types.form.tab.metadata') %></a>
5
+ <a href="#metadata" role="tab" data-toggle="tab" class="nav-safety-confirm"><%= t('hyrax.admin.collection_types.form.tab.metadata') %></a>
5
6
  </li>
6
7
  <% if @form.persisted? %>
7
8
  <li>
8
- <a href="#settings" role="tab" data-toggle="tab"><%= t('hyrax.admin.collection_types.form.tab.settings') %></a>
9
+ <a href="#settings" role="tab" data-toggle="tab" class="nav-safety-confirm"><%= t('hyrax.admin.collection_types.form.tab.settings') %></a>
9
10
  </li>
10
11
  <li>
11
- <a href="#participants" role="tab" data-toggle="tab"><%= t('hyrax.admin.collection_types.form.tab.participants') %></a>
12
- </li>
12
+ <a href="#participants" role="tab" data-toggle="tab" class="nav-safety-confirm"><%= t('hyrax.admin.collection_types.form.tab.participants') %></a>
13
+ </li>
14
+ <li>
15
+ <a href="#appearance" role="tab" data-toggle="tab" class="nav-safety-confirm"><%= t('hyrax.admin.collection_types.form.tab.appearance') %></a>
16
+ </li>
13
17
  <% end %>
14
18
  </ul>
15
19
  <% form_url = @form.id.nil? ? hyrax.admin_collection_types_path : hyrax.admin_collection_type_path(@form.id) %>
16
- <%= simple_form_for @form, url: form_url, as: :collection_type do |f| %>
20
+ <%= simple_form_for @form, url: form_url, as: :collection_type, html: {class: 'nav-safety'} do |f| %>
17
21
  <div class="tab-content">
18
22
  <% if @collection_type.admin_set? %>
19
23
  <div id="metadata" class="tab-pane active">
@@ -42,12 +46,19 @@
42
46
  <% # end of form %>
43
47
  <% # TODO: The participants partial can't sit inside the other form, moved down here temporarily %>
44
48
  <div id="participants" class="tab-pane">
45
- <div class="panel panel-default labels">
49
+ <div class="panel panel-default labels collection-types-edit-participants-tab">
46
50
  <div class="panel-body">
47
51
  <%= render 'form_participants' %>
48
52
  </div>
49
53
  </div>
50
54
  </div>
55
+ <div id="appearance" class="tab-pane">
56
+ <div class="panel panel-default labels">
57
+ <div class="panel-body">
58
+ <%= render 'form_appearance', f: f %>
59
+ </div>
60
+ </div>
61
+ </div>
51
62
  <div class="panel-footer">
52
63
  <% if params[:action] == "new" %>
53
64
  <%= f.submit t(:'hyrax.admin.collection_types.new.submit'), class: 'btn btn-primary', onclick: "confirmation_needed = false;", id: "create_submit", name: "create_collection_type" %>
@@ -0,0 +1,5 @@
1
+ <div class="panel panel-default">
2
+ <div class="panel-body">
3
+ <%= f.input :badge_color, required: false, input_html: { type: 'color' } %>
4
+ </div>
5
+ </div>
@@ -15,7 +15,7 @@
15
15
  <td data-agent="<%= g.agent_id %>"><%= g.label %></td>
16
16
  <td><%= g.agent_type.titleize %></td>
17
17
  <td>
18
- <%= button_to "Remove", hyrax.admin_collection_type_participant_path(g), method: :delete, class: 'btn btn-danger' %>
18
+ <%= link_to t("helpers.action.remove"), hyrax.admin_collection_type_participant_path(g), method: :delete, class: 'btn btn-sm btn-danger' %>
19
19
  </td>
20
20
  </tr>
21
21
  <% end %>
@@ -1,62 +1,66 @@
1
- <h2><%= t('.add_participants') %></h2>
1
+ <h3><%= t('.add_participants') %></h3>
2
2
  <p><%= t('.instructions') %></p>
3
3
  <% access_options = options_for_select([['Manager', Hyrax::CollectionTypeParticipant::MANAGE_ACCESS], ['Creator', Hyrax::CollectionTypeParticipant::CREATE_ACCESS]]) %>
4
4
  <% unless @collection_type_participant.nil? %>
5
- <%= simple_form_for @collection_type_participant,
6
- url: hyrax.admin_collection_type_participants_path,
7
- html: { id: 'group-participants-form' },
8
- as: :collection_type_participant do |f| %>
9
- <div class="clearfix spacer">
10
- <div class="form-inline">
11
- <label class="col-md-2 col-xs-4 control-label">Add Group</label>
12
5
 
13
- <div class="col-md-10 col-xs-8 form-group">
14
- <%= f.hidden_field :hyrax_collection_type_id, value: @collection_type_participant.hyrax_collection_type_id %>
15
- <%= f.hidden_field :agent_type, value: Hyrax::CollectionTypeParticipant::GROUP_TYPE %>
16
- <%= f.text_field :agent_id,
17
- placeholder: "Search for a group...",
18
- class: 'form-control' %>
19
- as
20
- <%= f.select :access,
21
- access_options,
22
- { prompt: "Select a role..." },
23
- class: 'form-control' %>
6
+ <section class="section-participants">
7
+ <!-- Add group form -->
8
+ <div class="form-add-participants-wrapper row spacer" data-id="<%= @form.id %>">
9
+ <%= simple_form_for @collection_type_participant,
10
+ url: hyrax.admin_collection_type_participants_path,
11
+ html: { id: 'group-participants-form' },
12
+ as: :collection_type_participant do |f| %>
13
+ <div class="form-inline add-participants-form">
14
+ <label class="col-md-2 col-xs-4 control-label"><%= t('.add_group') %>:</label>
15
+
16
+ <div class="col-md-10 col-xs-8 form-group">
17
+ <%= f.hidden_field :hyrax_collection_type_id, value: @collection_type_participant.hyrax_collection_type_id %>
18
+ <%= f.hidden_field :agent_type, value: Hyrax::CollectionTypeParticipant::GROUP_TYPE %>
19
+ <%= f.text_field :agent_id,
20
+ placeholder: "Search for a group...",
21
+ class: 'form-control' %>
22
+ as
23
+ <%= f.select :access,
24
+ access_options,
25
+ { prompt: "Select a role..." },
26
+ class: 'form-control' %>
24
27
 
25
- <%= f.submit t('.submit'), class: 'btn btn-info' %>
28
+ <%= f.submit t('.submit'), class: 'btn btn-info', :disabled => true %>
29
+ </div>
26
30
  </div>
27
- </div>
28
- </div>
29
- <% end %>
30
- <%= simple_form_for @collection_type_participant,
31
- url: hyrax.admin_collection_type_participants_path,
32
- html: { id: 'user-participants-form' },
33
- as: :collection_type_participant do |f| %>
34
- <div class="clearfix spacer">
35
- <div class="form-inline">
36
- <label class="col-md-2 col-xs-4 control-label">Add User</label>
31
+ <% end %>
32
+ </div>
33
+
34
+ <!-- Add user form -->
35
+ <div class="form-add-participants-wrapper row" data-id="<%= @form.id %>">
36
+ <%= simple_form_for @collection_type_participant,
37
+ url: hyrax.admin_collection_type_participants_path,
38
+ html: { id: 'user-participants-form' },
39
+ as: :collection_type_participant do |f| %>
40
+ <div class="form-inline add-participants-form">
41
+ <label class="col-md-2 col-xs-4 control-label"><%= t('.add_user') %>:</label>
37
42
 
38
- <div class="col-md-10 col-xs-8 form-group">
39
- <%= f.hidden_field :hyrax_collection_type_id, value: @collection_type_participant.hyrax_collection_type_id %>
40
- <%= f.hidden_field :agent_type, value: Hyrax::CollectionTypeParticipant::USER_TYPE %>
41
- <%= f.text_field :agent_id,
42
- placeholder: "Search for a user...",
43
+ <div class="col-md-10 col-xs-8 form-group">
44
+ <%= f.hidden_field :hyrax_collection_type_id, value: @collection_type_participant.hyrax_collection_type_id %>
45
+ <%= f.hidden_field :agent_type, value: Hyrax::CollectionTypeParticipant::USER_TYPE %>
46
+ <%= f.text_field :agent_id,
47
+ placeholder: "Search for a user..." %>
48
+ as
49
+ <%= f.select :access,
50
+ access_options,
51
+ { prompt: "Select a role..." },
43
52
  class: 'form-control' %>
44
- as
45
- <%= f.select :access,
46
- access_options,
47
- { prompt: "Select a role..." },
48
- class: 'form-control' %>
49
53
 
50
- <%= f.submit t('.submit'), class: 'btn btn-info' %>
51
- </div>
52
- </div>
53
- </div>
54
- <% end %>
54
+ <%= f.submit t('.submit'), class: 'btn btn-info', :disabled => true %>
55
+ </div>
56
+ </div>
57
+ <% end %>
58
+ </div>
59
+ </section>
60
+
55
61
  <% end %>
56
- <div>
57
- <fieldset>
58
- <legend><%= t('.current_participants') %></legend>
59
- <%= render 'form_participant_table', access: 'managers', filter: :manager? %>
60
- <%= render 'form_participant_table', access: 'creators', filter: :creator? %>
61
- </fieldset>
62
- </div>
62
+ <section class="section-current-participants">
63
+ <legend><%= t('.current_participants') %></legend>
64
+ <%= render 'form_participant_table', access: 'managers', filter: :manager? %>
65
+ <%= render 'form_participant_table', access: 'creators', filter: :creator? %>
66
+ </section>