From 71383ad672ff121a4d165b8ab1f7d84a7d926eeb Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:44:53 +0300 Subject: [PATCH 01/30] feature: audit logs (#2703) * WIP * wip * WIP * wip * typo * WIP * WIP * wip * wip * wip * dont break if db do not exist * wip * rename package * extract audit method and safe_call it * register all activity * Update app/components/avo/sidebar_component.html.erb * Update lib/avo/configuration.rb * Update lib/avo/configuration.rb * rename to avo-audit_logging * feature: log attach and detach * unbundle audits from enterprise license * implement gem configuration * rm unused config attribute * clear template * extract direct call * remove direct audit call * rm set_paper_trail_whodunnit * revert safe_call enhancement * temporary solution for not defined audit * wip * . * lint * extract audit call * rm activity * Update lib/tasks/avo_tasks.rake --- app/controllers/avo/actions_controller.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/avo/actions_controller.rb b/app/controllers/avo/actions_controller.rb index 1b192c1be..3aa65667b 100644 --- a/app/controllers/avo/actions_controller.rb +++ b/app/controllers/avo/actions_controller.rb @@ -11,6 +11,7 @@ class ActionsController < ApplicationController end before_action :set_action, only: [:show, :handle] before_action :verify_authorization, only: [:show, :handle] + before_action :set_query, :set_fields, only: :handle layout :choose_layout @@ -47,14 +48,11 @@ def build_background_url end def handle - resource_ids = action_params[:fields][:avo_resource_ids].split(",") - performed_action = @action.handle_action( - fields: action_params[:fields].except(:avo_resource_ids, :avo_selected_query), + fields: @fields, current_user: _current_user, resource: @resource, - query: decrypted_query || - (resource_ids.any? ? @resource.find_record(resource_ids, params: params) : []) + query: @query ) @response = performed_action.response @@ -63,6 +61,16 @@ def handle private + def set_query + resource_ids = action_params[:fields][:avo_resource_ids].split(",") + + @query = decrypted_query || (resource_ids.any? ? @resource.find_record(resource_ids, params: params) : []) + end + + def set_fields + @fields = action_params[:fields].except(:avo_resource_ids, :avo_selected_query) + end + def action_params @action_params ||= params.permit(:id, :authenticity_token, :resource_name, :action_id, :button, fields: {}) end From acfc6d0b1697669b6177f0a66a4342669f4eca17 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:01:52 +0300 Subject: [PATCH 02/30] feature: implicit authorization (#3292) * feature: implicit authorization * wip * improve authorize_association_for * more improvements on authorize_association_for * rm `raise_error_on_missing_policy_method` * fix logic * fix logic * lint * fix elseif * fix method_name * lint * implicit authorization * callable implicit_authorization * implicit_authorization as attr_writer --- .../avo/associations_controller.rb | 2 + .../concerns/checks_assoc_authorization.rb | 58 +++++++++---------- lib/avo/configuration.rb | 6 ++ lib/avo/fields/has_base_field.rb | 2 +- .../avo/templates/initializer/avo.tt | 1 + 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index 2cba58634..27377cf28 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -154,6 +154,8 @@ def authorize_if_defined(method, record = @record) if @authorization.has_method?(method.to_sym) @authorization.authorize_action method.to_sym + elsif Avo.configuration.authorization_client.present? && Avo.configuration.implicit_authorization + raise Avo::NotAuthorizedError.new end end diff --git a/lib/avo/concerns/checks_assoc_authorization.rb b/lib/avo/concerns/checks_assoc_authorization.rb index e45c0260d..117392d96 100644 --- a/lib/avo/concerns/checks_assoc_authorization.rb +++ b/lib/avo/concerns/checks_assoc_authorization.rb @@ -5,44 +5,38 @@ module ChecksAssocAuthorization # Ex: A Post has many Comments def authorize_association_for(policy_method) - policy_result = true + # Use the related_name as the base of the association + association_name = @reflection&.name + return true if association_name.blank? - if @reflection.present? - # Fetch the appropriate resource - reflection_resource = field.resource - # Fetch the record - # Hydrate the resource with the record if we have one - reflection_resource.hydrate(record: @parent_record) if @parent_record.present? - # Use the related_name as the base of the association - association_name = @reflection.name + # Fetch the appropriate resource + reflection_resource = field.resource - if association_name.present? - method_name = :"#{policy_method}_#{association_name}?".to_sym + # Hydrate the resource with the record if we have one + reflection_resource.hydrate(record: @parent_record) if @parent_record.present? - # Use the policy methods from the parent (Post) - service = reflection_resource.authorization + # Some policy methods should get the parent record in order to have the necessary information to do the authorization + # Example: Post->has_many->Comments + # + # When you want to authorize the creation/attaching of a Comment, you don't have the Comment instance. + # But you do have the Post instance and you can get that in your policy to authorize against. + record = if policy_method.in? [:view, :create, :attach, :act_on] + # Use the parent record (Post) + reflection_resource.record + else + # Override the record with the child record (Comment) + resource.record + end - if service.has_method?(method_name, raise_exception: false) - # Some policy methods should get the parent record in order to have the necessary information to do the authorization - # Example: Post->has_many->Comments - # - # When you want to authorize the creation/attaching of a Comment, you don't have the Comment instance. - # But you do have the Post instance and you can get that in your policy to authorize against. - parent_policy_methods = [:view, :create, :attach, :act_on] + # Use the policy methods from the parent (Post) + service = reflection_resource.authorization + method_name = :"#{policy_method}_#{association_name}?".to_sym - record = if parent_policy_methods.include?(policy_method) - # Use the parent record (Post) - reflection_resource.record - else - # Override the record with the child record (Comment) - resource.record - end - policy_result = service.authorize_action(method_name, record: record, raise_exception: false) - end - end + if service.has_method?(method_name, raise_exception: false) + service.authorize_action(method_name, record:, raise_exception: false) + else + !Avo.configuration.implicit_authorization end - - policy_result end end end diff --git a/lib/avo/configuration.rb b/lib/avo/configuration.rb index 269d45179..d8ea7d509 100644 --- a/lib/avo/configuration.rb +++ b/lib/avo/configuration.rb @@ -9,6 +9,7 @@ class Configuration attr_writer :logger attr_writer :turbo attr_writer :pagination + attr_writer :implicit_authorization attr_accessor :timezone attr_accessor :per_page attr_accessor :per_page_steps @@ -69,6 +70,7 @@ def initialize @license_key = nil @current_user = proc {} @authenticate = proc {} + @implicit_authorization = false @authorization_methods = { index: "index?", show: "show?", @@ -252,6 +254,10 @@ def pagination def default_locale @locale || I18n.default_locale end + + def implicit_authorization + Avo::ExecutionContext.new(target: @implicit_authorization).handle + end end def self.configuration diff --git a/lib/avo/fields/has_base_field.rb b/lib/avo/fields/has_base_field.rb index 7e45b0d07..d691fce73 100644 --- a/lib/avo/fields/has_base_field.rb +++ b/lib/avo/fields/has_base_field.rb @@ -100,7 +100,7 @@ def authorized? if service.has_method? method service.authorize_action(method, raise_exception: false) else - true + !Avo.configuration.implicit_authorization end end diff --git a/lib/generators/avo/templates/initializer/avo.tt b/lib/generators/avo/templates/initializer/avo.tt index ec6fa82f4..135494bed 100644 --- a/lib/generators/avo/templates/initializer/avo.tt +++ b/lib/generators/avo/templates/initializer/avo.tt @@ -41,6 +41,7 @@ Avo.configure do |config| # } # config.raise_error_on_missing_policy = false config.authorization_client = nil + config.implicit_authorization = true ## == Localization == # config.locale = 'en-US' From 49da69194b3fcf8af386cd33508ae6d9c9c89eec Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Wed, 9 Oct 2024 15:02:10 +0300 Subject: [PATCH 03/30] Bumped avo to 3.13.4 --- Gemfile.lock | 4 ++-- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a058686b2..8ab59e925 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) @@ -757,4 +757,4 @@ DEPENDENCIES zeitwerk BUNDLED WITH - 2.4.7 + 2.5.9 diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index 4e6a63dcd..e79e84b5b 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index 76f868fc9..b0ea5d27e 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index f0e9b1a7a..5640d4e5c 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 36b407e43..200e6c548 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 7a68e3525..50c7e7ee8 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 7a68e3525..50c7e7ee8 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index d66e88005..440f32e4c 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index d66e88005..440f32e4c 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.3) + avo (3.13.4) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index 4d39a0b84..11222cd0c 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.3" unless const_defined?(:VERSION) + VERSION = "3.13.4" unless const_defined?(:VERSION) end From 9a9a4b24bab6557d52c2a79ee7125e5c02004f81 Mon Sep 17 00:00:00 2001 From: Ender Ahmet Yurt Date: Wed, 9 Oct 2024 17:41:46 +0300 Subject: [PATCH 04/30] Add a comment to notice about security (#3318) --- lib/generators/avo/tool_generator.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/generators/avo/tool_generator.rb b/lib/generators/avo/tool_generator.rb index f8d35570b..47a1ac90a 100644 --- a/lib/generators/avo/tool_generator.rb +++ b/lib/generators/avo/tool_generator.rb @@ -40,13 +40,14 @@ def #{file_name} # bin/rails generate avo:tool lolo # will generate the avo.lolo_path helper # THe fact that it will always generate the definded? and Avo::Engine.routes.draw wraps is unfortunate. We'd love a PR to fix that. - route_contents = <<-ROUTE - -if defined? ::Avo - Avo::Engine.routes.draw do - get "#{file_name}", to: "tools##{file_name}", as: :#{file_name} - end -end + route_contents = <<~ROUTE + + if defined? ::Avo + Avo::Engine.routes.draw do + # This route is not protected, secure it with authentication if needed. + get "#{file_name}", to: "tools##{file_name}", as: :#{file_name} + end + end ROUTE append_to_file "config/routes.rb", route_contents From 700233ec264dd8be0989f453178cc46e40ed501d Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:42:51 +0300 Subject: [PATCH 05/30] chore: callable `disabled_features` (#3319) --- lib/avo/configuration.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/avo/configuration.rb b/lib/avo/configuration.rb index d8ea7d509..486aa8029 100644 --- a/lib/avo/configuration.rb +++ b/lib/avo/configuration.rb @@ -36,7 +36,7 @@ class Configuration attr_accessor :display_license_request_timeout_error attr_accessor :current_user_resource_name attr_accessor :raise_error_on_missing_policy - attr_accessor :disabled_features + attr_writer :disabled_features attr_accessor :buttons_on_form_footers attr_accessor :main_menu attr_accessor :profile_menu @@ -155,8 +155,12 @@ def root_path @root_path end + def disabled_features + Avo::ExecutionContext.new(target: @disabled_features).handle + end + def feature_enabled?(feature) - !@disabled_features.map(&:to_sym).include?(feature.to_sym) + !disabled_features.map(&:to_sym).include?(feature.to_sym) end def branding From 034b0b46cba6a1c4a201839e512848fee66b0676 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Wed, 9 Oct 2024 17:48:12 +0300 Subject: [PATCH 06/30] Bumped avo to 3.13.5 --- Gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ab59e925..9ad349eec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index e79e84b5b..1cb5cb1e4 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index b0ea5d27e..168c75d19 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index 5640d4e5c..f4746475f 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 200e6c548..0bbfc8450 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 50c7e7ee8..95d5ceb1f 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 50c7e7ee8..95d5ceb1f 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 440f32e4c..10a1e003b 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 440f32e4c..10a1e003b 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.4) + avo (3.13.5) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index 11222cd0c..d736c6c3a 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.4" unless const_defined?(:VERSION) + VERSION = "3.13.5" unless const_defined?(:VERSION) end From 5a60b49d3ed7440a9c60de8728069038427160a6 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:39:46 +0300 Subject: [PATCH 07/30] chore: enhancements section on release notes (#3274) --- .github/release-drafter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 76cde928f..908b73c19 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -5,6 +5,8 @@ categories: labels: - 'Feature' - 'Feat' + - title: '✨ Enhancements' + labels: - 'Enhancement' - title: '🐛 Bug Fixes' labels: From 36c319953b7bde137eac5419920255b4df0c971a Mon Sep 17 00:00:00 2001 From: Nishant Samel Date: Thu, 10 Oct 2024 17:44:57 +0530 Subject: [PATCH 08/30] Fix typographical errors from app [ci skip] (#3323) --- CONTRIBUTING.MD | 4 ++-- Gemfile | 2 +- .../avo/fields/boolean_group_field/edit_component.rb | 2 +- app/components/avo/index/resource_controls_component.rb | 2 +- app/components/avo/resource_component.rb | 2 +- app/javascript/avo.base.js | 2 +- app/javascript/js/controllers/copy_to_clipboard_controller.js | 2 +- app/javascript/js/controllers/sidebar_controller.js | 4 ++-- lib/tasks/avo_tasks.rake | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.MD b/CONTRIBUTING.MD index d3a3faba9..6004c46a6 100644 --- a/CONTRIBUTING.MD +++ b/CONTRIBUTING.MD @@ -29,7 +29,7 @@ Please fork Avo and create a descriptive branch for your feature or fix. We usua Thank you for considering to contribute to Avo. These are our recommendations to improve readability and interoperability when contributing with a PR: - the title should have the type (`feature`, `chore`, `fix`, `refactor`) followed by the sentence case of what it does (ex: `feature: scoped search for has many associations` or `fix: broken sidebar on desktop`). -- the PR should be marked by the appropiate tag (`feature`, `chore`, `fix`, `refactor`) +- the PR should be marked by the appropriate tag (`feature`, `chore`, `fix`, `refactor`) - if there's an issue open that could be fixed by this PR you can mark it by writing `Fixes ISSUE_URL` in the description so GitHub automates some actions (ex: `Fixes https://github.com/avo-hq/avo/issues/1008`). If there are more issues that could be fixed, add more lines. - please follow the steps on the `Checklist` and mark them as done with an `x` inside the brackets `[x]` - if there's something that we can test, please send us the instructions to do that in that PR description. @@ -167,7 +167,7 @@ In order to restore the previous fields you may run `RESOURCE_CLASS.restore_item ### Working with datepickers -The prerequisite for these helpers is to ensure you have the two inputs mapped in your test file like so and you update the `FIELD_ID` attribute to the field you decalred on your resource `created_at`, `starting_at`, etc. +The prerequisite for these helpers is to ensure you have the two inputs mapped in your test file like so and you update the `FIELD_ID` attribute to the field you declared on your resource `created_at`, `starting_at`, etc. ```ruby subject(:text_input) { find '[data-field-id="FIELD_ID"] [data-controller="date-field"] input[type="text"]' } diff --git a/Gemfile b/Gemfile index 2731d10d6..8255fe451 100644 --- a/Gemfile +++ b/Gemfile @@ -159,7 +159,7 @@ gem "bundler-integrity", "~> 1.0" # Avo country field requires this gem gem "countries" -# Avo dashbaords requires this gem +# Avo dashboards requires this gem gem "chartkick" # Required by Avo diff --git a/app/components/avo/fields/boolean_group_field/edit_component.rb b/app/components/avo/fields/boolean_group_field/edit_component.rb index 9639a4438..61bfcc4f7 100644 --- a/app/components/avo/fields/boolean_group_field/edit_component.rb +++ b/app/components/avo/fields/boolean_group_field/edit_component.rb @@ -4,7 +4,7 @@ class Avo::Fields::BooleanGroupField::EditComponent < Avo::Fields::EditComponent def initialize(...) super(...) - # Initilize here to avoid multiple calls to @field.get_html for each option. + # Initialize here to avoid multiple calls to @field.get_html for each option. @classes = "w-4 h-4 rounded checked:bg-primary-400 focus:checked:!bg-primary-400" \ "#{@field.get_html(:classes, view: view, element: :input)}" @data = @field.get_html(:data, view: view, element: :input) diff --git a/app/components/avo/index/resource_controls_component.rb b/app/components/avo/index/resource_controls_component.rb index e903cb118..d2475291a 100644 --- a/app/components/avo/index/resource_controls_component.rb +++ b/app/components/avo/index/resource_controls_component.rb @@ -102,7 +102,7 @@ def render_show_button(control) def render_delete_button(control) # If the resource is a related resource, we use the can_delete? policy method because it uses # authorize_association_for(:destroy). - # Otherwise we use the can_see_the_destroy_button? policy method becuse it do no check for assiciation + # Otherwise we use the can_see_the_destroy_button? policy method because it do no check for association # only for authorize_action . policy_method = is_a_related_resource? ? :can_delete? : :can_see_the_destroy_button? return unless send policy_method diff --git a/app/components/avo/resource_component.rb b/app/components/avo/resource_component.rb index 0df95128c..0cf8b5927 100644 --- a/app/components/avo/resource_component.rb +++ b/app/components/avo/resource_component.rb @@ -157,7 +157,7 @@ def render_actions_list(actions_list) def render_delete_button(control) # If the resource is a related resource, we use the can_delete? policy method because it uses # authorize_association_for(:destroy). - # Otherwise we use the can_see_the_destroy_button? policy method becuse it do no check for assiciation + # Otherwise we use the can_see_the_destroy_button? policy method because it do no check for association # only for authorize_action . policy_method = is_a_related_resource? ? :can_delete? : :can_see_the_destroy_button? return unless send policy_method diff --git a/app/javascript/avo.base.js b/app/javascript/avo.base.js index 37092e5ff..523670776 100644 --- a/app/javascript/avo.base.js +++ b/app/javascript/avo.base.js @@ -99,7 +99,7 @@ document.addEventListener('turbo:frame-load', () => { document.addEventListener('turbo:before-fetch-response', async (e) => { if (e.detail.fetchResponse.response.status === 500) { const { id, src } = e.target - // Don't try to redirect to failed to load if this is alread a redirection to failed to load and crashed somewhere. + // Don't try to redirect to failed to load if this is already a redirection to failed to load and crashed somewhere. // You'll end up with a request loop. if (!e.detail.fetchResponse?.response?.url?.includes('/failed_to_load')) { e.target.src = `${window.Avo.configuration.root_path}/failed_to_load?turbo_frame=${id}&src=${src}` diff --git a/app/javascript/js/controllers/copy_to_clipboard_controller.js b/app/javascript/js/controllers/copy_to_clipboard_controller.js index 90175a6ae..4ff80bf60 100644 --- a/app/javascript/js/controllers/copy_to_clipboard_controller.js +++ b/app/javascript/js/controllers/copy_to_clipboard_controller.js @@ -13,7 +13,7 @@ export default class extends Controller { el.value = str // Set its value to the string that you want copied el.contentEditable = true el.readOnly = false - el.setAttribute('readonly', false) // Make it readonly false for iOS compatability + el.setAttribute('readonly', false) // Make it readonly false for iOS compatibility el.setAttribute('contenteditable', true) // Make it editable for iOS el.style.position = 'absolute' el.style.left = '-9999px' // Move outside the screen to make it invisible diff --git a/app/javascript/js/controllers/sidebar_controller.js b/app/javascript/js/controllers/sidebar_controller.js index d94b2f817..320ef8991 100644 --- a/app/javascript/js/controllers/sidebar_controller.js +++ b/app/javascript/js/controllers/sidebar_controller.js @@ -69,7 +69,7 @@ export default class extends Controller { let handler document.addEventListener('turbo:visit', handler = () => { - // Remeber sidebar scroll position before changing pages. + // Remember sidebar scroll position before changing pages. this.sidebarScrollPosition = document.querySelector('.avo-sidebar .mac-styled-scrollbar').scrollTop // remove event handler after disconnection document.removeEventListener('turbo:visit', handler) @@ -99,7 +99,7 @@ export default class extends Controller { // we force a reflow here because we remove then // immediately add the sidebar-open class // which doesn't give the browser enough time to apply the - // transistion. + // transition. this.mainAreaTarget.offsetHeight; } this.mainAreaTarget.classList.toggle('sidebar-open') diff --git a/lib/tasks/avo_tasks.rake b/lib/tasks/avo_tasks.rake index ec95c247b..75bde4797 100644 --- a/lib/tasks/avo_tasks.rake +++ b/lib/tasks/avo_tasks.rake @@ -46,7 +46,7 @@ def get_gem_spec(name) spec end -desc "Finds all Avo gems and outputs theyr paths" +desc "Finds all Avo gems and outputs their paths" task "avo:gem_paths" do config = YAML.load_file("../support/gems.yml") From 6d91834e44f245af5723b4501a71de04f5b0f62d Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:22:13 +0300 Subject: [PATCH 09/30] refactor: remove types (#3308) * rm types * add avo-hq/literal * add avo-initializer * rename gem * add dependency on "prop_initializer" --- Gemfile.lock | 5 +-- app/components/avo/actions_component.rb | 30 ++++++++--------- app/components/avo/alert_component.rb | 4 +-- .../avo/asset_manager/javascript_component.rb | 2 +- .../avo/asset_manager/stylesheet_component.rb | 2 +- .../avo/backtrace_alert_component.rb | 2 +- app/components/avo/base_component.rb | 2 +- app/components/avo/button_component.rb | 27 +++++++-------- app/components/avo/cover_photo_component.rb | 4 +-- app/components/avo/divider_component.rb | 4 +-- app/components/avo/empty_state_component.rb | 8 ++--- app/components/avo/field_wrapper_component.rb | 32 +++++++++--------- .../fields/common/badge_viewer_component.rb | 4 +-- .../fields/common/boolean_check_component.rb | 6 ++-- .../fields/common/boolean_group_component.rb | 4 +-- .../fields/common/files/controls_component.rb | 6 ++-- .../common/files/list_viewer_component.rb | 4 +-- .../files/view_type/grid_item_component.rb | 8 ++--- .../common/gravatar_viewer_component.rb | 14 ++++---- .../avo/fields/common/heading_component.rb | 2 +- .../avo/fields/common/key_value_component.rb | 6 ++-- .../fields/common/progress_bar_component.rb | 10 +++--- .../fields/common/status_viewer_component.rb | 4 +-- .../avo/fields/tags_field/tag_component.rb | 4 +-- app/components/avo/filters_component.rb | 8 ++--- app/components/avo/flash_alerts_component.rb | 2 +- .../avo/index/field_wrapper_component.rb | 14 ++++---- .../avo/index/grid_item_component.rb | 10 +++--- .../avo/index/resource_controls_component.rb | 12 +++---- .../avo/index/resource_grid_component.rb | 12 +++---- .../avo/index/resource_table_component.rb | 16 ++++----- .../avo/index/table_row_component.rb | 14 ++++---- app/components/avo/items/panel_component.rb | 22 ++++++------- .../avo/items/visible_items_component.rb | 10 +++--- app/components/avo/loading_component.rb | 2 +- app/components/avo/modal_component.rb | 6 ++-- app/components/avo/paginator_component.rb | 12 +++---- app/components/avo/panel_component.rb | 20 +++++------ app/components/avo/panel_name_component.rb | 8 ++--- app/components/avo/profile_item_component.rb | 18 +++++----- app/components/avo/profile_photo_component.rb | 2 +- .../avo/referrer_params_component.rb | 2 +- .../avo/resource_sidebar_component.rb | 12 +++---- app/components/avo/row_component.rb | 4 +-- app/components/avo/row_selector_component.rb | 4 +-- .../avo/sidebar/base_item_component.rb | 5 ++- .../avo/sidebar/heading_component.rb | 10 +++--- app/components/avo/sidebar/link_component.rb | 14 ++++---- app/components/avo/sidebar_component.rb | 4 +-- .../avo/sidebar_profile_component.rb | 2 +- app/components/avo/tab_group_component.rb | 12 +++---- app/components/avo/tab_switcher_component.rb | 10 +++--- .../avo/turbo_frame_wrapper_component.rb | 2 +- .../avo/views/resource_edit_component.rb | 10 +++--- .../avo/views/resource_index_component.rb | 33 ++++++++----------- .../avo/views/resource_show_component.rb | 12 +++---- avo.gemspec | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile | 1 + gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 11 +++++-- gemfiles/rails_6.1_ruby_3.3.0.gemfile | 1 + gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 11 +++++-- gemfiles/rails_7.1_ruby_3.1.4.gemfile | 1 + gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 11 +++++-- gemfiles/rails_7.1_ruby_3.3.0.gemfile | 1 + gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 11 +++++-- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile | 1 + .../rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 11 +++++-- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile | 1 + .../rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 11 +++++-- gemfiles/rails_8.0_ruby_3.1.4.gemfile | 1 + gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 11 +++++-- gemfiles/rails_8.0_ruby_3.3.0.gemfile | 1 + gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 11 +++++-- 73 files changed, 335 insertions(+), 281 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9ad349eec..2013d62df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,9 +115,9 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) + prop_initializer turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -391,7 +391,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -450,6 +449,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) psych (5.1.2) stringio public_suffix (6.0.1) diff --git a/app/components/avo/actions_component.rb b/app/components/avo/actions_component.rb index c2da20804..0829acb8b 100644 --- a/app/components/avo/actions_component.rb +++ b/app/components/avo/actions_component.rb @@ -3,34 +3,32 @@ class Avo::ActionsComponent < Avo::BaseComponent include Avo::ApplicationHelper - ACTION_FILTER = _Set(_Class(Avo::BaseAction)) - - prop :as_row_control, _Boolean, default: false - prop :icon, _Nilable(String) - prop :size, Avo::ButtonComponent::SIZE, default: :md - prop :title, _Nilable(String) - prop :color, _Nilable(Symbol) do |value| + prop :as_row_control, default: false + prop :icon + prop :size, default: :md + prop :title + prop :color do |value| value || :primary end - prop :include, _Nilable(ACTION_FILTER), default: [].freeze do |include| + prop :include, default: [].freeze do |include| Array(include).to_set end - prop :custom_list, _Boolean, default: false - prop :label, _Nilable(String) do |label| + prop :custom_list, default: false + prop :label do |label| if @custom_list label else label || I18n.t("avo.actions") end end - prop :style, Avo::ButtonComponent::STYLE, default: :outline - prop :actions, _Array(_Any), default: [].freeze - prop :exclude, _Nilable(ACTION_FILTER), default: [].freeze do |exclude| + prop :style, default: :outline + prop :actions, default: [].freeze + prop :exclude, default: [].freeze do |exclude| Array(exclude).to_set end - prop :resource, _Nilable(Avo::BaseResource) - prop :view, _Nilable(Avo::ViewInquirer) - prop :host_component, _Nilable(_Any) + prop :resource + prop :view + prop :host_component delegate_missing_to :@host_component diff --git a/app/components/avo/alert_component.rb b/app/components/avo/alert_component.rb index 1b64513ff..60a4dd72e 100644 --- a/app/components/avo/alert_component.rb +++ b/app/components/avo/alert_component.rb @@ -3,8 +3,8 @@ class Avo::AlertComponent < Avo::BaseComponent include Avo::ApplicationHelper - prop :type, Symbol, :positional - prop :message, String, :positional + prop :type, kind: :positional + prop :message, kind: :positional def icon return "heroicons/solid/exclamation-circle" if is_error? diff --git a/app/components/avo/asset_manager/javascript_component.rb b/app/components/avo/asset_manager/javascript_component.rb index 55a52b35e..3de1aa8ee 100644 --- a/app/components/avo/asset_manager/javascript_component.rb +++ b/app/components/avo/asset_manager/javascript_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Avo::AssetManager::JavascriptComponent < Avo::BaseComponent - prop :asset_manager, Avo::AssetManager + prop :asset_manager delegate :javascripts, to: :@asset_manager end diff --git a/app/components/avo/asset_manager/stylesheet_component.rb b/app/components/avo/asset_manager/stylesheet_component.rb index 0b5d3e135..1345e4df0 100644 --- a/app/components/avo/asset_manager/stylesheet_component.rb +++ b/app/components/avo/asset_manager/stylesheet_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Avo::AssetManager::StylesheetComponent < Avo::BaseComponent - prop :asset_manager, Avo::AssetManager + prop :asset_manager delegate :stylesheets, to: :@asset_manager end diff --git a/app/components/avo/backtrace_alert_component.rb b/app/components/avo/backtrace_alert_component.rb index 4c9dfe902..1bb2b218b 100644 --- a/app/components/avo/backtrace_alert_component.rb +++ b/app/components/avo/backtrace_alert_component.rb @@ -3,7 +3,7 @@ class Avo::BacktraceAlertComponent < Avo::BaseComponent include Avo::ApplicationHelper - prop :backtrace, _Nilable(Array) + prop :backtrace def render? @backtrace.present? diff --git a/app/components/avo/base_component.rb b/app/components/avo/base_component.rb index cefdfcd20..aadcbbaf5 100644 --- a/app/components/avo/base_component.rb +++ b/app/components/avo/base_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Avo::BaseComponent < ViewComponent::Base - extend Literal::Properties + extend PropInitializer::Properties include Turbo::FramesHelper include Avo::Concerns::FindAssociationField diff --git a/app/components/avo/button_component.rb b/app/components/avo/button_component.rb index 0b22d398d..09926c4da 100644 --- a/app/components/avo/button_component.rb +++ b/app/components/avo/button_component.rb @@ -1,23 +1,20 @@ # frozen_string_literal: true class Avo::ButtonComponent < Avo::BaseComponent - SIZE = _Union(:xs, :sm, :md, :lg, :xl) - STYLE = _Union(:primary, :outline, :text, :icon) - - prop :path, _Nilable(String), :positional - prop :size, Symbol, default: :md - prop :style, Symbol, default: :outline - prop :color, Symbol, default: :gray - prop :icon, _Nilable(Symbol) do |value| + prop :path, kind: :positional + prop :size, default: :md + prop :style, default: :outline + prop :color, default: :gray + prop :icon do |value| value&.to_sym end - prop :icon_class, String, default: "" - prop :is_link, _Boolean, default: false - prop :rounded, _Boolean, default: true - prop :compact, _Boolean, default: false - prop :aria, Hash, default: {}.freeze - prop :args, Hash, :**, default: {}.freeze - prop :class, _Nilable(String) + prop :icon_class, default: "" + prop :is_link, default: false + prop :rounded, default: true + prop :compact, default: false + prop :aria, default: {}.freeze + prop :args, kind: :**, default: {}.freeze + prop :class def args if @args[:loading] diff --git a/app/components/avo/cover_photo_component.rb b/app/components/avo/cover_photo_component.rb index b264c6707..3e27c491c 100644 --- a/app/components/avo/cover_photo_component.rb +++ b/app/components/avo/cover_photo_component.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class Avo::CoverPhotoComponent < Avo::BaseComponent - prop :cover_photo, _Nilable(Avo::CoverPhoto) - prop :size, _Nilable(Symbol) do |value| + prop :cover_photo + prop :size do |value| @cover_photo&.size end diff --git a/app/components/avo/divider_component.rb b/app/components/avo/divider_component.rb index 8d505854f..625108945 100644 --- a/app/components/avo/divider_component.rb +++ b/app/components/avo/divider_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Avo::DividerComponent < Avo::BaseComponent - prop :label, _Nilable(String), :positional - prop :args, Hash, :** + prop :label, kind: :positional + prop :args, kind: :** end diff --git a/app/components/avo/empty_state_component.rb b/app/components/avo/empty_state_component.rb index 2c76abb99..df7404f8c 100644 --- a/app/components/avo/empty_state_component.rb +++ b/app/components/avo/empty_state_component.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true class Avo::EmptyStateComponent < Avo::BaseComponent - prop :message, _Nilable(String) - prop :view_type, Symbol, default: :table do |value| + prop :message + prop :view_type, default: :table do |value| value&.to_sym end - prop :add_background, _Boolean, default: false - prop :by_association, _Boolean, default: false + prop :add_background, default: false + prop :by_association, default: false def text @message || locale_message diff --git a/app/components/avo/field_wrapper_component.rb b/app/components/avo/field_wrapper_component.rb index fae0bce1a..48bfb1a99 100644 --- a/app/components/avo/field_wrapper_component.rb +++ b/app/components/avo/field_wrapper_component.rb @@ -3,24 +3,24 @@ class Avo::FieldWrapperComponent < Avo::BaseComponent include Avo::Concerns::HasResourceStimulusControllers - prop :dash_if_blank, _Boolean, default: true - prop :data, Hash, default: {}.freeze - prop :compact, _Boolean, default: false - prop :help, _Nilable(String) - prop :field, _Nilable(Avo::Fields::BaseField) - prop :form, _Nilable(ActionView::Helpers::FormBuilder) - prop :full_width, _Boolean, default: false - prop :label, _Nilable(String) - prop :resource, _Nilable(Avo::BaseResource) - prop :short, _Boolean, default: false - prop :stacked, _Nilable(_Boolean) - prop :style, String, default: "" - prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:show).freeze - prop :label_for, _Nilable(Symbol) do |value| + prop :dash_if_blank, default: true + prop :data, default: {}.freeze + prop :compact, default: false + prop :help + prop :field + prop :form + prop :full_width, default: false + prop :label + prop :resource + prop :short, default: false + prop :stacked + prop :style, default: "" + prop :view, default: Avo::ViewInquirer.new(:show).freeze + prop :label_for do |value| value&.to_sym end - prop :args, Hash, :**, default: {}.freeze - prop :classes, _Nilable(String) do |value| + prop :args, kind: :**, default: {}.freeze + prop :classes do |value| @args&.dig(:class) || "" end diff --git a/app/components/avo/fields/common/badge_viewer_component.rb b/app/components/avo/fields/common/badge_viewer_component.rb index 2a0d1d6dc..de3680789 100644 --- a/app/components/avo/fields/common/badge_viewer_component.rb +++ b/app/components/avo/fields/common/badge_viewer_component.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class Avo::Fields::Common::BadgeViewerComponent < Avo::BaseComponent - prop :value, _Union(_String, _Symbol) - prop :options, Hash + prop :value + prop :options def after_initialize @backgrounds = { diff --git a/app/components/avo/fields/common/boolean_check_component.rb b/app/components/avo/fields/common/boolean_check_component.rb index 6bc34bd59..a6d69071e 100644 --- a/app/components/avo/fields/common/boolean_check_component.rb +++ b/app/components/avo/fields/common/boolean_check_component.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::BooleanCheckComponent < Avo::BaseComponent - prop :checked, _Boolean, default: false - prop :icon, _Nilable(String) do |value| + prop :checked, default: false + prop :icon do |value| @checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle" end - prop :classes, _Nilable(String) do |value| + prop :classes do |value| "h-6 #{@checked ? "text-green-600" : "text-red-500"}" end end diff --git a/app/components/avo/fields/common/boolean_group_component.rb b/app/components/avo/fields/common/boolean_group_component.rb index 44a2ff7e4..6b7887f96 100644 --- a/app/components/avo/fields/common/boolean_group_component.rb +++ b/app/components/avo/fields/common/boolean_group_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Avo::Fields::Common::BooleanGroupComponent < Avo::BaseComponent - prop :options, Hash, default: {}.freeze - prop :value, _Nilable(Hash) + prop :options, default: {}.freeze + prop :value end diff --git a/app/components/avo/fields/common/files/controls_component.rb b/app/components/avo/fields/common/files/controls_component.rb index f8d82df76..1fb24d75c 100644 --- a/app/components/avo/fields/common/files/controls_component.rb +++ b/app/components/avo/fields/common/files/controls_component.rb @@ -6,9 +6,9 @@ class Avo::Fields::Common::Files::ControlsComponent < Avo::BaseComponent delegate :id, to: :@field - prop :field, Avo::Fields::BaseField - prop :file, _Any - prop :resource, Avo::BaseResource + prop :field + prop :file + prop :resource def destroy_path Avo::Services::URIService.parse(@resource.record_path).append_paths("active_storage_attachments", id, @file.id).to_s diff --git a/app/components/avo/fields/common/files/list_viewer_component.rb b/app/components/avo/fields/common/files/list_viewer_component.rb index ffd7c1f1d..fbf1ac1fe 100644 --- a/app/components/avo/fields/common/files/list_viewer_component.rb +++ b/app/components/avo/fields/common/files/list_viewer_component.rb @@ -3,8 +3,8 @@ class Avo::Fields::Common::Files::ListViewerComponent < Avo::BaseComponent include Turbo::FramesHelper - prop :field, Avo::Fields::BaseField - prop :resource, Avo::BaseResource + prop :field + prop :resource def classes base_classes = "py-4 rounded-2xl max-w-full" diff --git a/app/components/avo/fields/common/files/view_type/grid_item_component.rb b/app/components/avo/fields/common/files/view_type/grid_item_component.rb index 07ef3b448..013596eaa 100644 --- a/app/components/avo/fields/common/files/view_type/grid_item_component.rb +++ b/app/components/avo/fields/common/files/view_type/grid_item_component.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true class Avo::Fields::Common::Files::ViewType::GridItemComponent < Avo::BaseComponent - prop :field, Avo::Fields::BaseField - prop :resource, Avo::BaseResource - prop :file, _Nilable(_Any) - prop :extra_classes, _Nilable(String) + prop :field + prop :resource + prop :file + prop :extra_classes def id @field.id diff --git a/app/components/avo/fields/common/gravatar_viewer_component.rb b/app/components/avo/fields/common/gravatar_viewer_component.rb index 159a9b4ef..85bd53a20 100644 --- a/app/components/avo/fields/common/gravatar_viewer_component.rb +++ b/app/components/avo/fields/common/gravatar_viewer_component.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::GravatarViewerComponent < Avo::BaseComponent - prop :md5, _Nilable(String) - prop :link, _Nilable(String) - prop :default, _Nilable(String) - prop :size, _Nilable(Integer) - prop :rounded, _Boolean, default: false - prop :link_to_record, _Boolean, default: false - prop :title, _Nilable(String) + prop :md5 + prop :link + prop :default + prop :size + prop :rounded, default: false + prop :link_to_record, default: false + prop :title end diff --git a/app/components/avo/fields/common/heading_component.rb b/app/components/avo/fields/common/heading_component.rb index 552af9be9..74d5270db 100644 --- a/app/components/avo/fields/common/heading_component.rb +++ b/app/components/avo/fields/common/heading_component.rb @@ -3,7 +3,7 @@ class Avo::Fields::Common::HeadingComponent < Avo::BaseComponent include Avo::Concerns::HasResourceStimulusControllers - prop :field, Avo::Fields::BaseField + prop :field def after_initialize @view = @field.resource.view diff --git a/app/components/avo/fields/common/key_value_component.rb b/app/components/avo/fields/common/key_value_component.rb index a3e8a6f8a..ffe32b678 100644 --- a/app/components/avo/fields/common/key_value_component.rb +++ b/app/components/avo/fields/common/key_value_component.rb @@ -3,7 +3,7 @@ class Avo::Fields::Common::KeyValueComponent < Avo::BaseComponent include Avo::ApplicationHelper - prop :field, Avo::Fields::BaseField - prop :form, _Nilable(ActionView::Helpers::FormBuilder) - prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:show).freeze + prop :field + prop :form + prop :view, default: Avo::ViewInquirer.new(:show).freeze end diff --git a/app/components/avo/fields/common/progress_bar_component.rb b/app/components/avo/fields/common/progress_bar_component.rb index 41b6496e6..ee3516bcf 100644 --- a/app/components/avo/fields/common/progress_bar_component.rb +++ b/app/components/avo/fields/common/progress_bar_component.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class Avo::Fields::Common::ProgressBarComponent < Avo::BaseComponent - prop :value, Integer - prop :display_value, _Boolean, default: false - prop :value_suffix, _Nilable(String) - prop :max, Integer, default: 100 - prop :view, Avo::ViewInquirer, reader: :public, default: Avo::ViewInquirer.new(:index).freeze + prop :value + prop :display_value, default: false + prop :value_suffix + prop :max, default: 100 + prop :view, reader: :public, default: Avo::ViewInquirer.new(:index).freeze delegate :show?, :index?, to: :view end diff --git a/app/components/avo/fields/common/status_viewer_component.rb b/app/components/avo/fields/common/status_viewer_component.rb index 08516677d..5eb44530f 100644 --- a/app/components/avo/fields/common/status_viewer_component.rb +++ b/app/components/avo/fields/common/status_viewer_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Avo::Fields::Common::StatusViewerComponent < Avo::BaseComponent - prop :status, String - prop :label, String + prop :status + prop :label end diff --git a/app/components/avo/fields/tags_field/tag_component.rb b/app/components/avo/fields/tags_field/tag_component.rb index b0abde8f9..39156a222 100644 --- a/app/components/avo/fields/tags_field/tag_component.rb +++ b/app/components/avo/fields/tags_field/tag_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Avo::Fields::TagsField::TagComponent < Avo::BaseComponent - prop :label, _Nilable(String) - prop :title, _Nilable(String) + prop :label + prop :title end diff --git a/app/components/avo/filters_component.rb b/app/components/avo/filters_component.rb index d5fc5accf..63f70ce22 100644 --- a/app/components/avo/filters_component.rb +++ b/app/components/avo/filters_component.rb @@ -3,10 +3,10 @@ class Avo::FiltersComponent < Avo::BaseComponent include Avo::ApplicationHelper - prop :filters, _Array(Avo::Filters::BaseFilter), default: [].freeze - prop :resource, _Nilable(Avo::BaseResource) - prop :applied_filters, Hash, default: {}.freeze - prop :parent_record, _Nilable(_Any) + prop :filters, default: [].freeze + prop :resource + prop :applied_filters, default: {}.freeze + prop :parent_record def render? @filters.present? diff --git a/app/components/avo/flash_alerts_component.rb b/app/components/avo/flash_alerts_component.rb index 72c015c72..3a435e59a 100644 --- a/app/components/avo/flash_alerts_component.rb +++ b/app/components/avo/flash_alerts_component.rb @@ -3,5 +3,5 @@ class Avo::FlashAlertsComponent < Avo::BaseComponent include Avo::ApplicationHelper - prop :flashes, ActionDispatch::Flash::FlashHash, default: [].freeze + prop :flashes, default: [].freeze end diff --git a/app/components/avo/index/field_wrapper_component.rb b/app/components/avo/index/field_wrapper_component.rb index 14ef3de84..b4927f44a 100644 --- a/app/components/avo/index/field_wrapper_component.rb +++ b/app/components/avo/index/field_wrapper_component.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true class Avo::Index::FieldWrapperComponent < Avo::BaseComponent - prop :field, _Nilable(Avo::Fields::BaseField) - prop :resource, _Nilable(Avo::BaseResource) - prop :dash_if_blank, _Boolean, default: true - prop :center_content, _Boolean, default: false - prop :flush, _Boolean, default: false - prop :args, Hash, :**, default: {}.freeze - prop :classes, _Nilable(String) do |value| + prop :field + prop :resource + prop :dash_if_blank, default: true + prop :center_content, default: false + prop :flush, default: false + prop :args, kind: :**, default: {}.freeze + prop :classes do |value| @args&.dig(:class) || "" end diff --git a/app/components/avo/index/grid_item_component.rb b/app/components/avo/index/grid_item_component.rb index a5ce6e086..06d392196 100644 --- a/app/components/avo/index/grid_item_component.rb +++ b/app/components/avo/index/grid_item_component.rb @@ -4,11 +4,11 @@ class Avo::Index::GridItemComponent < Avo::BaseComponent include Avo::ResourcesHelper include Avo::Fields::Concerns::HasHTMLAttributes - prop :resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :actions, _Nilable(_Array(Avo::BaseAction)) + prop :resource + prop :reflection + prop :parent_record + prop :parent_resource + prop :actions def after_initialize @card = Avo::ExecutionContext.new(target: @resource.grid_view[:card], resource: @resource, record: @resource.record).handle diff --git a/app/components/avo/index/resource_controls_component.rb b/app/components/avo/index/resource_controls_component.rb index d2475291a..fad687912 100644 --- a/app/components/avo/index/resource_controls_component.rb +++ b/app/components/avo/index/resource_controls_component.rb @@ -4,12 +4,12 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent include Avo::ApplicationHelper include Avo::Concerns::ChecksShowAuthorization - prop :resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :view_type, Symbol, default: :table - prop :actions, _Nilable(_Array(Avo::BaseAction)) + prop :resource + prop :reflection + prop :parent_record + prop :parent_resource + prop :view_type, default: :table + prop :actions def can_detach? is_has_many_association? ? super : false diff --git a/app/components/avo/index/resource_grid_component.rb b/app/components/avo/index/resource_grid_component.rb index 8955c7749..32728e026 100644 --- a/app/components/avo/index/resource_grid_component.rb +++ b/app/components/avo/index/resource_grid_component.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true class Avo::Index::ResourceGridComponent < Avo::BaseComponent - prop :resources, _Array(_Nilable(Avo::BaseResource)) - prop :resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public + prop :resources + prop :resource + prop :reflection + prop :parent_record + prop :parent_resource + prop :actions, reader: :public end diff --git a/app/components/avo/index/resource_table_component.rb b/app/components/avo/index/resource_table_component.rb index a434a69c3..68f0afcd6 100644 --- a/app/components/avo/index/resource_table_component.rb +++ b/app/components/avo/index/resource_table_component.rb @@ -8,14 +8,14 @@ def before_render @header_fields, @table_row_components = cache_table_rows end - prop :resources, _Nilable(_Array(Avo::BaseResource)) - prop :resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :pagy, _Nilable(Pagy) - prop :query, _Nilable(_Any) - prop :actions, _Nilable(_Array(Avo::BaseAction)) + prop :resources + prop :resource + prop :reflection + prop :parent_record + prop :parent_resource + prop :pagy + prop :query + prop :actions def encrypted_query # TODO: move this to the resource where we can apply the adapter pattern diff --git a/app/components/avo/index/table_row_component.rb b/app/components/avo/index/table_row_component.rb index 298ddd9af..82cac0896 100644 --- a/app/components/avo/index/table_row_component.rb +++ b/app/components/avo/index/table_row_component.rb @@ -6,13 +6,13 @@ class Avo::Index::TableRowComponent < Avo::BaseComponent attr_writer :header_fields - prop :resource, _Nilable(Avo::BaseResource), reader: :public - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :actions, _Nilable(_Array(Avo::BaseAction)) - prop :fields, _Nilable(_Array(Avo::Fields::BaseField)) - prop :header_fields, _Nilable(_Array(String)) + prop :resource, reader: :public + prop :reflection + prop :parent_record + prop :parent_resource + prop :actions + prop :fields + prop :header_fields def resource_controls_component Avo::Index::ResourceControlsComponent.new( diff --git a/app/components/avo/items/panel_component.rb b/app/components/avo/items/panel_component.rb index aa6b0f816..5e0dc8ce7 100644 --- a/app/components/avo/items/panel_component.rb +++ b/app/components/avo/items/panel_component.rb @@ -3,17 +3,17 @@ class Avo::Items::PanelComponent < Avo::ResourceComponent include Avo::ApplicationHelper - prop :form, _Nilable(ActionView::Helpers::FormBuilder) - prop :item, _Nilable(Avo::Resources::Items::Panel) - prop :is_main_panel, _Nilable(_Boolean) - prop :resource, Avo::BaseResource - prop :view, Avo::ViewInquirer - prop :actions, _Nilable(_Array(Avo::BaseAction)), reader: :public - prop :index, _Nilable(Integer), reader: :public - prop :parent_component, _Nilable(ViewComponent::Base) - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) + prop :form + prop :item + prop :is_main_panel + prop :resource + prop :view + prop :actions, reader: :public + prop :index, reader: :public + prop :parent_component + prop :parent_record + prop :parent_resource + prop :reflection delegate :controls, :title, diff --git a/app/components/avo/items/visible_items_component.rb b/app/components/avo/items/visible_items_component.rb index d6d782e92..ccc1deb99 100644 --- a/app/components/avo/items/visible_items_component.rb +++ b/app/components/avo/items/visible_items_component.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true class Avo::Items::VisibleItemsComponent < Avo::BaseComponent - prop :resource, _Nilable(Avo::BaseResource) - prop :item, _Nilable(Avo::Concerns::IsResourceItem) - prop :view, _Nilable(Avo::ViewInquirer) - prop :form, _Nilable(ActionView::Helpers::FormBuilder) - prop :field_component_extra_args, _Nilable(Hash), default: {}.freeze + prop :resource + prop :item + prop :view + prop :form + prop :field_component_extra_args, default: {}.freeze end diff --git a/app/components/avo/loading_component.rb b/app/components/avo/loading_component.rb index 6398fa62d..bf0440f57 100644 --- a/app/components/avo/loading_component.rb +++ b/app/components/avo/loading_component.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Avo::LoadingComponent < Avo::BaseComponent - prop :title, _Nilable(String) + prop :title end diff --git a/app/components/avo/modal_component.rb b/app/components/avo/modal_component.rb index 8a55a587d..eb40f2470 100644 --- a/app/components/avo/modal_component.rb +++ b/app/components/avo/modal_component.rb @@ -4,9 +4,9 @@ class Avo::ModalComponent < Avo::BaseComponent renders_one :heading renders_one :controls - prop :width, Symbol, default: :md - prop :body_class, _Nilable(String) - prop :overflow, _Nilable(Symbol), default: :auto + prop :width, default: :md + prop :body_class + prop :overflow, default: :auto def width_classes case @width.to_sym diff --git a/app/components/avo/paginator_component.rb b/app/components/avo/paginator_component.rb index ccde48c7d..318197b7f 100644 --- a/app/components/avo/paginator_component.rb +++ b/app/components/avo/paginator_component.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true class Avo::PaginatorComponent < Avo::BaseComponent - prop :resource, _Nilable(Avo::BaseResource) - prop :parent_record, _Nilable(_Any) - prop :pagy, _Nilable(Pagy) - prop :turbo_frame, _Nilable(_Union(String, Symbol)) do |frame| + prop :resource + prop :parent_record + prop :pagy + prop :turbo_frame do |frame| frame.present? ? CGI.escapeHTML(frame) : :_top end - prop :index_params, _Nilable(Hash) - prop :discreet_pagination, _Nilable(_Boolean) + prop :index_params + prop :discreet_pagination def change_items_per_page_url(option) if @parent_record.present? diff --git a/app/components/avo/panel_component.rb b/app/components/avo/panel_component.rb index e8e24f54c..ca5a7631f 100644 --- a/app/components/avo/panel_component.rb +++ b/app/components/avo/panel_component.rb @@ -15,16 +15,16 @@ class Avo::PanelComponent < Avo::BaseComponent renders_one :footer_tools renders_one :footer - prop :description, _Nilable(String) - prop :body_classes, _Nilable(String) - prop :data, Hash, default: {}.freeze - prop :display_breadcrumbs, _Boolean, default: false - prop :index, _Nilable(Integer) - prop :classes, _Nilable(String) - prop :profile_photo, _Nilable(Avo::ProfilePhoto) - prop :cover_photo, _Nilable(Avo::CoverPhoto) - prop :args, Hash, :**, default: {}.freeze - prop :name, _Nilable(_Union(_String, _Integer)) do |value| + prop :description + prop :body_classes + prop :data, default: {}.freeze + prop :display_breadcrumbs, default: false + prop :index + prop :classes + prop :profile_photo + prop :cover_photo + prop :args, kind: :**, default: {}.freeze + prop :name do |value| value || @args&.dig(:title) end diff --git a/app/components/avo/panel_name_component.rb b/app/components/avo/panel_name_component.rb index 73172fcab..f9a4c04dc 100644 --- a/app/components/avo/panel_name_component.rb +++ b/app/components/avo/panel_name_component.rb @@ -3,10 +3,10 @@ class Avo::PanelNameComponent < Avo::BaseComponent renders_one :body - prop :name, _Nilable(_Union(_String, _Integer)) - prop :url, _Nilable(String) - prop :target, Symbol, default: :self do |value| + prop :name + prop :url + prop :target, default: :self do |value| value&.to_sym end - prop :classes, String, default: "" + prop :classes, default: "" end diff --git a/app/components/avo/profile_item_component.rb b/app/components/avo/profile_item_component.rb index af23326b7..16567d40b 100644 --- a/app/components/avo/profile_item_component.rb +++ b/app/components/avo/profile_item_component.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true class Avo::ProfileItemComponent < Avo::BaseComponent - prop :label, _Nilable(String), reader: :public - prop :icon, _Nilable(String), reader: :public - prop :path, _Nilable(String), reader: :public - prop :active, Symbol, default: :inclusive, reader: :public do |value| + prop :label, reader: :public + prop :icon, reader: :public + prop :path, reader: :public + prop :active, default: :inclusive, reader: :public do |value| value&.to_sym end - prop :target, _Nilable(Symbol), reader: :public do |value| + prop :target, reader: :public do |value| value&.to_sym end - prop :title, _Nilable(String), reader: :public - prop :method, _Nilable(_Union(_String, _Symbol)), reader: :public - prop :params, _Nilable(Hash), default: {}.freeze, reader: :public - prop :classes, String, default: "", reader: :public + prop :title, reader: :public + prop :method, reader: :public + prop :params, default: {}.freeze, reader: :public + prop :classes, default: "", reader: :public def title @title || @label diff --git a/app/components/avo/profile_photo_component.rb b/app/components/avo/profile_photo_component.rb index c35a6da3c..8323e9397 100644 --- a/app/components/avo/profile_photo_component.rb +++ b/app/components/avo/profile_photo_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Avo::ProfilePhotoComponent < Avo::BaseComponent - prop :profile_photo, _Nilable(Avo::ProfilePhoto) + prop :profile_photo def render? @profile_photo.present? && @profile_photo.visible_in_current_view? diff --git a/app/components/avo/referrer_params_component.rb b/app/components/avo/referrer_params_component.rb index 4c05e14a8..40b5a1d6f 100644 --- a/app/components/avo/referrer_params_component.rb +++ b/app/components/avo/referrer_params_component.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Avo::ReferrerParamsComponent < Avo::BaseComponent - prop :back_path, _Nilable(String) + prop :back_path end diff --git a/app/components/avo/resource_sidebar_component.rb b/app/components/avo/resource_sidebar_component.rb index 303a13b65..9ddf3590a 100644 --- a/app/components/avo/resource_sidebar_component.rb +++ b/app/components/avo/resource_sidebar_component.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true class Avo::ResourceSidebarComponent < Avo::BaseComponent - prop :resource, _Nilable(Avo::BaseResource) - prop :sidebar, _Nilable(Avo::Resources::Items::Sidebar) - prop :index, _Nilable(Integer) - prop :params, _Nilable(ActionController::Parameters) - prop :form, _Nilable(ActionView::Helpers::FormBuilder) - prop :view, _Nilable(Avo::ViewInquirer), reader: :public + prop :resource + prop :sidebar + prop :index + prop :params + prop :form + prop :view, reader: :public def render? Avo.license.has_with_trial(:resource_sidebar) diff --git a/app/components/avo/row_component.rb b/app/components/avo/row_component.rb index 76d4673ad..a6c249d33 100644 --- a/app/components/avo/row_component.rb +++ b/app/components/avo/row_component.rb @@ -3,6 +3,6 @@ class Avo::RowComponent < Avo::BaseComponent renders_one :body - prop :classes, _Nilable(String) - prop :data, Hash, default: {}.freeze + prop :classes + prop :data, default: {}.freeze end diff --git a/app/components/avo/row_selector_component.rb b/app/components/avo/row_selector_component.rb index d565d472f..734e309bd 100644 --- a/app/components/avo/row_selector_component.rb +++ b/app/components/avo/row_selector_component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true class Avo::RowSelectorComponent < Avo::BaseComponent - prop :floating, _Boolean, default: false - prop :size, Symbol, default: :md + prop :floating, default: false + prop :size, default: :md end diff --git a/app/components/avo/sidebar/base_item_component.rb b/app/components/avo/sidebar/base_item_component.rb index 93e5004d4..f21c88f7b 100644 --- a/app/components/avo/sidebar/base_item_component.rb +++ b/app/components/avo/sidebar/base_item_component.rb @@ -3,9 +3,8 @@ class Avo::Sidebar::BaseItemComponent < Avo::BaseComponent delegate :collapsable, :collapsed, to: :@item - # Object = Avo::Menu::BaseItem || ViewComponent::Base - prop :item, _Nilable(Object), reader: :public - prop :locals, _Nilable(Hash), default: {}.freeze + prop :item, reader: :public + prop :locals, default: {}.freeze def after_initialize @items = @item.items.select(&:visible?) diff --git a/app/components/avo/sidebar/heading_component.rb b/app/components/avo/sidebar/heading_component.rb index d6488db7f..02dee1e3c 100644 --- a/app/components/avo/sidebar/heading_component.rb +++ b/app/components/avo/sidebar/heading_component.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true class Avo::Sidebar::HeadingComponent < Avo::BaseComponent - prop :label, _Nilable(String) - prop :icon, _Nilable(String) - prop :collapsable, _Boolean, default: false - prop :collapsed, _Boolean, default: false - prop :key, _Nilable(String) + prop :label + prop :icon + prop :collapsable, default: false + prop :collapsed, default: false + prop :key end diff --git a/app/components/avo/sidebar/link_component.rb b/app/components/avo/sidebar/link_component.rb index ba155a2d2..663a6d885 100644 --- a/app/components/avo/sidebar/link_component.rb +++ b/app/components/avo/sidebar/link_component.rb @@ -1,17 +1,17 @@ # frozen_string_literal: true class Avo::Sidebar::LinkComponent < Avo::BaseComponent - prop :label, _Nilable(String) - prop :path, _Nilable(String) - prop :active, Symbol, default: :inclusive do |value| + prop :label + prop :path + prop :active, default: :inclusive do |value| value&.to_sym end - prop :target, _Nilable(Symbol) do |value| + prop :target do |value| value&.to_sym end - prop :data, Hash, default: {}.freeze - prop :icon, _Nilable(String) - prop :args, Hash, :**, default: {}.freeze + prop :data, default: {}.freeze + prop :icon + prop :args, kind: :**, default: {}.freeze def is_external? # If the path contains the scheme, check if it includes the root path or not diff --git a/app/components/avo/sidebar_component.rb b/app/components/avo/sidebar_component.rb index 30f6942a9..39310097a 100644 --- a/app/components/avo/sidebar_component.rb +++ b/app/components/avo/sidebar_component.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true class Avo::SidebarComponent < Avo::BaseComponent - prop :sidebar_open, _Boolean, default: false - prop :for_mobile, _Boolean, default: false + prop :sidebar_open, default: false + prop :for_mobile, default: false def dashboards return [] unless Avo.plugin_manager.installed?(:avo_dashboards) diff --git a/app/components/avo/sidebar_profile_component.rb b/app/components/avo/sidebar_profile_component.rb index 8c2aa1f38..258287f83 100644 --- a/app/components/avo/sidebar_profile_component.rb +++ b/app/components/avo/sidebar_profile_component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Avo::SidebarProfileComponent < Avo::BaseComponent - prop :user, _Nilable(_Any) + prop :user def avatar if @user.respond_to?(:avatar) && @user.avatar.present? diff --git a/app/components/avo/tab_group_component.rb b/app/components/avo/tab_group_component.rb index 7d3140575..730d6e4ea 100644 --- a/app/components/avo/tab_group_component.rb +++ b/app/components/avo/tab_group_component.rb @@ -3,12 +3,12 @@ class Avo::TabGroupComponent < Avo::BaseComponent delegate :group_param, to: :@group - prop :resource, Avo::BaseResource, reader: :public - prop :group, Avo::Resources::Items::TabGroup, reader: :public - prop :index, Integer, reader: :public - prop :form, _Nilable(ActionView::Helpers::FormBuilder), reader: :public - prop :params, ActionController::Parameters, reader: :public - prop :view, Avo::ViewInquirer, reader: :public + prop :resource, reader: :public + prop :group, reader: :public + prop :index, reader: :public + prop :form, reader: :public + prop :params, reader: :public + prop :view, reader: :public def after_initialize group.index = index diff --git a/app/components/avo/tab_switcher_component.rb b/app/components/avo/tab_switcher_component.rb index 16c13b80a..0a891f884 100644 --- a/app/components/avo/tab_switcher_component.rb +++ b/app/components/avo/tab_switcher_component.rb @@ -7,11 +7,11 @@ class Avo::TabSwitcherComponent < Avo::BaseComponent delegate :white_panel_classes, to: :helpers delegate :group_param, to: :@group - prop :resource, Avo::BaseResource - prop :group, Avo::Resources::Items::TabGroup - prop :current_tab, Avo::Resources::Items::Tab - prop :active_tab_name, String, reader: :public - prop :view, Avo::ViewInquirer + prop :resource + prop :group + prop :current_tab + prop :active_tab_name, reader: :public + prop :view #TOD: helper to record: def tab_path(tab) diff --git a/app/components/avo/turbo_frame_wrapper_component.rb b/app/components/avo/turbo_frame_wrapper_component.rb index c070c3777..d21e0197f 100644 --- a/app/components/avo/turbo_frame_wrapper_component.rb +++ b/app/components/avo/turbo_frame_wrapper_component.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Avo::TurboFrameWrapperComponent < Avo::BaseComponent - prop :name, _Nilable(String), :positional + prop :name, kind: :positional end diff --git a/app/components/avo/views/resource_edit_component.rb b/app/components/avo/views/resource_edit_component.rb index 5f5163e74..36cafac81 100644 --- a/app/components/avo/views/resource_edit_component.rb +++ b/app/components/avo/views/resource_edit_component.rb @@ -3,11 +3,11 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent include Avo::ApplicationHelper - prop :resource, _Nilable(Avo::BaseResource) - prop :record, _Nilable(_Any) - prop :actions, _Array(Avo::BaseAction), default: [].freeze - prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:edit).freeze - prop :display_breadcrumbs, _Boolean, default: true, reader: :public + prop :resource + prop :record + prop :actions, default: [].freeze + prop :view, default: Avo::ViewInquirer.new(:edit).freeze + prop :display_breadcrumbs, default: true, reader: :public def after_initialize @display_breadcrumbs = @reflection.blank? && display_breadcrumbs diff --git a/app/components/avo/views/resource_index_component.rb b/app/components/avo/views/resource_index_component.rb index c70805a66..92122977e 100644 --- a/app/components/avo/views/resource_index_component.rb +++ b/app/components/avo/views/resource_index_component.rb @@ -4,25 +4,20 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent include Avo::ResourcesHelper include Avo::ApplicationHelper - prop :resource, _Nilable(Avo::BaseResource) - prop :resources, _Nilable(_Array(Avo::BaseResource)) - # This is sometimes an array of records or an ActiveRecord::Relation - prop :records, Enumerable, default: [].freeze - prop :pagy, _Nilable(Pagy) - prop :index_params, Hash, default: {}.freeze - prop :filters, _Array(Avo::Filters::BaseFilter), default: [].freeze - prop :actions, _Array(Avo::BaseAction), default: [].freeze - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :turbo_frame, _Nilable(String), default: "" - prop :parent_record, _Nilable(_Any) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :applied_filters, Hash, default: {}.freeze - prop :query, _Nilable(_Any), reader: :public - # This should be - # prop :scopes, _Nilable(_Array(Avo::Advanced::Scopes::BaseScope)), reader: :public - # However, Avo::Advanced::Scopes::BaseScope raises an error because - # that constant is only available in the advanced repo - prop :scopes, _Nilable(Object), reader: :public + prop :resource + prop :resources + prop :records, default: [].freeze + prop :pagy + prop :index_params, default: {}.freeze + prop :filters, default: [].freeze + prop :actions, default: [].freeze + prop :reflection + prop :turbo_frame, default: "" + prop :parent_record + prop :parent_resource + prop :applied_filters, default: {}.freeze + prop :query, reader: :public + prop :scopes, reader: :public def title if @reflection.present? diff --git a/app/components/avo/views/resource_show_component.rb b/app/components/avo/views/resource_show_component.rb index 08560278c..33f255cc9 100644 --- a/app/components/avo/views/resource_show_component.rb +++ b/app/components/avo/views/resource_show_component.rb @@ -5,12 +5,12 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent attr_reader :display_breadcrumbs - prop :resource, _Nilable(Avo::BaseResource) - prop :reflection, _Nilable(ActiveRecord::Reflection::AbstractReflection) - prop :parent_resource, _Nilable(Avo::BaseResource) - prop :parent_record, _Nilable(_Any) - prop :resource_panel, _Nilable(_Array(Avo::BaseAction)), reader: :public - prop :actions, _Array(Avo::BaseAction), default: [].freeze, reader: :public + prop :resource + prop :reflection + prop :parent_resource + prop :parent_record + prop :resource_panel, reader: :public + prop :actions, default: [].freeze, reader: :public def after_initialize @view = Avo::ViewInquirer.new("show") diff --git a/avo.gemspec b/avo.gemspec index 20365b79b..8a7aa3416 100644 --- a/avo.gemspec +++ b/avo.gemspec @@ -45,7 +45,7 @@ Gem::Specification.new do |spec| spec.add_dependency "turbo_power", ">= 0.6.0" spec.add_dependency "addressable" spec.add_dependency "meta-tags" - spec.add_dependency "literal", "~> 0.2" spec.add_dependency "docile" spec.add_dependency "inline_svg" + spec.add_dependency "prop_initializer" end diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile b/gemfiles/rails_6.1_ruby_3.1.4.gemfile index 570b31bae..43ceee92f 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index 1cb5cb1e4..b17572465 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -349,7 +356,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -695,6 +701,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile b/gemfiles/rails_6.1_ruby_3.3.0.gemfile index 570b31bae..43ceee92f 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index 168c75d19..e749c3268 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -323,7 +330,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -668,6 +674,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile b/gemfiles/rails_7.1_ruby_3.1.4.gemfile index 759f8a33e..067d64387 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index f4746475f..4011fe202 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -362,7 +369,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -716,6 +722,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile b/gemfiles/rails_7.1_ruby_3.3.0.gemfile index 759f8a33e..067d64387 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 0bbfc8450..2679c9a12 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -336,7 +343,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -689,6 +695,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile index 68b5b0698..e549b25d7 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 95d5ceb1f..54cd23edc 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -336,7 +343,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -689,6 +695,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.2.0.beta2) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile index 68b5b0698..e549b25d7 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 95d5ceb1f..54cd23edc 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + PATH remote: ../pluggy specs: @@ -21,7 +29,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -336,7 +343,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -689,6 +695,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.2.0.beta2) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile b/gemfiles/rails_8.0_ruby_3.1.4.gemfile index 5366e6ffa..5ce3a78c7 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 10a1e003b..1df715e63 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + GIT remote: https://github.com/rails/rails.git revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e @@ -120,7 +128,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -365,7 +372,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -697,6 +703,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails! diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile b/gemfiles/rails_8.0_ruby_3.3.0.gemfile index 5366e6ffa..5ce3a78c7 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile @@ -45,6 +45,7 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" +gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 10a1e003b..1df715e63 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -5,6 +5,14 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) +GIT + remote: https://github.com/avo-hq/prop_initializer.git + revision: ec6808bc18b00ee53123497e885305d4d63da9de + branch: main + specs: + prop_initializer (0.1.0) + zeitwerk (>= 2.6.18) + GIT remote: https://github.com/rails/rails.git revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e @@ -120,7 +128,6 @@ PATH addressable docile inline_svg - literal (~> 0.2) meta-tags pagy (>= 7.0.0) turbo-rails (>= 2.0.0) @@ -365,7 +372,6 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - literal (0.2.1) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) @@ -697,6 +703,7 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids + prop_initializer! psych (< 4) puma (~> 6.4) rails! From abdebf44c7c90da9c30f692445a6b59a35761458 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:11:18 +0300 Subject: [PATCH 10/30] chore: update `prop_initializer` dependency (#3331) * chore: update `prop_initializer` dependency * lint --- Gemfile.lock | 4 ++-- avo.gemspec | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile | 1 - gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 12 +++--------- gemfiles/rails_6.1_ruby_3.3.0.gemfile | 1 - gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 12 +++--------- gemfiles/rails_7.1_ruby_3.1.4.gemfile | 1 - gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 12 +++--------- gemfiles/rails_7.1_ruby_3.3.0.gemfile | 1 - gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 12 +++--------- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile | 1 - gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 12 +++--------- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile | 1 - gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 12 +++--------- gemfiles/rails_8.0_ruby_3.1.4.gemfile | 1 - gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 12 +++--------- gemfiles/rails_8.0_ruby_3.3.0.gemfile | 1 - gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 12 +++--------- 18 files changed, 27 insertions(+), 83 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2013d62df..6fe6af235 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -117,7 +117,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) - prop_initializer + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -449,7 +449,7 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) - prop_initializer (0.1.0) + prop_initializer (0.2.0) zeitwerk (>= 2.6.18) psych (5.1.2) stringio diff --git a/avo.gemspec b/avo.gemspec index 8a7aa3416..e7d24f18a 100644 --- a/avo.gemspec +++ b/avo.gemspec @@ -47,5 +47,5 @@ Gem::Specification.new do |spec| spec.add_dependency "meta-tags" spec.add_dependency "docile" spec.add_dependency "inline_svg" - spec.add_dependency "prop_initializer" + spec.add_dependency "prop_initializer", ">= 0.2.0" end diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile b/gemfiles/rails_6.1_ruby_3.1.4.gemfile index 43ceee92f..570b31bae 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index b17572465..d6e1fafc3 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -412,6 +405,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -701,7 +696,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile b/gemfiles/rails_6.1_ruby_3.3.0.gemfile index 43ceee92f..570b31bae 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index e749c3268..7669fc016 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -386,6 +379,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -674,7 +669,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile b/gemfiles/rails_7.1_ruby_3.1.4.gemfile index 067d64387..759f8a33e 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index 4011fe202..0933f41bc 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -425,6 +418,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -722,7 +717,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile b/gemfiles/rails_7.1_ruby_3.3.0.gemfile index 067d64387..759f8a33e 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 2679c9a12..22b17cfc7 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -399,6 +392,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -695,7 +690,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile index e549b25d7..68b5b0698 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 54cd23edc..79e23e70a 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -399,6 +392,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -695,7 +690,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.2.0.beta2) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile index e549b25d7..68b5b0698 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 54cd23edc..79e23e70a 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - PATH remote: ../pluggy specs: @@ -31,6 +23,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -399,6 +392,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -695,7 +690,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails (~> 7.2.0.beta2) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile b/gemfiles/rails_8.0_ruby_3.1.4.gemfile index 5ce3a78c7..5366e6ffa 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 1df715e63..278ae3185 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - GIT remote: https://github.com/rails/rails.git revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e @@ -130,6 +122,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -428,6 +421,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -703,7 +698,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails! diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile b/gemfiles/rails_8.0_ruby_3.3.0.gemfile index 5ce3a78c7..5366e6ffa 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile @@ -45,7 +45,6 @@ gem "avo-money_field" gem "avo-record_link_field" gem "pagy", "> 8" gem "csv" -gem "prop_initializer", branch: "main", git: "https://github.com/avo-hq/prop_initializer.git" gem "psych", "< 4" group :development do diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 1df715e63..278ae3185 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -5,14 +5,6 @@ GIT acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 8) -GIT - remote: https://github.com/avo-hq/prop_initializer.git - revision: ec6808bc18b00ee53123497e885305d4d63da9de - branch: main - specs: - prop_initializer (0.1.0) - zeitwerk (>= 2.6.18) - GIT remote: https://github.com/rails/rails.git revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e @@ -130,6 +122,7 @@ PATH inline_svg meta-tags pagy (>= 7.0.0) + prop_initializer (>= 0.2.0) turbo-rails (>= 2.0.0) turbo_power (>= 0.6.0) view_component (>= 3.7.0) @@ -428,6 +421,8 @@ GEM hashids (>= 1.0.0, < 2.0.0) rails (>= 6.0.0) prettier_print (1.2.1) + prop_initializer (0.2.0) + zeitwerk (>= 2.6.18) psych (3.3.4) public_suffix (6.0.1) puma (6.4.3) @@ -703,7 +698,6 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pluggy! prefixed_ids - prop_initializer! psych (< 4) puma (~> 6.4) rails! From 58dbd0ea07332d4749a85d5c74418504c3a26b55 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Fri, 11 Oct 2024 18:05:04 +0300 Subject: [PATCH 11/30] Bumped avo to 3.13.6 --- Gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6fe6af235..aa6a9e652 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index d6e1fafc3..9eabd8e2e 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index 7669fc016..612be2489 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index 0933f41bc..f533229b0 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 22b17cfc7..a039b19b5 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 79e23e70a..9a286cbc0 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 79e23e70a..9a286cbc0 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 278ae3185..b22cb87c6 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 278ae3185..b22cb87c6 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.5) + avo (3.13.6) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index d736c6c3a..4f19e6de4 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.5" unless const_defined?(:VERSION) + VERSION = "3.13.6" unless const_defined?(:VERSION) end From 62c16ae9003b9e66b0cc88b9ee4720ce39075b2d Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Mon, 14 Oct 2024 08:26:44 +0100 Subject: [PATCH 12/30] Made TestHelpers include methods from WaitForLoaded (#3325) Right now many of the test helpers don't work in any other project because they rely on methods from WaitForLoaded and the test helpers crash when they are called. This isn't an issue in the avo project itself because the WaitForLoaded methods are required automatically by the avo test suite. It isn't possible to load WaitForLoaded in projects using the rubygem of avo because files inside the spec directory aren't included (and even if they were it would be a bit weird to load something from `spec/support` in a gem). To fix this I've moved WaitForLoaded alongside the TestHelpers module and included it from there so the helper methods can be used in other projects. --- lib/avo/test_helpers.rb | 2 + lib/avo/wait_for_loaded.rb | 108 ++++++++++++++++++++++++++++++++ spec/rails_helper.rb | 1 - spec/support/wait_for_loaded.rb | 104 ------------------------------ 4 files changed, 110 insertions(+), 105 deletions(-) create mode 100644 lib/avo/wait_for_loaded.rb delete mode 100644 spec/support/wait_for_loaded.rb diff --git a/lib/avo/test_helpers.rb b/lib/avo/test_helpers.rb index acf310f57..9fba97c50 100644 --- a/lib/avo/test_helpers.rb +++ b/lib/avo/test_helpers.rb @@ -1,5 +1,7 @@ module Avo module TestHelpers + include WaitForLoaded + # Finds the wrapper element on the index view for the given field id and type, and associated with the given record id # Example usage: # index_field_wrapper(id: "name", type: "text", record_id: 2) diff --git a/lib/avo/wait_for_loaded.rb b/lib/avo/wait_for_loaded.rb new file mode 100644 index 000000000..3a6d051a3 --- /dev/null +++ b/lib/avo/wait_for_loaded.rb @@ -0,0 +1,108 @@ +require "timeout" + +module Avo + module WaitForLoaded + def wait_for_route_loading(time = Capybara.default_max_wait_time) + Timeout.timeout(time) { sleep(0.01) until page.find("body")[:class].include?("route-loading") } + end + + def wait_for_route_loaded(time = Capybara.default_max_wait_time) + Timeout.timeout(time) { sleep(0.01) while page.find("body")[:class].include?("route-loading") } + end + + def wait_for_turbo_loaded(time = Capybara.default_max_wait_time) + wait_for_body_class_missing("turbo-loading", time) + end + + def wait_for_search_loaded(time = Capybara.default_max_wait_time) + wait_for_body_class_missing("search-loading", time) + end + + def wait_for_search_to_dissapear(time = Capybara.default_max_wait_time) + wait_for_element_missing(".aa-DetachedOverlay", time) + end + + def wait_for_turbo_frame_id(frame_id = "", time = Capybara.default_max_wait_time) + wait_for_element_missing("turbo-frame[id='#{frame_id}'][busy]", time) + end + + def wait_for_turbo_frame_src(frame_src = "", time = Capybara.default_max_wait_time) + wait_for_element_missing("turbo-frame[src='#{frame_src}'][busy]", time) + end + + def wait_for_body_class_missing(klass = "turbo-loading", time = Capybara.default_max_wait_time) + Timeout.timeout(time) do + body = page.find(:xpath, "//body") + break if !body[:class].to_s.include?(klass) + + if page.present? && body.present? && body[:class].present? && body[:class].is_a?(String) + sleep(0.1) until page.present? && !body[:class].to_s.include?(klass) + else + sleep 0.1 + end + end + rescue Timeout::Error + puts "\n\nMethod '#{__method__}' raised 'Timeout::Error' after #{time}s" + end + + def wait_for_element_missing(identifier = ".element", time = Capybara.default_max_wait_time) + Timeout.timeout(time) do + if page.present? + break if page.has_no_css?(identifier, wait: time) + else + sleep 0.05 + end + end + end + + def wait_for_element_present(identifier = ".element", time = Capybara.default_max_wait_time) + Timeout.timeout(time) do + if page.present? + break if page.has_css?(identifier, wait: time) + else + sleep 0.05 + end + end + end + + def wait_for_loaded + wait_for_turbo_loaded + end + + def wait_for_action_dialog_to_disappear(time = Capybara.default_max_wait_time) + wait_for_element_missing("[role='dialog']", time) + end + + def wait_for_tag_to_disappear(tag, time = Capybara.default_max_wait_time) + Capybara.using_wait_time(time) do + page.has_no_css?(".tagify__tag", text: tag) + end + end + + def wait_for_tag_to_appear(tag, time = Capybara.default_max_wait_time) + Capybara.using_wait_time(time) do + page.has_css?(".tagify__tag", text: tag) + end + end + + def wait_for_tag_suggestions_to_appear(time = Capybara.default_max_wait_time) + Capybara.using_wait_time(time) do + page.has_css?(".tagify__dropdown") + end + + current_count = prev_count = page.all(".tagify__dropdown__item").count + attempts = 5 + + loop do + sleep(0.05) + current_count = page.all(".tagify__dropdown__item").count + + # Break when suggestions stop appearing + # Or attempts reach 0 + attempts -= 1 + break if (current_count == prev_count) || (attempts == 0) + prev_count = current_count + end + end + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ac22e484f..c7985c6ed 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -205,7 +205,6 @@ def headless_download_setup(driver) require "support/helpers" require "support/factory_bot" require "support/database_cleaner" -require "support/wait_for_loaded" require "support/js_error_detector" require "support/devise" require "support/shared_contexts" diff --git a/spec/support/wait_for_loaded.rb b/spec/support/wait_for_loaded.rb deleted file mode 100644 index 562a1e026..000000000 --- a/spec/support/wait_for_loaded.rb +++ /dev/null @@ -1,104 +0,0 @@ -require "timeout" - -def wait_for_route_loading(time = Capybara.default_max_wait_time) - Timeout.timeout(time) { sleep(0.01) until page.find("body")[:class].include?("route-loading") } -end - -def wait_for_route_loaded(time = Capybara.default_max_wait_time) - Timeout.timeout(time) { sleep(0.01) while page.find("body")[:class].include?("route-loading") } -end - -def wait_for_turbo_loaded(time = Capybara.default_max_wait_time) - wait_for_body_class_missing("turbo-loading", time) -end - -def wait_for_search_loaded(time = Capybara.default_max_wait_time) - wait_for_body_class_missing("search-loading", time) -end - -def wait_for_search_to_dissapear(time = Capybara.default_max_wait_time) - wait_for_element_missing(".aa-DetachedOverlay", time) -end - -def wait_for_turbo_frame_id(frame_id = "", time = Capybara.default_max_wait_time) - wait_for_element_missing("turbo-frame[id='#{frame_id}'][busy]", time) -end - -def wait_for_turbo_frame_src(frame_src = "", time = Capybara.default_max_wait_time) - wait_for_element_missing("turbo-frame[src='#{frame_src}'][busy]", time) -end - -def wait_for_body_class_missing(klass = "turbo-loading", time = Capybara.default_max_wait_time) - Timeout.timeout(time) do - body = page.find(:xpath, "//body") - break if !body[:class].to_s.include?(klass) - - if page.present? && body.present? && body[:class].present? && body[:class].is_a?(String) - sleep(0.1) until page.present? && !body[:class].to_s.include?(klass) - else - sleep 0.1 - end - end -rescue Timeout::Error - puts "\n\nMethod '#{__method__}' raised 'Timeout::Error' after #{time}s" -end - -def wait_for_element_missing(identifier = ".element", time = Capybara.default_max_wait_time) - Timeout.timeout(time) do - if page.present? - break if page.has_no_css?(identifier, wait: time) - else - sleep 0.05 - end - end -end - -def wait_for_element_present(identifier = ".element", time = Capybara.default_max_wait_time) - Timeout.timeout(time) do - if page.present? - break if page.has_css?(identifier, wait: time) - else - sleep 0.05 - end - end -end - -def wait_for_loaded - wait_for_turbo_loaded -end - -def wait_for_action_dialog_to_disappear(time = Capybara.default_max_wait_time) - wait_for_element_missing("[role='dialog']", time) -end - -def wait_for_tag_to_disappear(tag, time = Capybara.default_max_wait_time) - Capybara.using_wait_time(time) do - page.has_no_css?(".tagify__tag", text: tag) - end -end - -def wait_for_tag_to_appear(tag, time = Capybara.default_max_wait_time) - Capybara.using_wait_time(time) do - page.has_css?(".tagify__tag", text: tag) - end -end - -def wait_for_tag_suggestions_to_appear(time = Capybara.default_max_wait_time) - Capybara.using_wait_time(time) do - page.has_css?(".tagify__dropdown") - end - - current_count = prev_count = page.all('.tagify__dropdown__item').count - attempts = 5 - - loop do - sleep(0.05) - current_count = page.all('.tagify__dropdown__item').count - - # Break when suggestions stop appearing - # Or attempts reach 0 - attempts -= 1 - break if (current_count == prev_count) || (attempts == 0) - prev_count = current_count - end -end From 7a4046a641c5c2303c9639eb8e47533bc40d3b34 Mon Sep 17 00:00:00 2001 From: Roc Khalil Date: Mon, 14 Oct 2024 12:05:53 +0300 Subject: [PATCH 13/30] =?UTF-8?q?=E2=9C=A8=20Controls=20placement=20on=20r?= =?UTF-8?q?esource=20level=20(#3320)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Controls placement on resource level * ♻️ Refactor to concern + add both sides * ✅ Add tests for controls placement --- .../avo/index/table_row_component.html.erb | 5 +- app/views/avo/partials/_table_header.html.erb | 4 +- lib/avo/concerns/controls_placement.rb | 27 +++++++++ .../configuration/resource_configuration.rb | 10 +--- lib/avo/resources/base.rb | 2 + .../avo/resource_controls_placement_spec.rb | 55 +++++++++++++++++-- 6 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 lib/avo/concerns/controls_placement.rb diff --git a/app/components/avo/index/table_row_component.html.erb b/app/components/avo/index/table_row_component.html.erb index 48b77e14e..0dff9248b 100644 --- a/app/components/avo/index/table_row_component.html.erb +++ b/app/components/avo/index/table_row_component.html.erb @@ -1,4 +1,5 @@ <%# hover:z-[21] removed from tr class to solve flickering actions component on row controls and z-20 changed to z-21%> + <%= content_tag :tr, class: class_names("bg-white hover:bg-gray-50 hover:shadow-row z-21 border-b", {"cursor-pointer": click_row_to_view_record}), data: { @@ -19,7 +20,7 @@ <% end %> - <% if Avo.configuration.resource_controls_on_the_left? %> + <% if @resource.resource_controls_render_on_the_left? %>
<%= render resource_controls_component %> @@ -41,7 +42,7 @@ — <% end %> <% end %> - <% if Avo.configuration.resource_controls_on_the_right? %> + <% if @resource.resource_controls_render_on_the_right? %>
<%= render resource_controls_component %> diff --git a/app/views/avo/partials/_table_header.html.erb b/app/views/avo/partials/_table_header.html.erb index 32ff1e622..bafb43bc0 100644 --- a/app/views/avo/partials/_table_header.html.erb +++ b/app/views/avo/partials/_table_header.html.erb @@ -26,7 +26,7 @@ <% end %> <% end %> - <% if Avo.configuration.resource_controls_on_the_left? %> + <% if @resource.resource_controls_render_on_the_left? %> @@ -100,7 +100,7 @@ <% end %> <% end %> <% end %> - <% if Avo.configuration.resource_controls_on_the_right? %> + <% if @resource.resource_controls_render_on_the_right? %> diff --git a/lib/avo/concerns/controls_placement.rb b/lib/avo/concerns/controls_placement.rb new file mode 100644 index 000000000..5ad97b25d --- /dev/null +++ b/lib/avo/concerns/controls_placement.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Avo + module Concerns + module ControlsPlacement + extend ActiveSupport::Concern + + def controls_placement_calculated + @controls_placement_calculated ||= controls_placement || Avo.configuration.resource_controls_placement + end + + def resource_controls_render_on_the_right? + controls_placement_calculated == :right || resource_controls_render_on_both_sides? + end + + def resource_controls_render_on_the_left? + controls_placement_calculated == :left || resource_controls_render_on_both_sides? + end + + private + + def resource_controls_render_on_both_sides? + controls_placement_calculated == :both + end + end + end +end diff --git a/lib/avo/configuration/resource_configuration.rb b/lib/avo/configuration/resource_configuration.rb index b1591ed5d..1ab694465 100644 --- a/lib/avo/configuration/resource_configuration.rb +++ b/lib/avo/configuration/resource_configuration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Avo class Configuration module ResourceConfiguration @@ -8,14 +10,6 @@ def resource_controls_placement=(val) def resource_controls_placement @resource_controls_placement_instance || :right end - - def resource_controls_on_the_left? - resource_controls_placement == :left - end - - def resource_controls_on_the_right? - resource_controls_placement == :right - end end end end diff --git a/lib/avo/resources/base.rb b/lib/avo/resources/base.rb index d1e4f3700..b14f2f26b 100644 --- a/lib/avo/resources/base.rb +++ b/lib/avo/resources/base.rb @@ -15,6 +15,7 @@ class Base include Avo::Concerns::HasHelpers include Avo::Concerns::Hydration include Avo::Concerns::Pagination + include Avo::Concerns::ControlsPlacement # Avo::Current methods delegate :context, to: Avo::Current @@ -78,6 +79,7 @@ def current_user class_attribute :components, default: {} class_attribute :default_sort_column, default: :created_at class_attribute :default_sort_direction, default: :desc + class_attribute :controls_placement, default: nil # EXTRACT: class_attribute :ordering diff --git a/spec/features/avo/resource_controls_placement_spec.rb b/spec/features/avo/resource_controls_placement_spec.rb index 84396331f..bb9c9b53a 100644 --- a/spec/features/avo/resource_controls_placement_spec.rb +++ b/spec/features/avo/resource_controls_placement_spec.rb @@ -10,25 +10,72 @@ end describe "with controls on the left" do - it "shows to the left" do + it "shows to the left when configured from Avo.configuration" do Avo.configuration.resource_controls_placement = :left visit "/admin/resources/comments" within find("table") do # XPath containing the index of the cell - expect(page).to have_xpath('tbody/tr[1]/td[1][@data-control="resource-controls"]') + expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']") + end + end + + it "shows to the left when configured from resource configuration" do + with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :left) do + visit "/admin/resources/comments" + + within find("table") do + # XPath containing the index of the cell + expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']") + end end end end describe "with controls on the right" do - it "shows to the right" do + it "shows to the right when configured from Avo.configuration" do Avo.configuration.resource_controls_placement = :right visit "/admin/resources/comments" within find("table") do # XPath containing the index of the cell - expect(page).to have_xpath('tbody/tr[1]/td[6][@data-control="resource-controls"]') + expect(page).to have_xpath("tbody/tr[1]/td[6][@data-control='resource-controls']") + end + end + + it "shows to the right when configured from resource configuration" do + with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :right) do + visit "/admin/resources/comments" + + within find("table") do + # XPath containing the index of the cell + expect(page).to have_xpath("tbody/tr[1]/td[6][@data-control='resource-controls']") + end + end + end + end + + describe "with controls on both sides" do + it "shows on both sides when configured from Avo.configuration" do + Avo.configuration.resource_controls_placement = :both + visit "/admin/resources/comments" + + within find("table") do + # XPath containing the index of the cell + expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']") + expect(page).to have_xpath("tbody/tr[1]/td[7][@data-control='resource-controls']") + end + end + + it "shows on both sides when configured from resource configuration" do + with_temporary_class_option(Avo::Resources::Comment, :controls_placement, :both) do + visit "/admin/resources/comments" + + within find("table") do + # XPath containing the index of the cell + expect(page).to have_xpath("tbody/tr[1]/td[1][@data-control='resource-controls']") + expect(page).to have_xpath("tbody/tr[1]/td[7][@data-control='resource-controls']") + end end end end From c0d852d7fab41c273dcb3bfc1254e76d9e33f836 Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Mon, 14 Oct 2024 21:18:20 +0100 Subject: [PATCH 14/30] Made the send_keys helper work in selenium as well as cuprite (#3328) A few of the test helpers use the `type` helper method but in selenium it raises this error: NoMethodError: undefined method `keyboard' for # I've changed this to check if the `keyboard` property exists and if it does not, try sending keys to the page instead (which works in selenium). --- lib/avo/test_helpers.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/avo/test_helpers.rb b/lib/avo/test_helpers.rb index 9fba97c50..4730e6957 100644 --- a/lib/avo/test_helpers.rb +++ b/lib/avo/test_helpers.rb @@ -315,7 +315,11 @@ def tag_suggestions(field:, input:) end def type(...) - page.driver.browser.keyboard.type(...) + if page.driver.browser.respond_to?(:keyboard) + page.driver.browser.keyboard.type(...) + else + page.send_keys(...) + end end def accept_custom_alert(&block) From bbd3c4340ad7cfba07e3d135b2a43b6eba430732 Mon Sep 17 00:00:00 2001 From: Robert Brandin Date: Tue, 15 Oct 2024 05:37:50 -0600 Subject: [PATCH 15/30] Check #email_address for sidebar name (#3340) --- app/components/avo/sidebar_profile_component.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/components/avo/sidebar_profile_component.rb b/app/components/avo/sidebar_profile_component.rb index 258287f83..e21416267 100644 --- a/app/components/avo/sidebar_profile_component.rb +++ b/app/components/avo/sidebar_profile_component.rb @@ -16,6 +16,8 @@ def name @user.name elsif @user.respond_to?(:email) && @user.email.present? @user.email + elsif @user.respond_to?(:email_address) && @user.email_address.present? + @user.email_address else "Avo user" end From 4fb7ea4d8a921ac303fd376155ada6aff8bae193 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:49:13 +0300 Subject: [PATCH 16/30] chore: update `view_component` to `3.17.0` (#3350) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index aa6a9e652..34d9a12d7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -643,7 +643,7 @@ GEM unicode-display_width (2.6.0) uri (0.13.1) useragent (0.16.10) - view_component (3.15.1) + view_component (3.17.0) activesupport (>= 5.2.0, < 8.0) concurrent-ruby (~> 1.0) method_source (~> 1.0) From 39ba83c23844e1b5534216c97aaeb2494c853376 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Mon, 21 Oct 2024 12:08:40 +0200 Subject: [PATCH 17/30] refactor: boolean group and checkbox improvements (#3279) * refactor: boolean group and checkbox improvements * fix test change red-500 to red-600 while asserting svg classes --------- Co-authored-by: Paul Bob --- .../fields/common/boolean_check_component.html.erb | 2 +- .../avo/fields/common/boolean_check_component.rb | 11 +++++++++-- .../fields/common/boolean_group_component.html.erb | 8 ++++---- .../avo/fields/common/boolean_group_component.rb | 4 ++++ spec/system/avo/boolean_group_field_spec.rb | 8 ++++---- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/components/avo/fields/common/boolean_check_component.html.erb b/app/components/avo/fields/common/boolean_check_component.html.erb index 3bef51608..6db564030 100644 --- a/app/components/avo/fields/common/boolean_check_component.html.erb +++ b/app/components/avo/fields/common/boolean_check_component.html.erb @@ -1 +1 @@ -<%= helpers.svg "#{@icon}.svg", class: @classes %> +<%= helpers.svg "#{@icon}.svg", class: classes %> diff --git a/app/components/avo/fields/common/boolean_check_component.rb b/app/components/avo/fields/common/boolean_check_component.rb index a6d69071e..70dcc6ce7 100644 --- a/app/components/avo/fields/common/boolean_check_component.rb +++ b/app/components/avo/fields/common/boolean_check_component.rb @@ -2,10 +2,17 @@ class Avo::Fields::Common::BooleanCheckComponent < Avo::BaseComponent prop :checked, default: false + prop :size, default: :md prop :icon do |value| @checked ? "heroicons/outline/check-circle" : "heroicons/outline/x-circle" end - prop :classes do |value| - "h-6 #{@checked ? "text-green-600" : "text-red-500"}" + + def classes + helpers.class_names({ + "h-5": @size == :sm, + "h-6": @size == :md, + "text-green-600": @checked, + "text-red-600": !@checked, + }) end end diff --git a/app/components/avo/fields/common/boolean_group_component.html.erb b/app/components/avo/fields/common/boolean_group_component.html.erb index 79e2d1302..5bbb3e968 100644 --- a/app/components/avo/fields/common/boolean_group_component.html.erb +++ b/app/components/avo/fields/common/boolean_group_component.html.erb @@ -1,11 +1,11 @@
<%= link_to t("avo.view").humanize, "javascript:void(0);", data: {"tippy-target": :source} %> <% end %> <% end %> diff --git a/lib/avo/licensing/h_q.rb b/lib/avo/licensing/h_q.rb index adb3fa38f..a2b9668e7 100644 --- a/lib/avo/licensing/h_q.rb +++ b/lib/avo/licensing/h_q.rb @@ -67,10 +67,16 @@ def payload app_name: app_name } - # metadata = Avo::Services::DebugService.avo_metadata - # if metadata[:resources_count] != 0 - # result[:avo_metadata] = "metadata" - # end + begin + metadata = Avo::Services::DebugService.avo_metadata + rescue => error + metadata = { + error_message: error.message, + error: "Failed to generate the Avo metadata" + } + end + + result[:avo_metadata] = metadata result end diff --git a/lib/avo/services/debug_service.rb b/lib/avo/services/debug_service.rb index 0f2689eb8..2716a5c36 100644 --- a/lib/avo/services/debug_service.rb +++ b/lib/avo/services/debug_service.rb @@ -17,11 +17,11 @@ def debug_report(request = nil) payload[:app_timezone] = Time.current.zone payload[:cache_key] = Avo::Licensing::HQ.cache_key payload[:cache_key_contents] = hq&.cached_response - payload[:plugins] = Avo.plugin_manager + payload[:plugins] = Avo.plugin_manager.as_json payload rescue => e - e + e.message end def get_thread_count @@ -31,46 +31,50 @@ def get_thread_count end def avo_metadata - resources = Avo.resource_manager.all + resource_classes = Avo.resource_manager.all dashboards = defined?(Avo::Dashboards) ? Avo::Dashboards.dashboard_manager.all : [] - # field_definitions = resources.map(&:get_field_definitions) - # fields_count = field_definitions.map(&:count).sum - # fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0)) + resources = resource_classes.map do |resource_class| + resource = resource_class.new view: :index + resource.detect_fields + resource + end + field_definitions = resources.map(&:get_field_definitions) + fields_count = field_definitions.map(&:count).sum + fields_per_resource = sprintf("%0.01f", fields_count / (resources.count + 0.0)).to_f - # field_types = {} - # custom_fields_count = 0 - # field_definitions.each do |fields| - # fields.each do |field| - # field_types[field.type] ||= 0 - # field_types[field.type] += 1 + field_types = {} + custom_fields_count = 0 + field_definitions.each do |fields| + fields.each do |field| + field_types[field.type] ||= 0 + field_types[field.type] += 1 - # custom_fields_count += 1 if field.custom? - # end - # end + custom_fields_count += 1 if field.custom? + end + end { resources_count: resources.count, dashboards_count: dashboards.count, - # fields_count: fields_count, - # fields_per_resource: fields_per_resource, - # custom_fields_count: custom_fields_count, - # field_types: field_types, - # **other_metadata(:actions), # TODO: this is fetching actions without hydration - # **other_metadata(:filters), + fields_count:, + fields_per_resource:, + custom_fields_count:, + field_types:, + **other_metadata(:actions, resources:), + **other_metadata(:filters, resources:), main_menu_present: Avo.configuration.main_menu.present?, profile_menu_present: Avo.configuration.profile_menu.present?, cache_store: Avo.cache_store&.class&.to_s, **config_metadata } - # rescue => error - # { - # error: error.message - # } + rescue => error + { + error: "Failed to generate the Avo metadata", + error_message: error.message + } end - def other_metadata(type = :actions) - resources = Avo.resource_manager.all - + def other_metadata(type = :actions, resources: []) types = resources.map(&:"get_#{type}") type_count = types.flatten.uniq.count type_per_resource = sprintf("%0.01f", types.map(&:count).sum / (resources.count + 0.0))