activeadmin 2.11.1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeadmin might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40e545429e58f56877c3374a3b41adb6e02b15dba7ce6155ecef68d606d63edf
4
- data.tar.gz: 6e479ebfc7d021502f8df7d11c57ea444bd0c7714be57673575d559b3871f7da
3
+ metadata.gz: 170a59df9471df04e568a2ae1cc4dab8ff58c28fd28a6861a5e87ba596a4e913
4
+ data.tar.gz: ff345b66e5c18bc94b2a9394d0a633ebe12cce3f7c94b5119ece2b54bcf86836
5
5
  SHA512:
6
- metadata.gz: d355e9804b0a59fb57708115c0ff5d3542ffb89e5b02c27e022bd4820747c587de4b26cfcca9894c28f573515d41d79ee4b78a98f627ebb17fbb19dab1e37929
7
- data.tar.gz: 17ba06abb61b0a7c74bf0e00201890c9a9e5021a2daa7c8866473f66b8497d3c948875fbffef761585d0b4f9b4fb75b2710142ae365b2f38c730531342d769d0
6
+ metadata.gz: 558b34213e3a1af076814008a337ed3d7a66fa328c33bb460020f28595f4e4898e815752dde54c8b41ab6fa687989e7c4d0d8cd58113e736bdafe3943b3c3026
7
+ data.tar.gz: bb0f39fecd17ef5bb0063aaa64cf2ee2684fa52b19faf7b2e37fc273484554ad97a686972f5d5baa02cbd8d785efd9de384769e86b2083f5a2a6c591381d573d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.13.0 [☰](https://github.com/activeadmin/activeadmin/compare/v2.12.0..v2.13.0)
6
+
7
+ ### Documentation
8
+
9
+ * Update validation errors documentation to account for deprecated `ActiveModel::Errors#keys`. [#7475] by [@amit]
10
+
11
+ ### Dependency Changes
12
+
13
+ * Drop rails 6.0 support. [#7476] by [@deivid-rodriguez]
14
+
15
+ ### Performance
16
+
17
+ * Fix pundit performance. [#7479] by [@deivid-rodriguez]
18
+
19
+ ## 2.12.0 [☰](https://github.com/activeadmin/activeadmin/compare/v2.11.2..v2.12.0)
20
+
21
+ ### Enhancements
22
+
23
+ * Add Ransack 3 compatibility. [#7453] by [@tagliala]
24
+
25
+ ### Bug Fixes
26
+
27
+ * Fix pundit namespace detection. [#7144] by [@vlad-psh]
28
+
29
+ ### Documentation
30
+
31
+ * Don't mention webpacker as the default asset generator in Rails. [#7377] by [@jaynetics]
32
+
33
+ ### Performance
34
+
35
+ * Avoid duplicate work when downloading CSV. [#7336] by [@deivid-rodriguez]
36
+
37
+ ## 2.11.2 [☰](https://github.com/activeadmin/activeadmin/compare/v2.11.1..v2.11.2)
38
+
39
+ ### Bug Fixes
40
+
41
+ * Fix disappearing BOM option for `CSVBuilder`. [#7170] by [@Karoid]
42
+
5
43
  ## 2.11.1 [☰](https://github.com/activeadmin/activeadmin/compare/v2.11.0..v2.11.1)
6
44
 
7
45
  ### Enhancements
@@ -730,6 +768,8 @@ Please check [0-6-stable] for previous changes.
730
768
  [#6959]: https://github.com/activeadmin/activeadmin/pull/6959
731
769
  [#7095]: https://github.com/activeadmin/activeadmin/pull/7095
732
770
  [#7127]: https://github.com/activeadmin/activeadmin/pull/7127
771
+ [#7144]: https://github.com/activeadmin/activeadmin/pull/7144
772
+ [#7170]: https://github.com/activeadmin/activeadmin/pull/7170
733
773
  [#7181]: https://github.com/activeadmin/activeadmin/pull/7181
734
774
  [#7205]: https://github.com/activeadmin/activeadmin/pull/7205
735
775
  [#7235]: https://github.com/activeadmin/activeadmin/pull/7235
@@ -737,12 +777,18 @@ Please check [0-6-stable] for previous changes.
737
777
  [#7262]: https://github.com/activeadmin/activeadmin/pull/7262
738
778
  [#7293]: https://github.com/activeadmin/activeadmin/pull/7293
739
779
  [#7332]: https://github.com/activeadmin/activeadmin/pull/7332
780
+ [#7336]: https://github.com/activeadmin/activeadmin/pull/7336
740
781
  [#7340]: https://github.com/activeadmin/activeadmin/pull/7340
741
782
  [#7341]: https://github.com/activeadmin/activeadmin/pull/7341
742
783
  [#7349]: https://github.com/activeadmin/activeadmin/pull/7349
743
784
  [#7350]: https://github.com/activeadmin/activeadmin/pull/7350
785
+ [#7377]: https://github.com/activeadmin/activeadmin/pull/7377
744
786
  [#7384]: https://github.com/activeadmin/activeadmin/pull/7384
745
787
  [#7394]: https://github.com/activeadmin/activeadmin/pull/7394
788
+ [#7453]: https://github.com/activeadmin/activeadmin/pull/7453
789
+ [#7475]: https://github.com/activeadmin/activeadmin/pull/7475
790
+ [#7476]: https://github.com/activeadmin/activeadmin/pull/7476
791
+ [#7479]: https://github.com/activeadmin/activeadmin/pull/7479
746
792
 
747
793
  [@1000ship]: https://github.com/1000ship
748
794
  [@5t111111]: https://github.com/5t111111
@@ -753,6 +799,7 @@ Please check [0-6-stable] for previous changes.
753
799
  [@alejandroperea]: https://github.com/alejandroperea
754
800
  [@alex-bogomolov]: https://github.com/alex-bogomolov
755
801
  [@amiel]: https://github.com/amiel
802
+ [@amit]: https://github.com/amit
756
803
  [@amiuhle]: https://github.com/amiuhle
757
804
  [@andreslemik]: https://github.com/andreslemik
758
805
  [@bartoszkopinski]: https://github.com/bartoszkopinski
@@ -794,12 +841,14 @@ Please check [0-6-stable] for previous changes.
794
841
  [@javawizard]: https://github.com/javawizard
795
842
  [@javierjulio]: https://github.com/javierjulio
796
843
  [@jawa]: https://github.com/jawa
844
+ [@jaynetics]: https://github.com/jaynetics
797
845
  [@JiiHu]: https://github.com/JiiHu
798
846
  [@jiikko]: https://github.com/jiikko
799
847
  [@johnnyshields]: https://github.com/johnnyshields
800
848
  [@jscheid]: https://github.com/jscheid
801
849
  [@juril33t]: https://github.com/juril33t
802
850
  [@jwesorick]: https://github.com/jwesorick
851
+ [@Karoid]: https://github.com/Karoid
803
852
  [@kjeldahl]: https://github.com/kjeldahl
804
853
  [@ko-lem]: https://github.com/ko-lem
805
854
  [@kobeumut]: https://github.com/kobeumut
data/CONTRIBUTING.md CHANGED
@@ -63,7 +63,7 @@ If you want to test against a Rails version different from the latest, make sure
63
63
  you use the correct Gemfile, for example:
64
64
 
65
65
  ```sh
66
- export BUNDLE_GEMFILE=gemfiles/rails_60/Gemfile
66
+ export BUNDLE_GEMFILE=gemfiles/rails_61/Gemfile
67
67
  ```
68
68
 
69
69
  **Warning** SCSS assets are aimed to be used indifferently with Sprockets **and** webpacker.
@@ -114,7 +114,7 @@ If you're getting the error `wrong number of arguments (6 for 4..5)`, [read #270
114
114
 
115
115
  ## webpacker
116
116
 
117
- For new apps starting with Rails 6.0, Webpacker has become the default asset generator. You can **opt-in to using Webpacker for ActiveAdmin assets** as well by updating your configuration to turn on the `use_webpacker` option, either at installation time or manually.
117
+ You can **opt-in to using Webpacker for ActiveAdmin assets** as well by updating your configuration to turn on the `use_webpacker` option, either at installation time or manually.
118
118
 
119
119
  * at active_admin installation:
120
120
 
data/docs/5-forms.md CHANGED
@@ -182,7 +182,8 @@ To display a list of all validation errors:
182
182
 
183
183
  ```ruby
184
184
  form do |f|
185
- f.semantic_errors *f.object.errors.keys
185
+ f.semantic_errors *f.object.errors.attribute_names
186
+
186
187
  # ...
187
188
  end
188
189
  ```
data/docs/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (6.0.4.6)
4
+ activesupport (6.0.4.7)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (>= 0.7, < 2)
7
7
  minitest (~> 5.1)
@@ -15,7 +15,7 @@ GEM
15
15
  coffee-script-source (1.11.1)
16
16
  colorator (1.1.0)
17
17
  commonmarker (0.23.4)
18
- concurrent-ruby (1.1.9)
18
+ concurrent-ruby (1.1.10)
19
19
  dnsruby (1.61.9)
20
20
  simpleidn (~> 0.1)
21
21
  em-websocket (0.5.3)
@@ -51,9 +51,9 @@ GEM
51
51
  ffi (1.15.5)
52
52
  forwardable-extended (2.6.0)
53
53
  gemoji (3.0.1)
54
- github-pages (225)
54
+ github-pages (226)
55
55
  github-pages-health-check (= 1.17.9)
56
- jekyll (= 3.9.0)
56
+ jekyll (= 3.9.2)
57
57
  jekyll-avatar (= 0.7.0)
58
58
  jekyll-coffeescript (= 1.1.1)
59
59
  jekyll-commonmark-ghpages (= 0.2.0)
@@ -88,12 +88,12 @@ GEM
88
88
  jekyll-theme-time-machine (= 0.2.0)
89
89
  jekyll-titles-from-headings (= 0.5.3)
90
90
  jemoji (= 0.12.0)
91
- kramdown (= 2.3.1)
91
+ kramdown (= 2.3.2)
92
92
  kramdown-parser-gfm (= 1.1.0)
93
93
  liquid (= 4.0.3)
94
94
  mercenary (~> 0.3)
95
95
  minima (= 2.5.1)
96
- nokogiri (>= 1.12.5, < 2.0)
96
+ nokogiri (>= 1.13.4, < 2.0)
97
97
  rouge (= 3.26.0)
98
98
  terminal-table (~> 1.4)
99
99
  github-pages-health-check (1.17.9)
@@ -102,13 +102,13 @@ GEM
102
102
  octokit (~> 4.0)
103
103
  public_suffix (>= 3.0, < 5.0)
104
104
  typhoeus (~> 1.3)
105
- html-pipeline (2.14.0)
105
+ html-pipeline (2.14.1)
106
106
  activesupport (>= 2)
107
107
  nokogiri (>= 1.4)
108
108
  http_parser.rb (0.8.0)
109
109
  i18n (0.9.5)
110
110
  concurrent-ruby (~> 1.0)
111
- jekyll (3.9.0)
111
+ jekyll (3.9.2)
112
112
  addressable (~> 2.4)
113
113
  colorator (~> 1.0)
114
114
  em-websocket (~> 0.5)
@@ -216,7 +216,7 @@ GEM
216
216
  gemoji (~> 3.0)
217
217
  html-pipeline (~> 2.2)
218
218
  jekyll (>= 3.0, < 5.0)
219
- kramdown (2.3.1)
219
+ kramdown (2.3.2)
220
220
  rexml
221
221
  kramdown-parser-gfm (1.1.0)
222
222
  kramdown (~> 2.0)
@@ -232,7 +232,7 @@ GEM
232
232
  jekyll-seo-tag (~> 2.1)
233
233
  minitest (5.15.0)
234
234
  multipart-post (2.1.1)
235
- nokogiri (1.13.3)
235
+ nokogiri (1.13.4)
236
236
  mini_portile2 (~> 2.8.0)
237
237
  racc (~> 1.4)
238
238
  octokit (4.22.0)
@@ -240,7 +240,7 @@ GEM
240
240
  sawyer (~> 0.8.0, >= 0.5.3)
241
241
  pathutil (0.16.2)
242
242
  forwardable-extended (~> 2.6)
243
- public_suffix (4.0.6)
243
+ public_suffix (4.0.7)
244
244
  racc (1.6.0)
245
245
  rb-fsevent (0.11.1)
246
246
  rb-inotify (0.10.1)
@@ -269,7 +269,7 @@ GEM
269
269
  thread_safe (~> 0.1)
270
270
  unf (0.1.4)
271
271
  unf_ext
272
- unf_ext (0.0.8)
272
+ unf_ext (0.0.8.1)
273
273
  unicode-display_width (1.8.0)
274
274
  zeitwerk (2.5.4)
275
275
 
@@ -43,11 +43,10 @@ module ActiveAdmin
43
43
  end
44
44
 
45
45
  def build(controller, csv)
46
- @collection = controller.send :find_collection, except: :pagination
47
46
  columns = exec_columns controller.view_context
48
- bom = options.delete :byte_order_mark
47
+ bom = options[:byte_order_mark]
49
48
  column_names = options.delete(:column_names) { true }
50
- csv_options = options.except :encoding_options, :humanize_name
49
+ csv_options = options.except :encoding_options, :humanize_name, :byte_order_mark
51
50
 
52
51
  csv << bom if bom
53
52
 
@@ -55,13 +54,8 @@ module ActiveAdmin
55
54
  csv << CSV.generate_line(columns.map { |c| encode c.name, options }, **csv_options)
56
55
  end
57
56
 
58
- ActiveRecord::Base.uncached do
59
- (1..paginated_collection.total_pages).each do |page|
60
- paginated_collection(page).each do |resource|
61
- resource = controller.send :apply_decorator, resource
62
- csv << CSV.generate_line(build_row(resource, columns, options), **csv_options)
63
- end
64
- end
57
+ controller.send(:in_paginated_batches) do |resource|
58
+ csv << CSV.generate_line(build_row(resource, columns, options), **csv_options)
65
59
  end
66
60
 
67
61
  csv
@@ -125,13 +119,5 @@ module ActiveAdmin
125
119
  def column_transitive_options
126
120
  @column_transitive_options ||= @options.slice(*COLUMN_TRANSITIVE_OPTIONS)
127
121
  end
128
-
129
- def paginated_collection(page_no = 1)
130
- @collection.public_send(Kaminari.config.page_method_name, page_no).per(batch_size)
131
- end
132
-
133
- def batch_size
134
- 1000
135
- end
136
122
  end
137
123
  end
@@ -31,16 +31,13 @@ module ActiveAdmin
31
31
  end
32
32
 
33
33
  def retrieve_policy(subject)
34
- case subject
35
- when nil then Pundit.policy!(user, namespace(resource))
36
- when Class then Pundit.policy!(user, namespace(subject.new))
37
- else Pundit.policy!(user, namespace(subject))
38
- end
39
- rescue Pundit::NotDefinedError => e
40
- if default_policy_class
41
- default_policy(user, subject)
34
+ target = policy_target(subject)
35
+ if (policy = policy(namespace(target)) || compat_policy(subject))
36
+ policy
37
+ elsif default_policy_class
38
+ default_policy(subject)
42
39
  else
43
- raise e
40
+ raise Pundit::NotDefinedError, "unable to find a compatible policy for `#{target}`"
44
41
  end
45
42
  end
46
43
 
@@ -57,8 +54,42 @@ module ActiveAdmin
57
54
 
58
55
  private
59
56
 
57
+ def policy_target(subject)
58
+ case subject
59
+ when nil then resource
60
+ when Class then subject.new
61
+ else subject
62
+ end
63
+ end
64
+
65
+ # This method is needed to fallback to our previous policy searching logic.
66
+ # I.e.: when class name contains `default_policy_namespace` (eg: ShopAdmin)
67
+ # we should try to search it without namespace. This is because that's
68
+ # the only thing that worked in this case before we fixed our buggy namespace
69
+ # detection, so people are probably relying on it.
70
+ # This fallback might be removed in future versions of ActiveAdmin, so
71
+ # pundit_adapter search will work consistently with provided namespaces
72
+ def compat_policy(subject)
73
+ return unless default_policy_namespace
74
+
75
+ target = policy_target(subject)
76
+
77
+ return unless target.class.to_s.include?(default_policy_module) &&
78
+ (policy = policy(target))
79
+
80
+ policy_name = policy.class.to_s
81
+
82
+ Deprecation.warn "You have `pundit_policy_namespace` configured as `#{default_policy_namespace}`, " \
83
+ "but ActiveAdmin was unable to find policy #{default_policy_module}::#{policy_name}. " \
84
+ "#{policy_name} will be used instead. " \
85
+ "This behavior will be removed in future versions of ActiveAdmin. " \
86
+ "To fix this warning, move your #{policy_name} policy to the #{default_policy_module} namespace"
87
+
88
+ policy
89
+ end
90
+
60
91
  def namespace(object)
61
- if default_policy_namespace && !object.class.to_s.include?(default_policy_namespace.to_s.camelize)
92
+ if default_policy_namespace && !object.class.to_s.start_with?("#{default_policy_module}::")
62
93
  [default_policy_namespace.to_sym, object]
63
94
  else
64
95
  object
@@ -69,7 +100,7 @@ module ActiveAdmin
69
100
  ActiveAdmin.application.pundit_default_policy && ActiveAdmin.application.pundit_default_policy.constantize
70
101
  end
71
102
 
72
- def default_policy(user, subject)
103
+ def default_policy(subject)
73
104
  default_policy_class.new(user, subject)
74
105
  end
75
106
 
@@ -77,6 +108,18 @@ module ActiveAdmin
77
108
  ActiveAdmin.application.pundit_policy_namespace
78
109
  end
79
110
 
111
+ def default_policy_module
112
+ default_policy_namespace.to_s.camelize
113
+ end
114
+
115
+ def policy(target)
116
+ policies[target] ||= Pundit.policy(user, target)
117
+ end
118
+
119
+ def policies
120
+ @policies ||= {}
121
+ end
122
+
80
123
  end
81
124
 
82
125
  end
@@ -250,12 +250,13 @@ module ActiveAdmin
250
250
  end
251
251
 
252
252
  def apply_pagination(chain)
253
+ # skip pagination if CSV format was requested
254
+ return chain if params["format"] == "csv"
253
255
  # skip pagination if already was paginated by scope
254
256
  return chain if chain.respond_to?(:total_pages)
255
- page_method_name = Kaminari.config.page_method_name
256
257
  page = params[Kaminari.config.param_name]
257
258
 
258
- chain.public_send(page_method_name, page).per(per_page)
259
+ paginate(chain, page, per_page)
259
260
  end
260
261
 
261
262
  def collection_applies(options = {})
@@ -265,6 +266,16 @@ module ActiveAdmin
265
266
  COLLECTION_APPLIES & only - except
266
267
  end
267
268
 
269
+ def in_paginated_batches(&block)
270
+ ActiveRecord::Base.uncached do
271
+ (1..paginated_collection.total_pages).each do |page|
272
+ paginated_collection(page).each do |resource|
273
+ yield apply_decorator(resource)
274
+ end
275
+ end
276
+ end
277
+ end
278
+
268
279
  def per_page
269
280
  if active_admin_config.paginate
270
281
  dynamic_per_page || configured_per_page
@@ -318,6 +329,20 @@ module ActiveAdmin
318
329
  def create_another?
319
330
  params[:create_another].present?
320
331
  end
332
+
333
+ def paginated_collection(page_no = 1)
334
+ paginate(collection, page_no, batch_size)
335
+ end
336
+
337
+ def paginate(chain, page, per_page)
338
+ page_method_name = Kaminari.config.page_method_name
339
+
340
+ chain.public_send(page_method_name, page).per(per_page)
341
+ end
342
+
343
+ def batch_size
344
+ 1000
345
+ end
321
346
  end
322
347
  end
323
348
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdmin
3
- VERSION = "2.11.1"
3
+ VERSION = "2.13.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Maresh
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2022-03-25 00:00:00.000000000 Z
18
+ date: 2022-05-07 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: arbre
@@ -125,7 +125,7 @@ dependencies:
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: '6.0'
128
+ version: '6.1'
129
129
  - - "<"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '7.1'
@@ -135,7 +135,7 @@ dependencies:
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '6.0'
138
+ version: '6.1'
139
139
  - - "<"
140
140
  - !ruby/object:Gem::Version
141
141
  version: '7.1'
@@ -143,22 +143,22 @@ dependencies:
143
143
  name: ransack
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - "~>"
147
- - !ruby/object:Gem::Version
148
- version: '2.1'
149
146
  - - ">="
150
147
  - !ruby/object:Gem::Version
151
148
  version: 2.1.1
149
+ - - "<"
150
+ - !ruby/object:Gem::Version
151
+ version: '4'
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '2.1'
159
156
  - - ">="
160
157
  - !ruby/object:Gem::Version
161
158
  version: 2.1.1
159
+ - - "<"
160
+ - !ruby/object:Gem::Version
161
+ version: '4'
162
162
  description: The administration framework for Ruby on Rails.
163
163
  email:
164
164
  - deivid.rodriguez@riseup.net
@@ -578,7 +578,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
578
578
  - !ruby/object:Gem::Version
579
579
  version: '0'
580
580
  requirements: []
581
- rubygems_version: 3.3.7
581
+ rubygems_version: 3.3.13
582
582
  signing_key:
583
583
  specification_version: 4
584
584
  summary: Active Admin is a Ruby on Rails plugin for generating administration style