avo 2.24.1 → 2.26.0

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd9af86b6e3a217455a722a02f0e63ac1730f3d38bc8cf437c2e7acf51e42393
4
- data.tar.gz: 3ec156f8d9aa616fe254d91f676d365ce949407c7496b9deac4147213ac25868
3
+ metadata.gz: 2b61c2b5a2648aa08f89b080fe7f8a8c982ef10c51cb361aa24aa53f979dd060
4
+ data.tar.gz: 723c552907d3c861383006edea41a9b73da6c609bc87add39f4349569e427b9e
5
5
  SHA512:
6
- metadata.gz: 6b36e26266d5f1db62580fcc1504e413bb037d5da0a6381bb7cb4785d9db64486f2c2d57d75ebb17ed1b8f21252bbda1c4ef2140ed659bfe62c2117a5c331955
7
- data.tar.gz: 365bb62634783fb83f3a0a3e88fa48f0f35ab64eae9ddeca321ed91f8c1fdaf5468f99e851beb602c2688b2a20db0b956143850e3e09006c07807f6384178837
6
+ metadata.gz: dfbeee5e9548d1c94fee23facf94685393e0cd58fd0079e980ef67707ac52b0545d5aebd7f4e6b3b6b44962d1a3ca540f966c3586660b4582e92484159ac8a3d
7
+ data.tar.gz: eebb9b58090526d78af41e3736985788dc69aabe53b0fd9cc02e4b926a7c8debb7daf5b4a9d17e91b357b126500804ef8cf72152d834cfe1b68a04303c1bda88
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.24.1)
4
+ avo (2.26.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -19,40 +19,40 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- actioncable (6.1.6.1)
23
- actionpack (= 6.1.6.1)
24
- activesupport (= 6.1.6.1)
22
+ actioncable (6.1.7.2)
23
+ actionpack (= 6.1.7.2)
24
+ activesupport (= 6.1.7.2)
25
25
  nio4r (~> 2.0)
26
26
  websocket-driver (>= 0.6.1)
27
- actionmailbox (6.1.6.1)
28
- actionpack (= 6.1.6.1)
29
- activejob (= 6.1.6.1)
30
- activerecord (= 6.1.6.1)
31
- activestorage (= 6.1.6.1)
32
- activesupport (= 6.1.6.1)
27
+ actionmailbox (6.1.7.2)
28
+ actionpack (= 6.1.7.2)
29
+ activejob (= 6.1.7.2)
30
+ activerecord (= 6.1.7.2)
31
+ activestorage (= 6.1.7.2)
32
+ activesupport (= 6.1.7.2)
33
33
  mail (>= 2.7.1)
34
- actionmailer (6.1.6.1)
35
- actionpack (= 6.1.6.1)
36
- actionview (= 6.1.6.1)
37
- activejob (= 6.1.6.1)
38
- activesupport (= 6.1.6.1)
34
+ actionmailer (6.1.7.2)
35
+ actionpack (= 6.1.7.2)
36
+ actionview (= 6.1.7.2)
37
+ activejob (= 6.1.7.2)
38
+ activesupport (= 6.1.7.2)
39
39
  mail (~> 2.5, >= 2.5.4)
40
40
  rails-dom-testing (~> 2.0)
41
- actionpack (6.1.6.1)
42
- actionview (= 6.1.6.1)
43
- activesupport (= 6.1.6.1)
41
+ actionpack (6.1.7.2)
42
+ actionview (= 6.1.7.2)
43
+ activesupport (= 6.1.7.2)
44
44
  rack (~> 2.0, >= 2.0.9)
45
45
  rack-test (>= 0.6.3)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
48
- actiontext (6.1.6.1)
49
- actionpack (= 6.1.6.1)
50
- activerecord (= 6.1.6.1)
51
- activestorage (= 6.1.6.1)
52
- activesupport (= 6.1.6.1)
48
+ actiontext (6.1.7.2)
49
+ actionpack (= 6.1.7.2)
50
+ activerecord (= 6.1.7.2)
51
+ activestorage (= 6.1.7.2)
52
+ activesupport (= 6.1.7.2)
53
53
  nokogiri (>= 1.8.5)
54
- actionview (6.1.6.1)
55
- activesupport (= 6.1.6.1)
54
+ actionview (6.1.7.2)
55
+ activesupport (= 6.1.7.2)
56
56
  builder (~> 3.1)
57
57
  erubi (~> 1.4)
58
58
  rails-dom-testing (~> 2.0)
@@ -62,22 +62,22 @@ GEM
62
62
  addressable
63
63
  active_median (0.3.3)
64
64
  activesupport (>= 5.2)
65
- activejob (6.1.6.1)
66
- activesupport (= 6.1.6.1)
65
+ activejob (6.1.7.2)
66
+ activesupport (= 6.1.7.2)
67
67
  globalid (>= 0.3.6)
68
- activemodel (6.1.6.1)
69
- activesupport (= 6.1.6.1)
70
- activerecord (6.1.6.1)
71
- activemodel (= 6.1.6.1)
72
- activesupport (= 6.1.6.1)
73
- activestorage (6.1.6.1)
74
- actionpack (= 6.1.6.1)
75
- activejob (= 6.1.6.1)
76
- activerecord (= 6.1.6.1)
77
- activesupport (= 6.1.6.1)
68
+ activemodel (6.1.7.2)
69
+ activesupport (= 6.1.7.2)
70
+ activerecord (6.1.7.2)
71
+ activemodel (= 6.1.7.2)
72
+ activesupport (= 6.1.7.2)
73
+ activestorage (6.1.7.2)
74
+ actionpack (= 6.1.7.2)
75
+ activejob (= 6.1.7.2)
76
+ activerecord (= 6.1.7.2)
77
+ activesupport (= 6.1.7.2)
78
78
  marcel (~> 1.0)
79
79
  mini_mime (>= 1.1.0)
80
- activesupport (6.1.6.1)
80
+ activesupport (6.1.7.2)
81
81
  concurrent-ruby (~> 1.0, >= 1.0.2)
82
82
  i18n (>= 1.6, < 2)
83
83
  minitest (>= 5.1)
@@ -142,7 +142,7 @@ GEM
142
142
  xpath (~> 3.2)
143
143
  chartkick (4.2.1)
144
144
  childprocess (4.1.0)
145
- concurrent-ruby (1.1.10)
145
+ concurrent-ruby (1.2.0)
146
146
  countries (4.2.3)
147
147
  i18n_data (~> 0.16.0)
148
148
  sixarm_ruby_unaccent (~> 1.1)
@@ -157,6 +157,7 @@ GEM
157
157
  activerecord (>= 5.a)
158
158
  database_cleaner-core (~> 2.0.0)
159
159
  database_cleaner-core (2.0.1)
160
+ date (3.3.3)
160
161
  devise (4.8.1)
161
162
  bcrypt (~> 3.0)
162
163
  orm_adapter (~> 0.1)
@@ -171,7 +172,7 @@ GEM
171
172
  railties (>= 3.2)
172
173
  dry-initializer (3.1.1)
173
174
  erb-formatter (0.3.0)
174
- erubi (1.11.0)
175
+ erubi (1.12.0)
175
176
  factory_bot (6.2.1)
176
177
  activesupport (>= 5.0.0)
177
178
  factory_bot_rails (6.2.0)
@@ -186,7 +187,7 @@ GEM
186
187
  rspec-core (~> 3.0)
187
188
  ruby-progressbar (~> 1.4)
188
189
  gem-release (2.2.2)
189
- globalid (1.0.0)
190
+ globalid (1.1.0)
190
191
  activesupport (>= 5.0)
191
192
  groupdate (6.1.0)
192
193
  activesupport (>= 5.2)
@@ -237,8 +238,11 @@ GEM
237
238
  loofah (2.19.1)
238
239
  crass (~> 1.0.2)
239
240
  nokogiri (>= 1.5.9)
240
- mail (2.7.1)
241
+ mail (2.8.0.1)
241
242
  mini_mime (>= 0.1.1)
243
+ net-imap
244
+ net-pop
245
+ net-smtp
242
246
  manifester (0.1.8)
243
247
  rails (>= 6.0)
244
248
  zeitwerk
@@ -249,19 +253,24 @@ GEM
249
253
  method_source (1.0.0)
250
254
  mini_magick (4.12.0)
251
255
  mini_mime (1.1.2)
252
- mini_portile2 (2.8.0)
256
+ mini_portile2 (2.8.1)
253
257
  minitest (5.17.0)
254
258
  msgpack (1.5.6)
255
259
  multi_xml (0.6.0)
260
+ net-imap (0.3.4)
261
+ date
262
+ net-protocol
263
+ net-pop (0.1.2)
264
+ net-protocol
256
265
  net-protocol (0.1.3)
257
266
  timeout
258
267
  net-smtp (0.3.3)
259
268
  net-protocol
260
269
  nio4r (2.5.8)
261
- nokogiri (1.13.10)
270
+ nokogiri (1.14.1)
262
271
  mini_portile2 (~> 2.8.0)
263
272
  racc (~> 1.4)
264
- nokogiri (1.13.10-x86_64-linux)
273
+ nokogiri (1.14.1-x86_64-linux)
265
274
  racc (~> 1.4)
266
275
  orm_adapter (0.5.0)
267
276
  pagy (6.0.1)
@@ -274,24 +283,24 @@ GEM
274
283
  nio4r (~> 2.0)
275
284
  pundit (2.2.0)
276
285
  activesupport (>= 3.0.0)
277
- racc (1.6.1)
278
- rack (2.2.5)
286
+ racc (1.6.2)
287
+ rack (2.2.6.2)
279
288
  rack-test (2.0.2)
280
289
  rack (>= 1.3)
281
- rails (6.1.6.1)
282
- actioncable (= 6.1.6.1)
283
- actionmailbox (= 6.1.6.1)
284
- actionmailer (= 6.1.6.1)
285
- actionpack (= 6.1.6.1)
286
- actiontext (= 6.1.6.1)
287
- actionview (= 6.1.6.1)
288
- activejob (= 6.1.6.1)
289
- activemodel (= 6.1.6.1)
290
- activerecord (= 6.1.6.1)
291
- activestorage (= 6.1.6.1)
292
- activesupport (= 6.1.6.1)
290
+ rails (6.1.7.2)
291
+ actioncable (= 6.1.7.2)
292
+ actionmailbox (= 6.1.7.2)
293
+ actionmailer (= 6.1.7.2)
294
+ actionpack (= 6.1.7.2)
295
+ actiontext (= 6.1.7.2)
296
+ actionview (= 6.1.7.2)
297
+ activejob (= 6.1.7.2)
298
+ activemodel (= 6.1.7.2)
299
+ activerecord (= 6.1.7.2)
300
+ activestorage (= 6.1.7.2)
301
+ activesupport (= 6.1.7.2)
293
302
  bundler (>= 1.15.0)
294
- railties (= 6.1.6.1)
303
+ railties (= 6.1.7.2)
295
304
  sprockets-rails (>= 2.0.0)
296
305
  rails-controller-testing (1.0.5)
297
306
  actionpack (>= 5.0.1.rc1)
@@ -300,14 +309,14 @@ GEM
300
309
  rails-dom-testing (2.0.3)
301
310
  activesupport (>= 4.2.0)
302
311
  nokogiri (>= 1.6)
303
- rails-html-sanitizer (1.4.4)
312
+ rails-html-sanitizer (1.5.0)
304
313
  loofah (~> 2.19, >= 2.19.1)
305
314
  rails-i18n (7.0.5)
306
315
  i18n (>= 0.7, < 2)
307
316
  railties (>= 6.0.0, < 8)
308
- railties (6.1.6.1)
309
- actionpack (= 6.1.6.1)
310
- activesupport (= 6.1.6.1)
317
+ railties (6.1.7.2)
318
+ actionpack (= 6.1.7.2)
319
+ activesupport (= 6.1.7.2)
311
320
  method_source
312
321
  rake (>= 12.2)
313
322
  thor (~> 1.0)
@@ -404,7 +413,7 @@ GEM
404
413
  actionpack (>= 6.0.0)
405
414
  activejob (>= 6.0.0)
406
415
  railties (>= 6.0.0)
407
- tzinfo (2.0.5)
416
+ tzinfo (2.0.6)
408
417
  concurrent-ruby (~> 1.0)
409
418
  unicode-display_width (2.4.0)
410
419
  view_component (2.82.0)
@@ -431,7 +440,7 @@ GEM
431
440
  websocket-extensions (0.1.5)
432
441
  xpath (3.2.0)
433
442
  nokogiri (~> 1.8)
434
- zeitwerk (2.6.2)
443
+ zeitwerk (2.6.6)
435
444
 
436
445
  PLATFORMS
437
446
  ruby
@@ -128,11 +128,7 @@ module Avo
128
128
  end
129
129
 
130
130
  def set_model
131
- @model = model_find_scope.find record_id
132
- end
133
-
134
- def record_id
135
- params.permit(:id).dig(:id)
131
+ @model = model_find_scope.find params[:id]
136
132
  end
137
133
 
138
134
  def model_find_scope
@@ -1,6 +1,6 @@
1
- <style>
1
+ <%= content_tag(:style, nonce: content_security_policy_nonce) do %>
2
2
  :root {
3
3
  <%= Avo.configuration.branding.css_colors %>
4
4
  }
5
- </style>
5
+ <% end %>
6
6
  <%= favicon_link_tag Avo.configuration.branding.favicon %>
data/db/factories.rb CHANGED
@@ -31,7 +31,7 @@ FactoryBot.define do
31
31
 
32
32
  factory :project do
33
33
  name { Faker::App.name }
34
- status { [:closed, :rejected, :failed, :loading, :running, :waiting].sample }
34
+ status { ['closed', :rejected, :failed, 'loading', :running, :waiting].sample }
35
35
  stage { ["Discovery", "Idea", "Done", "On hold", "Cancelled"].sample }
36
36
  budget { Faker::Number.decimal(l_digits: 4) }
37
37
  country { Faker::Address.country_code }
data/lib/avo/base_card.rb CHANGED
@@ -89,7 +89,6 @@ module Avo
89
89
  5 => " h-[45rem]",
90
90
  6 => " h-[54rem]"
91
91
  }
