avo 2.18.1 → 2.20.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.

Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -6
  3. data/Gemfile.lock +76 -77
  4. data/app/components/avo/actions_component.html.erb +1 -1
  5. data/app/components/avo/actions_component.rb +4 -4
  6. data/app/components/avo/base_component.rb +17 -0
  7. data/app/components/avo/card_component.html.erb +15 -15
  8. data/app/components/avo/card_component.rb +7 -5
  9. data/app/components/avo/field_wrapper_component.rb +7 -1
  10. data/app/components/avo/fields/has_one_field/show_component.rb +1 -2
  11. data/app/components/avo/fields/index_component.rb +4 -3
  12. data/app/components/avo/fields/select_field/edit_component.html.erb +1 -1
  13. data/app/components/avo/filters_component.html.erb +1 -1
  14. data/app/components/avo/filters_component.rb +2 -2
  15. data/app/components/avo/index/grid_item_component.rb +2 -2
  16. data/app/components/avo/index/resource_controls_component.rb +2 -2
  17. data/app/components/avo/index/table_row_component.html.erb +1 -1
  18. data/app/components/avo/item_switcher_component.html.erb +1 -1
  19. data/app/components/avo/panel_component.html.erb +1 -1
  20. data/app/components/avo/resource_component.rb +1 -1
  21. data/app/components/avo/resource_sidebar_component.rb +1 -6
  22. data/app/components/avo/sidebar/group_component.html.erb +18 -12
  23. data/app/components/avo/sidebar/heading_component.html.erb +17 -10
  24. data/app/components/avo/sidebar_profile_component.rb +3 -1
  25. data/app/components/avo/tab_group_component.rb +1 -1
  26. data/app/components/avo/views/resource_show_component.html.erb +1 -1
  27. data/app/controllers/avo/actions_controller.rb +27 -5
  28. data/app/controllers/avo/application_controller.rb +7 -0
  29. data/app/controllers/avo/base_controller.rb +30 -18
  30. data/app/controllers/avo/dashboards/cards_controller.rb +37 -0
  31. data/app/controllers/avo/dashboards_controller.rb +1 -0
  32. data/app/helpers/avo/application_helper.rb +5 -1
  33. data/app/javascript/js/controllers/search_controller.js +11 -2
  34. data/app/views/avo/actions/keep_modal_open.turbo_stream.erb +5 -0
  35. data/app/views/avo/actions/show.html.erb +2 -1
  36. data/app/views/avo/{cards → dashboards/cards}/_chartkick_card.html.erb +0 -0
  37. data/app/views/avo/{cards → dashboards/cards}/_metric_card.html.erb +0 -0
  38. data/app/views/avo/{cards → dashboards/cards}/chartkick_missing.html.erb +0 -0
  39. data/app/views/avo/{cards → dashboards/cards}/show.html.erb +0 -0
  40. data/app/views/avo/partials/_branding.html.erb +1 -0
  41. data/app/views/layouts/avo/application.html.erb +1 -1
  42. data/avo.gemspec +1 -2
  43. data/bin/init +11 -1
  44. data/bin/test +1 -0
  45. data/config/routes.rb +2 -2
  46. data/db/factories.rb +10 -0
  47. data/lib/avo/app.rb +14 -1
  48. data/lib/avo/base_action.rb +35 -10
  49. data/lib/avo/base_card.rb +3 -1
  50. data/lib/avo/base_resource.rb +21 -10
  51. data/lib/avo/concerns/breadcrumbs.rb +96 -0
  52. data/lib/avo/concerns/filters_session_handler.rb +43 -0
  53. data/lib/avo/concerns/has_fields.rb +2 -0
  54. data/lib/avo/concerns/has_html_attributes.rb +14 -16
  55. data/lib/avo/concerns/visible_items.rb +44 -0
  56. data/lib/avo/configuration/branding.rb +10 -2
  57. data/lib/avo/configuration.rb +3 -0
  58. data/lib/avo/dashboards/base_dashboard.rb +7 -1
  59. data/lib/avo/dynamic_router.rb +16 -15
  60. data/lib/avo/engine.rb +6 -9
  61. data/lib/avo/fields/base_field.rb +21 -12
  62. data/lib/avo/fields/concerns/has_default.rb +17 -0
  63. data/lib/avo/fields/concerns/is_readonly.rb +1 -1
  64. data/lib/avo/fields/concerns/is_required.rb +2 -2
  65. data/lib/avo/fields/has_base_field.rb +2 -0
  66. data/lib/avo/fields/key_value_field.rb +1 -1
  67. data/lib/avo/fields/select_field.rb +39 -34
  68. data/lib/avo/filters/base_filter.rb +24 -2
  69. data/lib/avo/hosts/resource_view_record_host.rb +7 -0
  70. data/lib/avo/hosts/visibility_host.rb +13 -0
  71. data/lib/avo/panel.rb +4 -1
  72. data/lib/avo/resources/controls/action.rb +1 -3
  73. data/lib/avo/sidebar.rb +1 -31
  74. data/lib/avo/tab.rb +5 -22
  75. data/lib/avo/version.rb +1 -1
  76. data/lib/avo.rb +9 -0
  77. data/lib/generators/avo/resource_generator.rb +281 -0
  78. data/lib/generators/avo/templates/action.tt +3 -0
  79. data/lib/generators/avo/templates/filters/boolean_filter.tt +3 -0
  80. data/lib/generators/avo/templates/filters/multiple_select_filter.tt +3 -0
  81. data/lib/generators/avo/templates/filters/select_filter.tt +3 -0
  82. data/lib/generators/avo/templates/filters/text_filter.tt +3 -0
  83. data/lib/generators/avo/templates/initializer/avo.tt +4 -0
  84. data/lib/generators/avo/templates/resource/controller.tt +1 -1
  85. data/lib/generators/avo/templates/resource/resource.tt +2 -2
  86. data/lib/generators/model_generator.rb +10 -0
  87. data/lib/generators/rails/avo_resource_generator.rb +11 -0
  88. data/public/avo-assets/avo.base.css +14 -14
  89. data/public/avo-assets/avo.base.js +1 -1
  90. data/public/avo-assets/avo.base.js.map +2 -2
  91. data/public/avo-assets/favicon.ico +0 -0
  92. data/{app/assets/svgs → public/avo-assets}/placeholder.svg +0 -0
  93. metadata +20 -25
  94. data/app/controllers/avo/cards_controller.rb +0 -35
  95. data/config/master.key +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7079bc6f71897afdcc083d49d88255d5a3e903e130a9c054e069976dc9038bc0
4
- data.tar.gz: c618bf337578ddc521f6be2c92eb1c1bfc76f4e7956c5f4a7393e31326f49f02
3
+ metadata.gz: 032f3c926677645e9939a30205693425f4c44c4db874d7e30849c600e13be8a1
4
+ data.tar.gz: 110d46843bf447a9e1a1215e3d4e17e4c8bf64ca4f88889d72a504c6b9cef06e
5
5
  SHA512:
6
- metadata.gz: 7b32f335e16778be0647bd74c1579f5842d01b74c836655040d165e64bcb5325a7f23b43bb01a31f455af6f58ae3ecac968cb301e8737d4d36734f2ea1d88dcd
7
- data.tar.gz: c9a37f010a3b138f64f7f10d31b077a94f06d48539bffb635f6b6e0d35d2d56b76d2b25cd34e31e189fbf72911a91b52910bb341391a13edff6b6c79cac3c48f
6
+ metadata.gz: feed3402af12295a712d16f45ced2248c6fcb0663cdad1d4e3b160f9d706e26322ce2966f64f1f6d0fe622f13f2019be8b12d8c16afa7f009ddefe175fd0a7f5
7
+ data.tar.gz: 28c50de8194d7c649b2c629c988511f1470b00dbaa5d7a60013f743959fecff0b7e97e5c5383548552e412bdea05b9224910c38d681ddbefea25116ade529145
data/Gemfile CHANGED
@@ -21,7 +21,7 @@ gem 'cssbundling-rails'
21
21
  # Dependencies for dummy_app
22
22
  #
23
23
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
24
- # gem "rails", "~> 6.1.0"
24
+ gem "rails", "~> 6.1.0"
25
25
 
26
26
  # Use postgresql as the database for Active Record
27
27
  gem "pg", ">= 0.18", "< 2.0"
@@ -102,14 +102,12 @@ group :test do
102
102
  gem "launchy", require: false
103
103
 
104
104
  gem "test-prof"
105
-
106
- gem "sprockets-rails"
107
105
  end
108
106
 
109
107
  gem "rubocop"
110
108
  gem "rubocop-shopify", require: false
111
109
 
112
- gem "zeitwerk", "~> 2.3"
110
+ gem "zeitwerk"
113
111
 
114
112
  gem "httparty"
115
113
 
@@ -123,8 +121,6 @@ gem "appraisal"
123
121
 
124
122
  gem 'meta-tags'
125
123
 
126
- gem 'breadcrumbs_on_rails'
127
-
128
124
  gem 'manifester'
129
125
 
130
126
  # Search
@@ -160,6 +156,8 @@ gem "chartkick"
160
156
 
161
157
  # Avo file filed requires this gem
162
158
  gem "activestorage"
159
+ # Required by Avo
160
+ gem "sprockets-rails"
163
161
 
164
162
  # Avo file filed requires this gem
165
163
  # Use Active Storage variant
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.18.1)
4
+ avo (2.20.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
8
8
  addressable
9
- breadcrumbs_on_rails
10
9
  docile
11
10
  dry-initializer
12
11
  httparty
@@ -15,7 +14,7 @@ PATH
15
14
  pagy
16
15
  turbo-rails
17
16
  view_component
18
- zeitwerk
17
+ zeitwerk (>= 2.6.2)
19
18
 
20
19
  GEM
21
20
  remote: https://rubygems.org/
@@ -88,8 +87,8 @@ GEM
88
87
  activerecord (>= 6.0, < 7.1)
89
88
  acts_as_list (1.0.4)
90
89
  activerecord (>= 4.2)
91
- addressable (2.8.0)
92
- public_suffix (>= 2.0.2, < 5.0)
90
+ addressable (2.8.1)
91
+ public_suffix (>= 2.0.2, < 6.0)
93
92
  annotate (3.2.0)
94
93
  activerecord (>= 3.2, < 8.0)
95
94
  rake (>= 10.4, < 14.0)
@@ -100,22 +99,22 @@ GEM
100
99
  ast (2.4.2)
101
100
  awesome_print (1.9.2)
102
101
  aws-eventstream (1.2.0)
103
- aws-partitions (1.551.0)
104
- aws-sdk-core (3.125.5)
102
+ aws-partitions (1.621.0)
103
+ aws-sdk-core (3.134.0)
105
104
  aws-eventstream (~> 1, >= 1.0.2)
106
105
  aws-partitions (~> 1, >= 1.525.0)
107
106
  aws-sigv4 (~> 1.1)
108
- jmespath (~> 1.0)
109
- aws-sdk-kms (1.53.0)
110
- aws-sdk-core (~> 3, >= 3.125.0)
107
+ jmespath (~> 1, >= 1.6.1)
108
+ aws-sdk-kms (1.58.0)
109
+ aws-sdk-core (~> 3, >= 3.127.0)
111
110
  aws-sigv4 (~> 1.1)
112
- aws-sdk-s3 (1.111.3)
113
- aws-sdk-core (~> 3, >= 3.125.0)
111
+ aws-sdk-s3 (1.114.0)
112
+ aws-sdk-core (~> 3, >= 3.127.0)
114
113
  aws-sdk-kms (~> 1)
115
114
  aws-sigv4 (~> 1.4)
116
- aws-sigv4 (1.4.0)
115
+ aws-sigv4 (1.5.1)
117
116
  aws-eventstream (~> 1, >= 1.0.2)
118
- bcrypt (3.1.16)
117
+ bcrypt (3.1.18)
119
118
  better_html (2.0.1)
120
119
  actionview (>= 6.0)
121
120
  activesupport (>= 6.0)
@@ -127,11 +126,9 @@ GEM
127
126
  bootsnap (1.13.0)
128
127
  msgpack (~> 1.2)
129
128
  brakeman (5.3.1)
130
- breadcrumbs_on_rails (4.1.0)
131
- railties (>= 5.0)
132
129
  builder (3.2.4)
133
130
  bump (0.10.0)
134
- bundler-integrity (1.0.7)
131
+ bundler-integrity (1.0.9)
135
132
  byebug (11.1.3)
136
133
  capybara (3.36.0)
137
134
  addressable
@@ -150,7 +147,7 @@ GEM
150
147
  crack (0.4.5)
151
148
  rexml
152
149
  crass (1.0.6)
153
- cssbundling-rails (1.0.0)
150
+ cssbundling-rails (1.1.1)
154
151
  railties (>= 6.0.0)
155
152
  database_cleaner (2.0.1)
156
153
  database_cleaner-active_record (~> 2.0.0)
@@ -167,20 +164,20 @@ GEM
167
164
  diff-lcs (1.5.0)
168
165
  digest (3.1.0)
169
166
  docile (1.4.0)
170
- dotenv (2.7.6)
171
- dotenv-rails (2.7.6)
172
- dotenv (= 2.7.6)
167
+ dotenv (2.8.1)
168
+ dotenv-rails (2.8.1)
169
+ dotenv (= 2.8.1)
173
170
  railties (>= 3.2)
174
171
  dry-initializer (3.1.1)
175
172
  erb-formatter (0.3.0)
176
173
  erubi (1.11.0)
177
- factory_bot (6.2.0)
174
+ factory_bot (6.2.1)
178
175
  activesupport (>= 5.0.0)
179
176
  factory_bot_rails (6.2.0)
180
177
  factory_bot (~> 6.2.0)
181
178
  railties (>= 5.0.0)
182
- faker (2.19.0)
183
- i18n (>= 1.6, < 2)
179
+ faker (2.22.0)
180
+ i18n (>= 1.8.11, < 2)
184
181
  ffi (1.15.5)
185
182
  friendly_id (5.4.2)
186
183
  activerecord (>= 4.0.0)
@@ -190,16 +187,16 @@ GEM
190
187
  gem-release (2.2.2)
191
188
  globalid (1.0.0)
192
189
  activesupport (>= 5.0)
193
- groupdate (5.2.4)
194
- activesupport (>= 5)
190
+ groupdate (6.1.0)
191
+ activesupport (>= 5.2)
195
192
  hashdiff (1.0.1)
196
193
  highline (2.0.3)
197
194
  hightop (0.3.0)
198
195
  activesupport (>= 5.2)
199
- hotwire-livereload (1.1.0)
196
+ hotwire-livereload (1.2.2)
200
197
  listen (>= 3.0.0)
201
198
  rails (>= 6.0.0)
202
- htmlbeautifier (1.4.1)
199
+ htmlbeautifier (1.4.2)
203
200
  httparty (0.20.0)
204
201
  mime-types (~> 3.0)
205
202
  multi_xml (>= 0.5.2)
@@ -222,12 +219,12 @@ GEM
222
219
  inline_svg (1.8.0)
223
220
  activesupport (>= 3.0)
224
221
  nokogiri (>= 1.6)
225
- io-wait (0.2.1)
226
222
  iso (0.4.0)
227
223
  i18n
228
224
  jmespath (1.6.1)
229
- jsbundling-rails (1.0.0)
225
+ jsbundling-rails (1.0.3)
230
226
  railties (>= 6.0.0)
227
+ json (2.6.2)
231
228
  launchy (2.5.0)
232
229
  addressable (~> 2.7)
233
230
  listen (3.7.1)
@@ -243,7 +240,7 @@ GEM
243
240
  zeitwerk
244
241
  marcel (1.0.2)
245
242
  matrix (0.4.2)
246
- meta-tags (2.16.0)
243
+ meta-tags (2.17.0)
247
244
  actionpack (>= 3.2.0, < 7.1)
248
245
  method_source (1.0.0)
249
246
  mime-types (3.4.1)
@@ -253,10 +250,9 @@ GEM
253
250
  mini_mime (1.1.2)
254
251
  mini_portile2 (2.8.0)
255
252
  minitest (5.16.3)
256
- msgpack (1.6.0)
253
+ msgpack (1.5.6)
257
254
  multi_xml (0.6.0)
258
- net-protocol (0.1.2)
259
- io-wait
255
+ net-protocol (0.1.3)
260
256
  timeout
261
257
  net-smtp (0.3.1)
262
258
  digest
@@ -271,12 +267,12 @@ GEM
271
267
  orm_adapter (0.5.0)
272
268
  pagy (5.10.1)
273
269
  activesupport
274
- parallel (1.21.0)
275
- parser (3.1.0.0)
270
+ parallel (1.22.1)
271
+ parser (3.1.2.1)
276
272
  ast (~> 2.4.1)
277
- pg (1.3.1)
278
- public_suffix (4.0.6)
279
- puma (5.6.4)
273
+ pg (1.4.3)
274
+ public_suffix (5.0.0)
275
+ puma (5.6.5)
280
276
  nio4r (~> 2.0)
281
277
  pundit (2.2.0)
282
278
  activesupport (>= 3.0.0)
@@ -319,27 +315,27 @@ GEM
319
315
  thor (~> 1.0)
320
316
  rainbow (3.1.1)
321
317
  rake (13.0.6)
322
- ransack (2.5.0)
323
- activerecord (>= 5.2.4)
324
- activesupport (>= 5.2.4)
318
+ ransack (3.2.1)
319
+ activerecord (>= 6.1.5)
320
+ activesupport (>= 6.1.5)
325
321
  i18n
326
- rb-fsevent (0.11.0)
322
+ rb-fsevent (0.11.1)
327
323
  rb-inotify (0.10.1)
328
324
  ffi (~> 1.0)
329
- redis (4.6.0)
330
- regexp_parser (2.2.0)
325
+ redis (4.8.0)
326
+ regexp_parser (2.5.0)
331
327
  responders (3.0.1)
332
328
  actionpack (>= 5.0)
333
329
  railties (>= 5.0)
334
330
  rexml (3.2.5)
335
- rspec-core (3.10.2)
336
- rspec-support (~> 3.10.0)
337
- rspec-expectations (3.10.2)
331
+ rspec-core (3.11.0)
332
+ rspec-support (~> 3.11.0)
333
+ rspec-expectations (3.11.0)
338
334
  diff-lcs (>= 1.2.0, < 2.0)
339
- rspec-support (~> 3.10.0)
340
- rspec-mocks (3.10.3)
335
+ rspec-support (~> 3.11.0)
336
+ rspec-mocks (3.11.1)
341
337
  diff-lcs (>= 1.2.0, < 2.0)
342
- rspec-support (~> 3.10.0)
338
+ rspec-support (~> 3.11.0)
343
339
  rspec-rails (4.0.2)
344
340
  actionpack (>= 4.2)
345
341
  activesupport (>= 4.2)
@@ -348,33 +344,35 @@ GEM
348
344
  rspec-expectations (~> 3.10)
349
345
  rspec-mocks (~> 3.10)
350
346
  rspec-support (~> 3.10)
351
- rspec-support (3.10.3)
352
- rubocop (1.25.0)
347
+ rspec-support (3.11.0)
348
+ rubocop (1.35.0)
349
+ json (~> 2.3)
353
350
  parallel (~> 1.10)
354
- parser (>= 3.1.0.0)
351
+ parser (>= 3.1.2.1)
355
352
  rainbow (>= 2.2.2, < 4.0)
356
353
  regexp_parser (>= 1.8, < 3.0)
357
- rexml
358
- rubocop-ast (>= 1.15.1, < 2.0)
354
+ rexml (>= 3.2.5, < 4.0)
355
+ rubocop-ast (>= 1.20.1, < 2.0)
359
356
  ruby-progressbar (~> 1.7)
360
357
  unicode-display_width (>= 1.4.0, < 3.0)
361
- rubocop-ast (1.15.1)
362
- parser (>= 3.0.1.1)
363
- rubocop-performance (1.13.2)
358
+ rubocop-ast (1.21.0)
359
+ parser (>= 3.1.1.0)
360
+ rubocop-performance (1.14.3)
364
361
  rubocop (>= 1.7.0, < 2.0)
365
362
  rubocop-ast (>= 0.4.0)
366
- rubocop-shopify (2.5.0)
367
- rubocop (~> 1.25)
363
+ rubocop-shopify (2.9.0)
364
+ rubocop (~> 1.33)
368
365
  ruby-debug-ide (0.7.3)
369
366
  rake (>= 0.8.1)
370
367
  ruby-progressbar (1.11.0)
371
368
  ruby-vips (2.1.4)
372
369
  ffi (~> 1.12)
373
370
  rubyzip (2.3.2)
374
- selenium-webdriver (4.1.0)
371
+ selenium-webdriver (4.5.0)
375
372
  childprocess (>= 0.5, < 5.0)
376
373
  rexml (~> 3.2, >= 3.2.5)
377
- rubyzip (>= 1.2.2)
374
+ rubyzip (>= 1.2.2, < 3.0)
375
+ websocket (~> 1.0)
378
376
  simplecov (0.21.2)
379
377
  docile (~> 1.1)
380
378
  simplecov-html (~> 0.11)
@@ -383,7 +381,7 @@ GEM
383
381
  rexml
384
382
  simplecov (~> 0.19)
385
383
  simplecov-html (0.12.3)
386
- simplecov_json_formatter (0.1.3)
384
+ simplecov_json_formatter (0.1.4)
387
385
  sixarm_ruby_unaccent (1.2.0)
388
386
  smart_properties (1.17.0)
389
387
  spring (4.0.0)
@@ -396,22 +394,22 @@ GEM
396
394
  actionpack (>= 5.2)
397
395
  activesupport (>= 5.2)
398
396
  sprockets (>= 3.0.0)
399
- standard (1.7.0)
400
- rubocop (= 1.25.0)
401
- rubocop-performance (= 1.13.2)
397
+ standard (1.16.0)
398
+ rubocop (= 1.35.0)
399
+ rubocop-performance (= 1.14.3)
402
400
  terminal-table (3.0.2)
403
401
  unicode-display_width (>= 1.1.1, < 3)
404
- test-prof (1.0.7)
402
+ test-prof (1.0.10)
405
403
  thor (1.2.1)
406
- timeout (0.2.0)
404
+ timeout (0.3.0)
407
405
  turbo-rails (1.3.2)
408
406
  actionpack (>= 6.0.0)
409
407
  activejob (>= 6.0.0)
410
408
  railties (>= 6.0.0)
411
409
  tzinfo (2.0.5)
412
410
  concurrent-ruby (~> 1.0)
413
- unicode-display_width (2.1.0)
414
- view_component (2.74.1)
411
+ unicode-display_width (2.2.0)
412
+ view_component (2.77.0)
415
413
  activesupport (>= 5.0.0, < 8.0)
416
414
  concurrent-ruby (~> 1.0)
417
415
  method_source (~> 1.0)
@@ -422,20 +420,21 @@ GEM
422
420
  activemodel (>= 6.0.0)
423
421
  bindex (>= 0.4.0)
424
422
  railties (>= 6.0.0)
425
- webdrivers (5.0.0)
423
+ webdrivers (5.2.0)
426
424
  nokogiri (~> 1.6)
427
425
  rubyzip (>= 1.3.0)
428
426
  selenium-webdriver (~> 4.0)
429
- webmock (3.14.0)
427
+ webmock (3.18.1)
430
428
  addressable (>= 2.8.0)
431
429
  crack (>= 0.3.2)
432
430
  hashdiff (>= 0.4.0, < 2.0.0)
431
+ websocket (1.2.9)
433
432
  websocket-driver (0.7.5)
434
433
  websocket-extensions (>= 0.1.0)
435
434
  websocket-extensions (0.1.5)
436
435
  xpath (3.2.0)
437
436
  nokogiri (~> 1.8)
438
- zeitwerk (2.6.0)
437
+ zeitwerk (2.6.2)
439
438
 
440
439
  PLATFORMS
441
440
  ruby
@@ -455,7 +454,6 @@ DEPENDENCIES
455
454
  aws-sdk-s3
456
455
  bootsnap (>= 1.4.2)
457
456
  brakeman
458
- breadcrumbs_on_rails
459
457
  bump
460
458
  bundler-integrity (~> 1.0)
461
459
  byebug
@@ -489,6 +487,7 @@ DEPENDENCIES
489
487
  pg (>= 0.18, < 2.0)
490
488
  puma (~> 5.6.4)
491
489
  pundit
490
+ rails (~> 6.1.0)
492
491
  rails-controller-testing
493
492
  ransack
494
493
  redis (~> 4.0)
@@ -508,7 +507,7 @@ DEPENDENCIES
508
507
  web-console (>= 3.3.0)
509
508
  webdrivers
510
509
  webmock
511
- zeitwerk (~> 2.3)
510
+ zeitwerk
512
511
 
513
512
  BUNDLED WITH
514
- 2.3.23
513
+ 2.3.24
@@ -11,7 +11,7 @@
11
11
  icon_class: 'transform rotate-90',
12
12
  'data-action': "click->toggle-panel#togglePanel",
13
13
  'data-actions-dropdown-button': @resource.model_key do %>
14
- <%= t 'avo.actions' %>
14
+ <%= label %>
15
15
  <% end %>
16
16
  <div
17
17
  class="absolute flex inset-auto xl:right-0 top-full bg-white w-full sm:w-auto sm:min-w-[300px] mt-2 z-40 shadow-modal rounded overflow-hidden hidden"
@@ -2,14 +2,16 @@
2
2
 
3
3
  class Avo::ActionsComponent < ViewComponent::Base
4
4
  include Avo::ApplicationHelper
5
+ attr_reader :label
5
6
 
6
- def initialize(actions: [], resource: nil, view: nil, exclude: [], style: :outline, color: :primary)
7
+ def initialize(actions: [], resource: nil, view: nil, exclude: [], style: :outline, color: :primary, label: nil)
7
8
  @actions = actions || []
8
9
  @resource = resource
9
10
  @view = view
10
11
  @exclude = exclude
11
12
  @color = color
12
13
  @style = style
14
+ @label = label || t("avo.actions")
13
15
  end
14
16
 
15
17
  def render?
@@ -17,9 +19,7 @@ class Avo::ActionsComponent < ViewComponent::Base
17
19
  end
18
20
 
19
21
  def actions
20
- @actions.select do |action|
21
- !action.class.in?(@exclude)
22
- end
22
+ @actions.reject { |action| action.class.in?(@exclude) }
23
23
  end
24
24
 
25
25
  # When running an action for one record we should do it on a special path.
@@ -43,4 +43,21 @@ class Avo::BaseComponent < ViewComponent::Base
43
43
  rescue
44
44
  nil
45
45
  end
46
+
47
+ def parent_or_child_resource
48
+ return @resource unless link_to_child_resource_is_enabled?
49
+ return @resource if @resource.model.class.base_class == @resource.model.class
50
+
51
+ ::Avo::App.get_resource_by_model_name(@resource.model.class).dup || @resource
52
+ end
53
+
54
+ def link_to_child_resource_is_enabled?
55
+ return field_linked_to_child_resource? if @parent_resource
56
+
57
+ @resource.link_to_child_resource
58
+ end
59
+
60
+ def field_linked_to_child_resource?
61
+ field.present? && field.respond_to?(:link_to_child_resource) && field.link_to_child_resource
62
+ end
46
63
  end
@@ -1,18 +1,18 @@
1
1
  <div class="relative flex-1 flex flex-col justify-between h-full"
2
2
  data-controller="dashboard-card"
3
3
  data-dashboard-card-target="card"
4
- data-refresh-every="<%= @card.refresh_every %>"
5
- data-card-id="<%= @card.id %>"
6
- data-card-index="<%= @card.index %>">
7
- <% if @card.class.display_header %>
4
+ data-refresh-every="<%= card.refresh_every %>"
5
+ data-card-id="<%= card.id %>"
6
+ data-card-index="<%= card.index %>">
7
+ <% if card.class.display_header %>
8
8
  <div class="px-4 pt-4">
9
9
  <div class="flex justify-between items-center min-h-6">
10
10
  <div class="text-base font-bold text-gray-700 leading-none">
11
- <%= @card.label %>
11
+ <%= card.label %>
12
12
  </div>
13
13
  <div data-controller="select">
14
- <% if @card.type.in?([:metric, :chartkick, :partial]) && @card.ranges.present? %>
15
- <%= select_tag "#{@card.id}_#{@card.index}_range", options_for_select(@card.ranges, @card.range),
14
+ <% if card.type.in?([:metric, :chartkick, :partial]) && card.ranges.present? %>
15
+ <%= select_tag "#{card.id}_#{card.index}_range", options_for_select(card.ranges, card.range),
16
16
  class: 'appearance-none inline-flex bg-blue-gray-100 disabled:bg-blue-gray-300 disabled:cursor-not-allowed focus:bg-white text-sm text-blue-gray-700 disabled:text-blue-gray-700 leading-none rounded-md py-px px-2 leading-tight border outline-none outline w-24',
17
17
  data: {
18
18
  target: 'select',
@@ -24,18 +24,18 @@
24
24
  </div>
25
25
  </div>
26
26
  <% end %>
27
- <% if @card.type == :chartkick %>
28
- <%= render 'chartkick_card', card: @card %>
29
- <% elsif @card.type === :partial %>
30
- <%= render @card.class.partial %>
31
- <% elsif @card.type === :metric %>
27
+ <% if card.type == :chartkick %>
28
+ <%= render 'chartkick_card', card: card %>
29
+ <% elsif card.type === :partial %>
30
+ <%= render card.class.partial %>
31
+ <% elsif card.type === :metric %>
32
32
  <div class="flex-1 flex px-4 pb-4">
33
- <%= render 'metric_card', card: @card %>
33
+ <%= render 'metric_card', card: card %>
34
34
  </div>
35
35
  <% end %>
36
- <% if @card.description.present? %>
36
+ <% if card.description.present? %>
37
37
  <%= content_tag :div, class: "absolute inset-auto bottom-0 right-0 mb-4 mr-4",
38
- title: @card.description,
38
+ title: card.description,
39
39
  data: {
40
40
  target: 'card-description',
41
41
  tippy: 'tooltip',
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::CardComponent < ViewComponent::Base
4
+ attr_reader :card
5
+
4
6
  def initialize(card: nil)
5
7
  @card = card
6
8
 
@@ -8,16 +10,16 @@ class Avo::CardComponent < ViewComponent::Base
8
10
  end
9
11
 
10
12
  def render?
11
- !@card.nil?
13
+ card.present?
12
14
  end
13
15
 
14
16
  # Initializing the card byt running the query method.
15
17
  # We'll still keep the query block around for compatibility reasons.
16
18
  def init_card
17
- if @card.respond_to? :query
18
- @card.query
19
- elsif @card.query_block.present?
20
- @card.compute_result
19
+ if card.respond_to? :query
20
+ card.query
21
+ elsif card.query_block.present?
22
+ card.compute_result
21
23
  end
22
24
  end
23
25
  end
@@ -61,7 +61,13 @@ class Avo::FieldWrapperComponent < ViewComponent::Base
61
61
  end
62
62
 
63
63
  def help
64
- @help || @field.help
64
+ help_value = @help || @field.help
65
+
66
+ if help_value.respond_to?(:call)
67
+ return Avo::Hosts::ResourceViewRecordHost.new(block: help_value, record: record, resource: resource, view: view).handle
68
+ end
69
+
70
+ help_value
65
71
  end
66
72
 
67
73
  def record
@@ -38,10 +38,9 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
38
38
  def create_path
39
39
  args = {
40
40
  via_relation: @resource.singular_model_key,
41
- via_relation_class: @resource.name,
41
+ via_relation_class: @resource.model_class.to_s,
42
42
  via_resource_id: @resource.model.id
43
43
  }
44
-
45
44
  helpers.new_resource_path(resource: @field.target_resource, **args)
46
45
  end
47
46
  end
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Avo::Fields::IndexComponent < ViewComponent::Base
3
+ class Avo::Fields::IndexComponent < Avo::BaseComponent
4
4
  include Avo::ResourcesHelper
5
5
 
6
6
  attr_reader :parent_resource
7
7
  attr_reader :view
8
8
 
9
- def initialize(field: nil, resource: nil, index: 0, parent_model: nil, parent_resource: nil)
9
+ def initialize(field: nil, resource: nil, reflection: nil, index: 0, parent_model: nil, parent_resource: nil)
10
10
  @field = field
11
11
  @resource = resource
12
12
  @index = index
13
13
  @parent_model = parent_model
14
14
  @parent_resource = parent_resource
15
15
  @view = :index
16
+ @reflection = reflection
16
17
  end
17
18
 
18
19
  def resource_view_path
@@ -25,7 +26,7 @@ class Avo::Fields::IndexComponent < ViewComponent::Base
25
26
  }
26
27
  end
27
28
 
28
- helpers.resource_view_path(model: @resource.model, resource: @resource, **args)
29
+ helpers.resource_view_path(model: @resource.model, resource: parent_or_child_resource, **args)
29
30
  end
30
31
 
31
32
  def field_wrapper_args
@@ -1,5 +1,5 @@
1
1
  <%= field_wrapper **field_wrapper_args do %>
2
- <%= @form.select @field.id, @field.options_for_select, {
2
+ <%= @form.select @field.id, options_for_select(@field.options_for_select, selected: @field.value), {
3
3
  include_blank: @field.include_blank
4
4
  },
5
5
  aria: {
@@ -21,7 +21,7 @@
21
21
  <%= render partial: filter.class.template, locals: {filter: filter} %>
22
22
  <% end %>
23
23
  <div class="p-4 border-gray-300 border-t">
24
- <% if params[:filters].present? %>
24
+ <% if @applied_filters.present? %>
25
25
  <%= a_link reset_path, data: {turbo_frame: params[:turbo_frame]}, color: :gray, size: :sm, class: 'w-full justify-center' do %>
26
26
  <%= t('avo.reset_filters') %>
27
27
  <% end %>
@@ -17,9 +17,9 @@ class Avo::FiltersComponent < ViewComponent::Base
17
17
  def reset_path
18
18
  # If come from a association page
19
19
  if @parent_model.present?
20
- helpers.related_resources_path(@parent_model, @parent_model, filters: nil, keep_query_params: true)
20
+ helpers.related_resources_path(@parent_model, @parent_model, filters: nil, reset_filter: true, keep_query_params: true)
21
21
  else
22
- helpers.resources_path(resource: @resource, filters: nil, keep_query_params: true)
22
+ helpers.resources_path(resource: @resource, filters: nil, reset_filter: true, keep_query_params: true)
23
23
  end
24
24
  end
25
25
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Avo::Index::GridItemComponent < ViewComponent::Base
3
+ class Avo::Index::GridItemComponent < Avo::BaseComponent
4
4
  include Avo::ResourcesHelper
5
5
 
6
6
  attr_reader :parent_resource
@@ -37,6 +37,6 @@ class Avo::Index::GridItemComponent < ViewComponent::Base
37
37
  }
38
38
  end
39
39
 
40
- helpers.resource_view_path(model: @resource.model, resource: @resource, **args)
40
+ helpers.resource_view_path(model: @resource.model, resource: parent_or_child_resource, **args)
41
41
  end
42
42
  end