avo 3.11.10 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -9
  3. data/app/components/avo/fields/common/badge_viewer_component.rb +1 -1
  4. data/app/components/avo/filters_component.rb +1 -1
  5. data/app/components/avo/index/grid_item_component.rb +1 -1
  6. data/app/components/avo/index/resource_controls_component.rb +1 -1
  7. data/app/components/avo/index/resource_grid_component.rb +1 -1
  8. data/app/components/avo/index/resource_table_component.rb +17 -1
  9. data/app/components/avo/index/table_row_component.rb +1 -1
  10. data/app/components/avo/items/panel_component.rb +1 -1
  11. data/app/components/avo/paginator_component.rb +1 -1
  12. data/app/components/avo/panel_component.rb +1 -1
  13. data/app/components/avo/panel_name_component.rb +1 -1
  14. data/app/components/avo/sidebar/base_item_component.rb +1 -0
  15. data/app/components/avo/sidebar/link_component.html.erb +1 -1
  16. data/app/components/avo/sidebar/link_component.rb +1 -0
  17. data/app/components/avo/sidebar_profile_component.rb +1 -1
  18. data/app/components/avo/views/resource_edit_component.rb +1 -1
  19. data/app/components/avo/views/resource_index_component.rb +1 -1
  20. data/app/components/avo/views/resource_show_component.rb +1 -1
  21. data/lib/avo/concerns/model_class_constantized.rb +8 -3
  22. data/lib/avo/resources/base.rb +5 -1
  23. data/lib/avo/version.rb +1 -1
  24. data/lib/generators/avo/tailwindcss/install_generator.rb +1 -1
  25. data/lib/generators/avo/templates/tailwindcss/tailwind.config.js +1 -0
  26. data/public/avo-assets/avo.base.js +98 -98
  27. data/public/avo-assets/avo.base.js.map +4 -4
  28. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee5f9113b37053e43065a7acaf34cde1cba9e2b297c88c64f6c79f8717995b50
4
- data.tar.gz: 4dab827b95239e51d02b237c245b6293e17df89dab56dc91e4646035478058ec
3
+ metadata.gz: 7ea6bacc70642569fc566cfe8077351f912d1732dc448aaae5c3c7e9f514c03b
4
+ data.tar.gz: 00311e5f04c3cc273f95b9ca28d349e5b1b04fcab26e1b55b3d7dbea4742b538
5
5
  SHA512:
6
- metadata.gz: 1a6e5969e163adacdf017c015c861f84852daddcf11910d969b07981d7bc701ab06b1d4671edb478ed6f33a3e6b5f054396fd4dda5f28e770c8f6b1489031daf
7
- data.tar.gz: 0e5ae8070c7646318efbda00096ed29541941b85e0827a1e661fd054ccbce77f309ad23fac5cc3f2071d1cf5d05d681085f146e39a164e545a93ff5fe65a2a86
6
+ metadata.gz: 8f33cbf80efdcc7c0b499bd6832b827e4d010550425e3de2d1a277039ad72182bef24a43f05bd893ffbdfd99e89cef878b03d35d61c9dbf2809d76f2c8567182
7
+ data.tar.gz: 6f4298165afa9a741778a1226d90b1f513bbf85b27ca604ab69d4cab96c36893823ca69b0b353d2215bbb10fede3782086e2187ee1a6bde3d89ce5c4d54aff91
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
 
8
8
  GIT
9
9
  remote: https://github.com/rails/rails.git
10
- revision: 984b10b6fca7572a6d60150a06f43095210a11f6
10
+ revision: c692e75d96f572f3fe518f06bec0dfd12b548429
11
11
  branch: main
12
12
  specs:
13
13
  actioncable (8.0.0.alpha)
@@ -105,7 +105,7 @@ GIT
105
105
  PATH
106
106
  remote: .
107
107
  specs:
108
- avo (3.11.10)
108
+ avo (3.12.0)
109
109
  actionview (>= 6.1)
110
110
  active_link_to
111
111
  activerecord (>= 6.1)
@@ -156,8 +156,8 @@ GEM
156
156
  money-rails (~> 1.12)
157
157
  avo-record_link_field (0.0.1)
158
158
  aws-eventstream (1.3.0)
159
- aws-partitions (1.967.0)
160
- aws-sdk-core (3.201.5)
159
+ aws-partitions (1.969.0)
160
+ aws-sdk-core (3.202.0)
161
161
  aws-eventstream (~> 1, >= 1.3.0)
162
162
  aws-partitions (~> 1, >= 1.651.0)
163
163
  aws-sigv4 (~> 1.9)
@@ -320,7 +320,7 @@ GEM
320
320
  activerecord (>= 4.0)