92
- # puts ["cols->", cols, classes_for_cols, classes_for_rows, classes_for_cols[cols.to_i]].inspect
93
92
 
94
93
  result += classes_for_cols[cols.to_i] if classes_for_cols[cols.to_i].present?
95
94
  result += classes_for_rows[rows.to_i] if classes_for_rows[rows.to_i].present?
@@ -98,9 +97,9 @@ module Avo
98
97
  end
99
98
 
100
99
  def type
101
- return :metric if self.class.superclass == ::Avo::Dashboards::MetricCard
102
- return :chartkick if self.class.superclass == ::Avo::Dashboards::ChartkickCard
103
- return :partial if self.class.superclass == ::Avo::Dashboards::PartialCard
100
+ return :metric if is_a?(::Avo::Dashboards::MetricCard)
101
+ return :chartkick if is_a?(::Avo::Dashboards::ChartkickCard)
102
+ return :partial if is_a?(::Avo::Dashboards::PartialCard)
104
103
  end
105
104
 
106
105
  def compute_result
@@ -4,8 +4,8 @@ module Avo
4
4
  def initialize(id, **args, &block)
5
5
  super(id, **args, &block)
6
6
 
7
- @loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten : [:waiting, :running]
8
- @failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten : [:failed]
7
+ @loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten.map(&:to_sym) : [:waiting, :running]
8
+ @failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten.map(&:to_sym) : [:failed]
9
9
  end
