avo 2.18.1 → 2.19.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -5
  3. data/Gemfile.lock +75 -76
  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/field_wrapper_component.rb +7 -1
  8. data/app/components/avo/fields/has_one_field/show_component.rb +1 -2
  9. data/app/components/avo/fields/index_component.rb +4 -3
  10. data/app/components/avo/filters_component.html.erb +1 -1
  11. data/app/components/avo/filters_component.rb +2 -2
  12. data/app/components/avo/index/grid_item_component.rb +2 -2
  13. data/app/components/avo/index/resource_controls_component.rb +2 -2
  14. data/app/components/avo/index/table_row_component.html.erb +1 -1
  15. data/app/components/avo/item_switcher_component.html.erb +1 -1
  16. data/app/components/avo/resource_component.rb +1 -1
  17. data/app/components/avo/resource_sidebar_component.rb +1 -6
  18. data/app/components/avo/sidebar_profile_component.rb +3 -1
  19. data/app/components/avo/tab_group_component.rb +1 -1
  20. data/app/components/avo/views/resource_show_component.html.erb +1 -1
  21. data/app/controllers/avo/application_controller.rb +6 -0
  22. data/app/controllers/avo/base_controller.rb +14 -7
  23. data/app/controllers/avo/dashboards/cards_controller.rb +37 -0
  24. data/app/helpers/avo/application_helper.rb +5 -1
  25. data/app/javascript/js/controllers/search_controller.js +11 -2
  26. data/app/views/avo/{cards → dashboards/cards}/_chartkick_card.html.erb +0 -0
  27. data/app/views/avo/{cards → dashboards/cards}/_metric_card.html.erb +0 -0
  28. data/app/views/avo/{cards → dashboards/cards}/chartkick_missing.html.erb +0 -0
  29. data/app/views/avo/{cards → dashboards/cards}/show.html.erb +0 -0
  30. data/app/views/avo/partials/_branding.html.erb +1 -0
  31. data/avo.gemspec +1 -1
  32. data/bin/init +11 -1
  33. data/bin/test +1 -0
  34. data/config/routes.rb +2 -2
  35. data/db/factories.rb +10 -0
  36. data/lib/avo/app.rb +11 -1
  37. data/lib/avo/base_action.rb +19 -9
  38. data/lib/avo/base_resource.rb +3 -6
  39. data/lib/avo/concerns/filters_session_handler.rb +43 -0
  40. data/lib/avo/concerns/has_fields.rb +2 -0
  41. data/lib/avo/concerns/visible_items.rb +44 -0
  42. data/lib/avo/configuration/branding.rb +10 -2
  43. data/lib/avo/configuration.rb +3 -0
  44. data/lib/avo/dynamic_router.rb +16 -15
  45. data/lib/avo/engine.rb +6 -9
  46. data/lib/avo/fields/base_field.rb +21 -12
  47. data/lib/avo/fields/concerns/has_default.rb +17 -0
  48. data/lib/avo/fields/concerns/is_readonly.rb +1 -1
  49. data/lib/avo/fields/concerns/is_required.rb +2 -2
  50. data/lib/avo/fields/has_base_field.rb +2 -0
  51. data/lib/avo/fields/key_value_field.rb +1 -1
  52. data/lib/avo/filters/base_filter.rb +17 -2
  53. data/lib/avo/hosts/resource_view_record_host.rb +7 -0
  54. data/lib/avo/hosts/visibility_host.rb +11 -0
  55. data/lib/avo/panel.rb +4 -1
  56. data/lib/avo/resources/controls/action.rb +1 -3
  57. data/lib/avo/sidebar.rb +1 -31
  58. data/lib/avo/tab.rb +5 -22
  59. data/lib/avo/version.rb +1 -1
  60. data/lib/avo.rb +9 -0
  61. data/lib/generators/avo/resource_generator.rb +281 -0
  62. data/lib/generators/avo/templates/action.tt +3 -0
  63. data/lib/generators/avo/templates/filters/boolean_filter.tt +3 -0
  64. data/lib/generators/avo/templates/filters/multiple_select_filter.tt +3 -0
  65. data/lib/generators/avo/templates/filters/select_filter.tt +3 -0
  66. data/lib/generators/avo/templates/filters/text_filter.tt +3 -0
  67. data/lib/generators/avo/templates/initializer/avo.tt +4 -0
  68. data/lib/generators/avo/templates/resource/controller.tt +1 -1
  69. data/lib/generators/avo/templates/resource/resource.tt +2 -2
  70. data/lib/generators/model_generator.rb +10 -0
  71. data/lib/generators/rails/avo_resource_generator.rb +11 -0
  72. data/public/avo-assets/avo.base.css +10 -10
  73. data/public/avo-assets/avo.base.js +1 -1
  74. data/public/avo-assets/avo.base.js.map +2 -2
  75. data/public/avo-assets/favicon.ico +0 -0
  76. data/{app/assets/svgs → public/avo-assets}/placeholder.svg +0 -0
  77. metadata +18 -11
  78. data/app/controllers/avo/cards_controller.rb +0 -35
  79. 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: b2b092c8d9df1951b5ccd6a07b31c8c96a6cb68846ab2b2342f43082449a5ced