321
321
  hashids (~> 1.0)
322
322
  hashids (1.0.6)
323
- highline (3.1.0)
323
+ highline (3.1.1)
324
324
  reline
325
325
  hightop (0.4.0)
326
326
  activesupport (>= 6.1)
@@ -401,7 +401,7 @@ GEM
401
401
  money (~> 6.13)
402
402
  railties (>= 3.0)
403
403
  msgpack (1.7.2)
404
- net-imap (0.4.14)
404
+ net-imap (0.4.15)
405
405
  date
406
406
  net-protocol
407
407
  net-pop (0.1.2)
@@ -417,7 +417,7 @@ GEM
417
417
  nokogiri (1.16.7-x86_64-linux)
418
418
  racc (~> 1.4)
419
419
  orm_adapter (0.5.0)
420
- pagy (9.0.5)
420
+ pagy (9.0.6)
421
421
  parallel (1.26.3)
422
422
  parser (3.3.4.2)
423
423
  ast (~> 2.4.1)
@@ -604,7 +604,7 @@ GEM
604
604
  prettier_print (>= 1.2.0)
605
605
  terminal-table (3.0.2)
606
606
  unicode-display_width (>= 1.1.1, < 3)
607
- test-prof (1.4.0)
607
+ test-prof (1.4.1)
608
608
  thor (1.3.1)
609
609
  thread_safe (0.3.6)
610
610
  tilt (2.4.0)
@@ -621,7 +621,7 @@ GEM
621
621
  unaccent (0.4.0)
622
622
  unicode-display_width (2.5.0)
623
623
  useragent (0.16.10)
624
- view_component (3.13.0)
624
+ view_component (3.14.0)
625
625
  activesupport (>= 5.2.0, < 8.0)
626
626
  concurrent-ruby (~> 1.0)
627
627
  method_source (~> 1.0)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::Fields::Common::BadgeViewerComponent < Avo::BaseComponent
4
- prop :value, String
4
+ prop :value, _Union(_String, _Symbol)
5
5
  prop :options, Hash
6
6
 
7
7
  def after_initialize
@@ -6,7 +6,7 @@ class Avo::FiltersComponent < Avo::BaseComponent
6
6
  prop :filters, _Array(Avo::Filters::BaseFilter), default: [].freeze
7
7
  prop :resource, _Nilable(Avo::BaseResource)
8
8
  prop :applied_filters, Hash, default: {}.freeze
9
- prop :parent_record, _Nilable(ActiveRecord::Base)
9
+ prop :parent_record, _Nilable(_Any)
10
10
 
11
11
  def render?
12
12
  @filters.present?
@@ -6,7 +6,7 @@ class Avo::Index::GridItemComponent < Avo::BaseComponent
6
6
 
7
7
  prop :resource, _Nilable(Avo::BaseResource)
8
8
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
9
- prop :parent_record, _Nilable(ActiveRecord::Base)
9
+ prop :parent_record, _Nilable(_Any)
10
10
  prop :parent_resource, _Nilable(Avo::BaseResource)
11
11
  prop :actions, _Nilable(_Array(Avo::BaseAction))
12
12
 
@@ -5,7 +5,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
5
5
 
6
6
  prop :resource, _Nilable(Avo::BaseResource)
7
7
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
8
- prop :parent_record, _Nilable(ActiveRecord::Base)
8
+ prop :parent_record, _Nilable(_Any)
9
9
  prop :parent_resource, _Nilable(Avo::BaseResource)
10
10
  prop :view_type, Symbol, default: :table
11
11
  prop :actions, _Nilable(_Array(Avo::BaseAction))
@@ -4,7 +4,7 @@ class Avo::Index::ResourceGridComponent < Avo::BaseComponent
4
4
  prop :resources, _Array(_Nilable(Avo::BaseResource))
5
5
  prop :resource, _Nilable(Avo::BaseResource)
6
6
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
7
- prop :parent_record, _Nilable(ActiveRecord::Base)
7
+ prop :parent_record, _Nilable(_Any)
8
8
  prop :parent_resource, _Nilable(Avo::BaseResource)
9
9
  prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public
10
10
  end
@@ -11,7 +11,7 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
11
11
  prop :resources, _Nilable(_Array(Avo::BaseResource))
12
12
  prop :resource, _Nilable(Avo::BaseResource)
13
13
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
14
- prop :parent_record, _Nilable(ActiveRecord::Base)
14
+ prop :parent_record, _Nilable(_Any)
15
15
  prop :parent_resource, _Nilable(Avo::BaseResource)
16
16
  prop :pagy, _Nilable(Pagy)