10
10
 
11
11
  def status
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.24.1" unless const_defined?(:VERSION)
2
+ VERSION = "2.26.0" unless const_defined?(:VERSION)
3
3
  end
@@ -18,19 +18,19 @@ module Generators
18
18
  end
19
19
 
20
20
  def resource_class
21
- "#{class_name}Resource"
21
+ "#{class_name.remove(":")}Resource"
22
22
  end
23
23
 
24
24
  def controller_class
25
- "Avo::#{class_name.camelize.pluralize}Controller"
25
+ "Avo::#{class_name.remove(":").pluralize}Controller"
26
26
  end
27
27
 
28
28
  def resource_name
29
- "#{singular_name}_resource"
29
+ "#{model_resource_name}_resource"
30
30
  end
31
31
 
32
32
  def controller_name
33
- "#{plural_name}_controller"
33
+ "#{model_resource_name.pluralize}_controller"
34
34
  end
35
35
 
36
36
  def current_models
@@ -40,11 +40,13 @@ module Generators
40
40
  end
41
41
 
42
42
  def class_from_args
43
- @class_from_args ||= options["model-class"]&.capitalize
43
+ @class_from_args ||= options["model-class"]&.camelize || (class_name if class_name.include?("::"))
44
44
  end
45
45
 
46
46
  def model_class_from_args