4
+ data.tar.gz: 5bb4985123f45ad9aeca49892559d43a80130a29ff823fc6c7f35127e5de3e5c
5
5
  SHA512:
6
- metadata.gz: 7b32f335e16778be0647bd74c1579f5842d01b74c836655040d165e64bcb5325a7f23b43bb01a31f455af6f58ae3ecac968cb301e8737d4d36734f2ea1d88dcd
7
- data.tar.gz: c9a37f010a3b138f64f7f10d31b077a94f06d48539bffb635f6b6e0d35d2d56b76d2b25cd34e31e189fbf72911a91b52910bb341391a13edff6b6c79cac3c48f
6
+ metadata.gz: e28f40d6e4559541cd2e08a76753ef87bcbfe54a48bd3ba2c7ea368436762bb287ddbac6641df9b18f6196071dd6bd7bb3f5e2f6e0bb95e2b7b10a5ab0cc6a2b
7
+ data.tar.gz: c6a64520f187b1e725b167bc396e23d6177c9c83e8f5ff2864a56cd12aed87ec757bfd34ee76955e93718268e888c9693dfa6899d6633e37f93874d2d86cbd73
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
 
@@ -125,7 +123,6 @@ gem 'meta-tags'
125
123
 
126
124
  gem 'breadcrumbs_on_rails'
127
125
 
128
- gem 'manifester'
129
126
 
130
127
  # Search
131
128
  gem 'ransack'
@@ -160,6 +157,8 @@ gem "chartkick"
160
157
 
161
158
  # Avo file filed requires this gem
162
159
  gem "activestorage"
160
+ # Required by Avo
161
+ gem "sprockets-rails"
163
162
 
164
163
  # Avo file filed requires this gem