17
17
  prop :query, _Nilable(ActiveRecord::Relation)
@@ -24,6 +24,8 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
24
24
  end
25
25
 
26
26
  Avo::Services::EncryptionService.encrypt(message: @query, purpose: :select_all, serializer: Marshal)
27
+ rescue
28
+ disable_select_all
27
29
  end
28
30
 
29
31
  def selected_page_label
@@ -86,4 +88,18 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
86
88
 
87
89
  [header_fields, table_row_components]
88
90
  end
91
+
92
+ private
93
+
94
+ def disable_select_all
95
+ if Rails.env.development?
96
+ Avo.error_manager.add({
97
+ url: "https://docs.avohq.io/3.0/select-all.html#serialization-known-issues",
98
+ target: "_blank",
99
+ message: "An error occurred while serializing the query object. The Select All feature has been disabled because it depends on successful query serialization. For more details and troubleshooting steps, click here."
100
+ })
101
+ end
102
+
103
+ :select_all_disabled
104
+ end
89
105
  end
@@ -7,7 +7,7 @@ class Avo::Index::TableRowComponent < Avo::BaseComponent
7
7
 
8
8
  prop :resource, _Nilable(Avo::BaseResource)
9
9
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
10
- prop :parent_record, _Nilable(ActiveRecord::Base)
10
+ prop :parent_record, _Nilable(_Any)
11
11
  prop :parent_resource, _Nilable(Avo::BaseResource)
12
12
  prop :actions, _Nilable(_Array(Avo::BaseAction))
13
13
  prop :fields, _Nilable(_Array(Avo::Fields::BaseField))
@@ -11,7 +11,7 @@ class Avo::Items::PanelComponent < Avo::ResourceComponent
11
11
  prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public
12
12
  prop :index, _Nilable(Integer), reader: :public
13
13
  prop :parent_component, _Nilable(ViewComponent::Base)
14
- prop :parent_record, _Nilable(ActiveRecord::Base)
14
+ prop :parent_record, _Nilable(_Any)
15
15
  prop :parent_resource, _Nilable(Avo::BaseResource)
16
16
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
17
17
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Avo::PaginatorComponent < Avo::BaseComponent
4
4
  prop :resource, _Nilable(Avo::BaseResource)
5
- prop :parent_record, _Nilable(ActiveRecord::Base)
5
+ prop :parent_record, _Nilable(_Any)
6
6
  prop :pagy, _Nilable(Pagy)
7
7
  prop :turbo_frame, _Nilable(_Union(String, Symbol)) do |frame|
8
8
  frame.present? ? CGI.escapeHTML(frame) : :_top
@@ -24,7 +24,7 @@ class Avo::PanelComponent < Avo::BaseComponent
24
24
  prop :profile_photo, _Nilable(Avo::ProfilePhoto)
25
25
  prop :cover_photo, _Nilable(Avo::CoverPhoto)
26
26
  prop :args, Hash, :**, default: {}.freeze
27
- prop :name, _Nilable(String) do |value|
27
+ prop :name, _Nilable(_Union(_String, _Integer)) do |value|
28
28
  value || @args&.dig(:title)
29
29
  end
30
30
 
@@ -3,7 +3,7 @@
3
3
  class Avo::PanelNameComponent < Avo::BaseComponent
4
4
  renders_one :body
5
5
 
6
- prop :name, _Nilable(String)
6
+ prop :name, _Nilable(_Union(_String, _Integer))
7
7
  prop :url, _Nilable(String)
8
8
  prop :target, Symbol, default: :self do |value|
9
9
  value&.to_sym
@@ -5,6 +5,7 @@ class Avo::Sidebar::BaseItemComponent < Avo::BaseComponent
5
5
 
6
6
  # Object = Avo::Menu::BaseItem || ViewComponent::Base
7
7
  prop :item, _Nilable(Object), reader: :public
8
+ prop :locals, _Nilable(Hash), default: {}.freeze
8
9
 
9
10
  def after_initialize
10
11
  @items = @item.items.select(&:visible?)
@@ -1,5 +1,5 @@
1
1
  <% if @path.present? %>
2
- <%= send link_method, @path, class: classes, active: @active, target: @target, data: @data do %>
2
+ <%= send link_method, @path, class: classes, active: @active, target: @target, data: @data, **@args do %>
3
3
  <%= helpers.svg @icon, class: "h-4 text-gray-700" if @icon.present? %>
4
4
  <%= @label %>
5
5
  <% if @target == :_blank %>
@@ -11,6 +11,7 @@ class Avo::Sidebar::LinkComponent < Avo::BaseComponent
11
11
  end