47
- "\n self.model_class = ::#{class_from_args}" if class_from_args.present?
47
+ if class_from_args.present? || class_name.include?("::")
48
+ "\n self.model_class = ::#{class_from_args || class_name}"
49
+ end
48
50
  end
49
51
 
50
52
  private
@@ -58,7 +60,7 @@ module Generators
58
60
  end
59
61
 
60
62
  def model_db_columns
61
- @model_db_columns ||= model.columns_hash.reject { |name, _| db_columns_to_ignore.include? name }
63
+ @model_db_columns ||= model.columns_hash.except(*db_columns_to_ignore)
62
64
  end
63
65
 
64
66
  def db_columns_to_ignore
@@ -155,14 +157,30 @@ module Generators
155
157
 
156
158
  def fields_from_model_associations
157
159
  associations.each do |name, association|
158
- fields[name] = associations_mapping[association.class]
159
-
160
- if association.is_a? ActiveRecord::Reflection::ThroughReflection
161
- fields[name][:options][:through] = ":#{association.options[:through]}"
160
+ fields[name] = if association.is_a? ActiveRecord::Reflection::ThroughReflection
161
+ field_from_through_association(association)
162
+ else
163
+ associations_mapping[association.class]
162
164
  end
163
165
  end
164
166
  end
165
167
 