165
164
  # Use Active Storage variant
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.18.1)
4
+ avo (2.19.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -15,7 +15,7 @@ PATH
15
15
  pagy
16
16
  turbo-rails
17
17
  view_component
18
- zeitwerk
18
+ zeitwerk (>= 2.6.2)
19
19
 
20
20
  GEM
21
21
  remote: https://rubygems.org/
@@ -88,8 +88,8 @@ GEM
88
88
  activerecord (>= 6.0, < 7.1)
89
89
  acts_as_list (1.0.4)
90
90
  activerecord (>= 4.2)
91
- addressable (2.8.0)
92
- public_suffix (>= 2.0.2, < 5.0)
91
+ addressable (2.8.1)
92
+ public_suffix (>= 2.0.2, < 6.0)
93
93
  annotate (3.2.0)
94
94
  activerecord (>= 3.2, < 8.0)
95
95
  rake (>= 10.4, < 14.0)
@@ -100,22 +100,22 @@ GEM
100
100
  ast (2.4.2)
101
101
  awesome_print (1.9.2)
102
102
  aws-eventstream (1.2.0)
103
- aws-partitions (1.551.0)
104
- aws-sdk-core (3.125.5)
103
+ aws-partitions (1.621.0)
104
+ aws-sdk-core (3.134.0)
105
105
  aws-eventstream (~> 1, >= 1.0.2)
106
106
  aws-partitions (~> 1, >= 1.525.0)
107
107
  aws-sigv4 (~> 1.1)
108
- jmespath (~> 1.0)
109
- aws-sdk-kms (1.53.0)
110
- aws-sdk-core (~> 3, >= 3.125.0)
108
+ jmespath (~> 1, >= 1.6.1)
109
+ aws-sdk-kms (1.58.0)
110
+ aws-sdk-core (~> 3, >= 3.127.0)
111
111
  aws-sigv4 (~> 1.1)
112
- aws-sdk-s3 (1.111.3)
113
- aws-sdk-core (~> 3, >= 3.125.0)
112
+ aws-sdk-s3 (1.114.0)
113
+ aws-sdk-core (~> 3, >= 3.127.0)
114
114
  aws-sdk-kms (~> 1)
115
115
  aws-sigv4 (~> 1.4)
116
- aws-sigv4 (1.4.0)
116
+ aws-sigv4 (1.5.1)
117
117
  aws-eventstream (~> 1, >= 1.0.2)
118
- bcrypt (3.1.16)
118
+ bcrypt (3.1.18)
119
119
  better_html (2.0.1)
120
120
  actionview (>= 6.0)
121
121
  activesupport (>= 6.0)
@@ -131,7 +131,7 @@ GEM
131
131
  railties (>= 5.0)
132
132
  builder (3.2.4)
133
133
  bump (0.10.0)
134
- bundler-integrity (1.0.7)
134
+ bundler-integrity (1.0.9)
135
135
  byebug (11.1.3)
136
136
  capybara (3.36.0)
137
137
  addressable
@@ -150,7 +150,7 @@ GEM
150
150
  crack (0.4.5)
151
151
  rexml
152
152
  crass (1.0.6)
153
- cssbundling-rails (1.0.0)
153
+ cssbundling-rails (1.1.1)
154
154
  railties (>= 6.0.0)
155
155
  database_cleaner (2.0.1)
156
156
  database_cleaner-active_record (~> 2.0.0)
@@ -167,20 +167,20 @@ GEM
167
167
  diff-lcs (1.5.0)
168
168
  digest (3.1.0)
169
169
  docile (1.4.0)
170
- dotenv (2.7.6)
171
- dotenv-rails (2.7.6)
172
- dotenv (= 2.7.6)
170
+ dotenv (2.8.1)
171
+ dotenv-rails (2.8.1)
172
+ dotenv (= 2.8.1)
173
173
  railties (>= 3.2)
174
174
  dry-initializer (3.1.1)
175
175
  erb-formatter (0.3.0)
176
176
  erubi (1.11.0)
177
- factory_bot (6.2.0)
177
+ factory_bot (6.2.1)
178
178
  activesupport (>= 5.0.0)
179
179
  factory_bot_rails (6.2.0)
180
180
  factory_bot (~> 6.2.0)
181
181
  railties (>= 5.0.0)
182
- faker (2.19.0)
183
- i18n (>= 1.6, < 2)
182
+ faker (2.22.0)
183
+ i18n (>= 1.8.11, < 2)
184
184
  ffi (1.15.5)
185
185
  friendly_id (5.4.2)
186
186
  activerecord (>= 4.0.0)
@@ -190,16 +190,16 @@ GEM
190
190
  gem-release (2.2.2)
191
191
  globalid (1.0.0)
192
192
  activesupport (>= 5.0)
193
- groupdate (5.2.4)
194
- activesupport (>= 5)
193
+ groupdate (6.1.0)
194
+ activesupport (>= 5.2)
195
195
  hashdiff (1.0.1)
196
196
  highline (2.0.3)
197
197
  hightop (0.3.0)
198
198
  activesupport (>= 5.2)
199
- hotwire-livereload (1.1.0)
199
+ hotwire-livereload (1.2.2)
200
200
  listen (>= 3.0.0)
201
201
  rails (>= 6.0.0)
202
- htmlbeautifier (1.4.1)
202
+ htmlbeautifier (1.4.2)
203
203
  httparty (0.20.0)
204
204
  mime-types (~> 3.0)
205
205
  multi_xml (>= 0.5.2)
@@ -222,12 +222,12 @@ GEM
222
222
  inline_svg (1.8.0)
223
223
  activesupport (>= 3.0)
224
224
  nokogiri (>= 1.6)
225
- io-wait (0.2.1)
226
225
  iso (0.4.0)
227
226
  i18n
228
227
  jmespath (1.6.1)
229
- jsbundling-rails (1.0.0)
228
+ jsbundling-rails (1.0.3)
230
229
  railties (>= 6.0.0)
230
+ json (2.6.2)
231
231
  launchy (2.5.0)
232
232
  addressable (~> 2.7)
233
233
  listen (3.7.1)
@@ -238,12 +238,9 @@ GEM
238
238
  nokogiri (>= 1.5.9)
239
239
  mail (2.7.1)
240
240
  mini_mime (>= 0.1.1)
241
- manifester (0.1.8)
242
- rails (>= 6.0)
243
- 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,21 +394,21 @@ 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)
411
+ unicode-display_width (2.2.0)
414
412
  view_component (2.74.1)
415
413
  activesupport (>= 5.0.0, < 8.0)
416
414
  concurrent-ruby (~> 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
@@ -483,12 +482,12 @@ DEPENDENCIES
483
482
  jsbundling-rails
484
483
  launchy
485
484
  listen (>= 3.5.1)
486
- manifester
487
485
  meta-tags
488
486
  net-smtp
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
@@ -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
@@ -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
@@ -41,7 +41,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
41
41
  }
42
42
  end
43
43
 
44
- helpers.resource_path(model: @resource.model, resource: @resource, **args)
44
+ helpers.resource_path(model: @resource.model, resource: parent_or_child_resource , **args)
45
45
  end
46
46
 
47
47
  def edit_path
@@ -55,7 +55,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
55
55
  }
56
56
  end
57
57
 
58
- helpers.edit_resource_path(model: @resource.model, resource: @resource, **args)
58
+ helpers.edit_resource_path(model: @resource.model, resource: parent_or_child_resource, **args)
59
59
  end
60
60
 
61
61
  def singular_resource_name
@@ -17,7 +17,7 @@
17
17
  </td>
18
18
  <% end %>
19
19
  <% @resource.get_fields(reflection: @reflection, only_root: true).each_with_index do |field, index| %>
20
- <%= render field.component_for_view(:index).new(field: field, resource: @resource, index: index, parent_model: @parent_model, parent_resource: @parent_resource) %>
20
+ <%= render field.component_for_view(:index).new(field: field, resource: @resource, reflection: @reflection, index: index, parent_model: @parent_model, parent_resource: @parent_resource) %>
21
21
  <% end %>
22
22
  <% if Avo.configuration.resource_controls_on_the_right? %>
23
23
  <td class="text-right whitespace-nowrap px-2" data-control="resource-controls">
@@ -6,7 +6,7 @@
6
6
  <%= render Avo::PanelComponent.new(name: item.name, description: item.description, index: index) do |c| %>
7
7
  <% c.body do %>
8
8
  <div class="divide-y">
9
- <% item.items.each_with_index do |field, index| %>
9
+ <% item.visible_items.each_with_index do |field, index| %>
10
10
  <%= render field
11
11
  .hydrate(resource: @resource, model: @resource.model, user: resource.user, view: view)
12
12
  .component_for_view(view)
@@ -92,7 +92,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
92
92
  end
93
93
 
94
94
  def sidebar_component(form: nil)
95
- Avo::ResourceSidebarComponent.new resource: @resource, fields: sidebar.items, params: params, view: view, form: form
95
+ Avo::ResourceSidebarComponent.new resource: @resource, fields: sidebar.visible_items, params: params, view: view, form: form
96
96
  end
97
97
 
98
98
  def has_reflection_and_is_read_only
@@ -5,6 +5,7 @@ class Avo::ResourceSidebarComponent < ViewComponent::Base
5
5
  attr_reader :params
6
6
  attr_reader :view
7
7
  attr_reader :form
8
+ attr_reader :fields
8
9
 
9
10
  def initialize(resource: nil, fields: nil, index: nil, params: nil, form: nil, view: nil)
10
11
  @resource = resource
@@ -14,12 +15,6 @@ class Avo::ResourceSidebarComponent < ViewComponent::Base
14
15
  @form = form
15
16
  end
16
17
 
17
- def fields
18
- @fields.filter do |field|
19
- field.visible_on? view
20
- end
21
- end
22
-
23
18
  def render?
24
19
  Avo::App.license.has_with_trial(:resource_sidebar)
25
20
  end
@@ -34,7 +34,9 @@ class Avo::SidebarProfileComponent < ViewComponent::Base
34
34
  end
35
35
 
36
36
  def destroy_user_session_path
37
- "destroy_#{Avo.configuration.current_user_resource_name}_session_path".to_sym
37
+ # If `sign_out_path_name` is configured, use it. Otherwise construct the
38
+ # path name based on `current_user_resource_name`.
39
+ (Avo.configuration.sign_out_path_name || "destroy_#{Avo.configuration.current_user_resource_name}_session_path").to_sym
38
40
  end
39
41
 
40
42
  def can_destroy_user?
@@ -39,7 +39,7 @@ class Avo::TabGroupComponent < Avo::BaseComponent
39
39
 
40
40
  def visible_tabs
41
41
  tabs.select do |tab|
42
- !tab.empty?
42
+ tab.visible?
43
43
  end
44
44
  end
45
45
 
@@ -40,7 +40,7 @@
40
40
  <% end %>
41
41
  <% end %>
42
42
  <% elsif can_see_the_actions_button? && control.actions_list? %>
43
- <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, style: control.style, color: control.color %>
43
+ <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view, exclude: control.exclude, style: control.style, color: control.color, label: control.label %>
44
44
  <% elsif control.edit_button? %>
45
45
  <% if @resource.authorization.authorize_action(:edit, raise_exception: false) %>
46
46
  <% end %>