12
12
  prop :data, Hash, default: {}.freeze
13
13
  prop :icon, _Nilable(String)
14
+ prop :args, Hash, :**, default: {}.freeze
14
15
 
15
16
  def is_external?
16
17
  # If the path contains the scheme, check if it includes the root path or not
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Avo::SidebarProfileComponent < Avo::BaseComponent
4
- prop :user, _Nilable(ActiveRecord::Base)
4
+ prop :user, _Nilable(_Any)
5
5
 
6
6
  def avatar
7
7
  if @user.respond_to?(:avatar) && @user.avatar.present?
@@ -4,7 +4,7 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
4
4
  include Avo::ApplicationHelper
5
5
 
6
6
  prop :resource, _Nilable(Avo::BaseResource)
7
- prop :record, _Nilable(ActiveRecord::Base)
7
+ prop :record, _Nilable(_Any)
8
8
  prop :actions, _Array(Avo::BaseAction), default: [].freeze
9
9
  prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:edit).freeze
10
10
  prop :display_breadcrumbs, _Boolean, default: true, reader: :public
@@ -14,7 +14,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
14
14
  prop :actions, _Array(Avo::BaseAction), default: [].freeze
15
15
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
16
16
  prop :turbo_frame, _Nilable(String), default: ""
17
- prop :parent_record, _Nilable(ActiveRecord::Base)
17
+ prop :parent_record, _Nilable(_Any)
18
18
  prop :parent_resource, _Nilable(Avo::BaseResource)
19
19
  prop :applied_filters, Hash, default: {}.freeze
20
20
  prop :query, _Nilable(ActiveRecord::Relation), reader: :public
@@ -8,7 +8,7 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
8
8
  prop :resource, _Nilable(Avo::BaseResource)
9
9
  prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection)
10
10
  prop :parent_resource, _Nilable(Avo::BaseResource)
11
- prop :parent_record, _Nilable(ActiveRecord::Base)
11
+ prop :parent_record, _Nilable(_Any)
12
12
  prop :resource_panel, _Nilable(_Array(Avo::BaseAction)), reader: :public
13
13
  prop :actions, _Array(Avo::BaseAction), default: [].freeze, reader: :public
14
14
 
@@ -6,11 +6,16 @@ module Avo
6
6
  class_methods do
7
7
  # Cast the model class to a constantized version and memoize it like that
8
8
  def model_class=(value)
9
- @model_class = case value
9
+ @model_class = value
10
+ end
11
+
12
+ # Cast the model class to a constantized version
13
+ def constantized_model_class
14
+ @constantized_model_class ||= case @model_class
10
15
  when Class
11
- value
16
+ @model_class
12
17
  when String, Symbol
13
- value.to_s.safe_constantize
18
+ @model_class.to_s.safe_constantize
14
19
  else
15
20
  raise ArgumentError.new "Failed to find a proper model class for #{self}"
16
21
  end
@@ -143,7 +143,7 @@ module Avo
143
143
  # where we figure out the model class from the record
144
144
  def model_class(record_class: nil)
145
145
  # get the model class off of the static property
146
- return @model_class if @model_class.present?
146
+ return constantized_model_class if @model_class.present?
147
147
 
148
148
  # get the model class off of the record for STI models
149
149
  return record_class if record_class.present?
@@ -395,6 +395,10 @@ module Avo
395
395
  end
396
396
 
397
397
  def record_title
398
+ fetch_record_title.to_s
399
+ end
400
+
401
+ def fetch_record_title
398
402
  return name if @record.nil?
399
403
 
400
404
  # Get the title from the record if title is not set, try to get the name, title or label, or fallback to the to_param
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.11.10" unless const_defined?(:VERSION)
2
+ VERSION = "3.12.0" unless const_defined?(:VERSION)
3
3
  end
@@ -35,7 +35,7 @@ module Generators
35
35
  script_name = "avo:tailwindcss"
36
36
  if Rails.root.join("Procfile.dev").exist?
37
37
  say "Add #{cmd = "avo_css: yarn #{script_name} --watch"} to Procfile.dev"
38
- append_to_file "Procfile.dev", "#{cmd}\n"
38
+ append_to_file "Procfile.dev", "\n#{cmd}\n"
39
39
  else
40
40
  say "Add default Procfile.dev"
41
41
  copy_file template_path("Procfile.dev"), "Procfile.dev"
@@ -7,5 +7,6 @@ module.exports = {
7
7
  './app/views/**/*.html.erb',
8
8
  './app/helpers/**/*.rb',
9
9
  './app/javascript/**/*.js',
10
+ './app/components/avo/**/*.html.erb',
10
11
  ],
11
12
  }