168
+ def field_from_through_association(association)
169
+ if association.through_reflection.is_a? ActiveRecord::Reflection::HasManyReflection
170
+ {
171
+ field: "has_many",
172
+ options: {
173
+ through: ":#{association.options[:through]}"
174
+ }
175
+ }
176
+ else
177
+ # If the through_reflection is not a HasManyReflection, add it to the fields hash using the class of the through_reflection
178
+ # ex (team.rb): has_one :admin, through: :admin_membership, source: :user
179
+ # we use the class of the through_reflection (HasOneReflection -> has_one :admin) to generate the field
180
+ associations_mapping[association.through_reflection.class]
181
+ end
182
+ end
183
+
166
184
  def fields_from_model_attachements
167
185
  attachments.each do |name, attachment|
168
186
  fields[remove_last_word_from name] = attachments_mapping[attachment.class]
@@ -210,12 +228,6 @@ module Generators
210
228
  ActiveRecord::Reflection::HasManyReflection => {
211
229
  field: "has_many"
212
230
  },
213
- ActiveRecord::Reflection::ThroughReflection => {
214
- field: "has_many",
215
- options: {
216
- through: ":..."
217
- }
218
- },
219
231
  ActiveRecord::Reflection::HasAndBelongsToManyReflection => {
220
232
  field: "has_and_belongs_to_many"
221
233
  }
@@ -17,7 +17,8 @@ Avo.configure do |config|
17
17
 
18
18
  ## == Authentication ==
19
19
  # config.current_user_method = {}
20
- # config.authenticate_with = {}
20
+ # config.authenticate_with do
21
+ # end
21
22
 
22
23
  ## == Authorization ==
23
24
  # config.authorization_methods = {
@@ -76,8 +77,9 @@ Avo.configure do |config|
76
77
  # },
77
78
  # chart_colors: ["#0B8AE2", "#34C683", "#2AB1EE", "#34C6A8"],
78
79
  # logo: "/avo-assets/logo.png",
79
- # logomark: "/avo-assets/logomark.png"
80
- # placeholder: "/avo-assets/placeholder.svg"
80
+ # logomark: "/avo-assets/logomark.png",
81
+ # placeholder: "/avo-assets/placeholder.svg",
82
+ # favicon: "/avo-assets/favicon.ico"
81
83
  # }
82
84
 
83
85
  ## == Breadcrumbs ==
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.24.1
4
+ version: 2.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-20 00:00:00.000000000 Z
12
+ date: 2023-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord