activeadmin 2.11.2 → 2.12.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: 26f9266cffc8d0e054be977056ba02e2c09803db4f3690235112df2dbaa5b054
4
- data.tar.gz: 8d7a87d3e2f53f5279cf100129149710e3886a633c902c7cd657ad0008b6c397
3
+ metadata.gz: 8fee30bf6175502c7e29f5cba45777a52fd9d72f9433f7f3911ba324a24638ef
4
+ data.tar.gz: 8ad44b1980960d2e8abb3f1406f90c3a0cd01255f0fcb30b6a56bf3cb8db1ab6
5
5
  SHA512:
6
- metadata.gz: f783a8a7dba38645b4c62d11c384c54ceff4a198ea90eaab237c5b87293e82033ddfcbf00e5d7fd15c346b12debdb402a5f96f9b86891576ef34cd87644d3dcd
7
- data.tar.gz: 55cd5df702122eaac4dc70cc7a072754edc1141553056896268ac3c0c7176b8876a8bafac61fe75cec064d58d3d4b03e15b36e3d4c52102a5f6dfb5e44d47214
6
+ metadata.gz: 39beb44c14375cec330f99a1d63d38959523a0bbbcf90e55f6b938a71a8d2624b9f8fdb110839b7272b346acdd533bc3f0fcd3a78ca3c3250bf401c807fb4b13
7
+ data.tar.gz: 9b4d5fb6d6d2238925e315c639bb6625703102d111c482399eb79b02cd6f203f7145770c2985795c2a3f60f6822f2757efe1e5c57a8c4ede3716e023e2efc50e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.12.0 [☰](https://github.com/activeadmin/activeadmin/compare/v2.11.2..v2.12.0)
6
+
7
+ ### Enhancements
8
+
9
+ * Add Ransack 3 compatibility. [#7453] by [@tagliala]
10
+
11
+ ### Bug Fixes
12
+
13
+ * Fix pundit namespace detection. [#7144] by [@vlad-psh]
14
+
15
+ ### Documentation
16
+
17
+ * Don't mention webpacker as the default asset generator in Rails. [#7377] by [@jaynetics]
18
+
19
+ ### Performance
20
+
21
+ * Avoid duplicate work when downloading CSV. [#7336] by [@deivid-rodriguez]
22
+
5
23
  ## 2.11.2 [☰](https://github.com/activeadmin/activeadmin/compare/v2.11.1..v2.11.2)
6
24
 
7
25
  ### Bug Fixes
@@ -736,6 +754,7 @@ Please check [0-6-stable] for previous changes.
736
754
  [#6959]: https://github.com/activeadmin/activeadmin/pull/6959
737
755
  [#7095]: https://github.com/activeadmin/activeadmin/pull/7095
738
756
  [#7127]: https://github.com/activeadmin/activeadmin/pull/7127
757
+ [#7144]: https://github.com/activeadmin/activeadmin/pull/7144
739
758
  [#7170]: https://github.com/activeadmin/activeadmin/pull/7170
740
759
  [#7181]: https://github.com/activeadmin/activeadmin/pull/7181
741
760
  [#7205]: https://github.com/activeadmin/activeadmin/pull/7205
@@ -744,12 +763,15 @@ Please check [0-6-stable] for previous changes.
744
763
  [#7262]: https://github.com/activeadmin/activeadmin/pull/7262
745
764
  [#7293]: https://github.com/activeadmin/activeadmin/pull/7293
746
765
  [#7332]: https://github.com/activeadmin/activeadmin/pull/7332
766
+ [#7336]: https://github.com/activeadmin/activeadmin/pull/7336
747
767
  [#7340]: https://github.com/activeadmin/activeadmin/pull/7340
748
768
  [#7341]: https://github.com/activeadmin/activeadmin/pull/7341
749
769
  [#7349]: https://github.com/activeadmin/activeadmin/pull/7349
750
770
  [#7350]: https://github.com/activeadmin/activeadmin/pull/7350
771
+ [#7377]: https://github.com/activeadmin/activeadmin/pull/7377
751
772
  [#7384]: https://github.com/activeadmin/activeadmin/pull/7384
752
773
  [#7394]: https://github.com/activeadmin/activeadmin/pull/7394
774
+ [#7453]: https://github.com/activeadmin/activeadmin/pull/7453
753
775
 
754
776
  [@1000ship]: https://github.com/1000ship
755
777
  [@5t111111]: https://github.com/5t111111
@@ -801,6 +823,7 @@ Please check [0-6-stable] for previous changes.
801
823
  [@javawizard]: https://github.com/javawizard
802
824
  [@javierjulio]: https://github.com/javierjulio
803
825
  [@jawa]: https://github.com/jawa
826
+ [@jaynetics]: https://github.com/jaynetics
804
827
  [@JiiHu]: https://github.com/JiiHu
805
828
  [@jiikko]: https://github.com/jiikko
806
829
  [@johnnyshields]: https://github.com/johnnyshields
@@ -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/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,7 +43,6 @@ 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
47
  bom = options[:byte_order_mark]
49
48
  column_names = options.delete(:column_names) { true }
@@ -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,13 +31,11 @@ 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
34
+ Pundit.policy!(user, namespace(policy_target(subject)))
39
35
  rescue Pundit::NotDefinedError => e
40
- if default_policy_class
36
+ if (policy = compat_policy(subject))
37
+ policy
38
+ elsif default_policy_class
41
39
  default_policy(user, subject)
42
40
  else
43
41
  raise e
@@ -57,8 +55,41 @@ module ActiveAdmin
57
55
 
58
56
  private
59
57
 
58
+ def policy_target(subject)
59
+ case subject
60
+ when nil then resource
61
+ when Class then subject.new
62
+ else subject
63
+ end
64
+ end
65
+
66
+ # This method is needed to fallback to our previous policy searching logic.
67
+ # I.e.: when class name contains `default_policy_namespace` (eg: ShopAdmin)
68
+ # we should try to search it without namespace. This is because that's
69
+ # the only thing that worked in this case before we fixed our buggy namespace
70
+ # detection, so people are probably relying on it.
71
+ # This fallback might be removed in future versions of ActiveAdmin, so
72
+ # pundit_adapter search will work consistently with provided namespaces
73
+ def compat_policy(subject)
74
+ target = policy_target(subject)
75
+
76
+ return unless default_policy_namespace &&
77
+ target.class.to_s.include?(default_policy_module) &&
78
+ (policy = Pundit.policy(user, 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.match?(/^#{default_policy_module}::/)
62
93
  [default_policy_namespace.to_sym, object]
63
94
  else
64
95
  object
@@ -77,6 +108,10 @@ 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
+
80
115
  end
81
116
 
82
117
  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.2"
3
+ VERSION = "2.12.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.2
4
+ version: 2.12.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-04-12 00:00:00.000000000 Z
18
+ date: 2022-04-22 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: arbre
@@ -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.11
581
+ rubygems_version: 3.3.10
582
582
  signing_key:
583
583
  specification_version: 4
584
584
  summary: Active Admin is a Ruby on Rails plugin for generating administration style