Skip to content

Commit

Permalink
Merge branch 'main' into refactor/maintain-pagination-in-associations
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Sep 26, 2024
2 parents 6d5fb16 + 0e91afb commit 60c40eb
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 111 deletions.
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT

GIT
remote: https://github.com/rails/rails.git
revision: 219e75354b516af0144035a49abcbfa6a380a2f2
revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e
branch: main
specs:
actioncable (8.0.0.alpha)
Expand Down Expand Up @@ -158,17 +158,17 @@ GEM
money-rails (~> 1.12)
avo-record_link_field (0.0.1)
aws-eventstream (1.3.0)
aws-partitions (1.977.0)
aws-sdk-core (3.206.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.163.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
Expand Down Expand Up @@ -404,8 +404,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.0.2)
meta-tags (2.22.0)
memory_profiler (1.1.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -547,7 +547,7 @@ GEM
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
ruby-statistics (3.0.2)
ruby-statistics (4.0.1)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
Expand Down Expand Up @@ -631,7 +631,7 @@ GEM
tilt (2.4.0)
timeout (0.4.1)
tty-which (0.5.0)
turbo-rails (2.0.9)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand Down Expand Up @@ -661,7 +661,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
36 changes: 27 additions & 9 deletions app/components/avo/actions_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,33 @@ class Avo::ActionsComponent < Avo::BaseComponent
prop :icon, _Nilable(String)
prop :size, Avo::ButtonComponent::SIZE, default: :md
prop :title, _Nilable(String)
prop :color, Symbol, default: :primary
prop :color, _Nilable(Symbol) do |value|
value || :primary
end
prop :include, _Nilable(ACTION_FILTER), default: [].freeze do |include|
Array(include).to_set
end
prop :label, String do |label|
label || I18n.t("avo.actions")
prop :custom_list, _Boolean, default: false
prop :label, _Nilable(String) do |label|
if @custom_list
label
else
label || I18n.t("avo.actions")
end
end
prop :style, Avo::ButtonComponent::STYLE, default: :outline
prop :actions, _Array(Avo::BaseAction), default: [].freeze
prop :actions, _Array(_Any), default: [].freeze
prop :exclude, _Nilable(ACTION_FILTER), default: [].freeze do |exclude|
Array(exclude).to_set
end
prop :resource, _Nilable(Avo::BaseResource)
prop :view, _Nilable(Avo::ViewInquirer)
prop :host_component, _Nilable(_Any)

delegate_missing_to :@host_component

def after_initialize
filter_actions
filter_actions unless @custom_list
end

def render?
Expand Down Expand Up @@ -61,8 +71,8 @@ def on_index_page?
!on_record_page?
end

def icon(action)
svg action.icon, class: "h-5 shrink-0 mr-1 inline pointer-events-none"
def icon(icon)
svg icon, class: "h-5 shrink-0 mr-1 inline pointer-events-none"
end

def render_item(action)
Expand All @@ -71,6 +81,14 @@ def render_item(action)
render_divider(action)
when Avo::BaseAction
render_action_link(action)
when defined?(Avo::Advanced::Resources::Controls::Action) && Avo::Advanced::Resources::Controls::Action
render_action_link(action.action, icon: action.icon)
when defined?(Avo::Advanced::Resources::Controls::LinkTo) && Avo::Advanced::Resources::Controls::LinkTo
link_to action.args[:path],
class: action.args.delete(:class) || "flex items-center px-4 py-3 w-full text-black font-semibold text-sm hover:bg-primary-100",
**action.args.except(:path, :label, :icon) do
raw("#{icon(action.args[:icon])} #{action.args[:label]}")
end
end
end

Expand All @@ -81,12 +99,12 @@ def render_divider(action)
render Avo::DividerComponent.new(label)
end

def render_action_link(action)
def render_action_link(action, icon: nil)
link_to action.link_arguments(resource: @resource, arguments: action.arguments).first,
data: action_data_attributes(action),
title: action.action_name,
class: action_css_class(action) do
raw("#{icon(action)} #{action.action_name}")
raw("#{icon(icon || action.icon)} #{action.action_name}")
end
end

Expand Down
22 changes: 11 additions & 11 deletions gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ GEM
money-rails (~> 1.12)
avo-record_link_field (0.0.1)
aws-eventstream (1.3.0)
aws-partitions (1.977.0)
aws-sdk-core (3.206.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.163.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
Expand Down Expand Up @@ -362,8 +362,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.0.2)
meta-tags (2.22.0)
memory_profiler (1.1.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -517,7 +517,7 @@ GEM
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
ruby-statistics (3.0.2)
ruby-statistics (4.0.1)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
Expand Down Expand Up @@ -599,7 +599,7 @@ GEM
tilt (2.4.0)
timeout (0.4.1)
tty-which (0.5.0)
turbo-rails (2.0.9)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand Down Expand Up @@ -627,7 +627,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
22 changes: 11 additions & 11 deletions gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ GEM
money-rails (~> 1.12)
avo-record_link_field (0.0.1)
aws-eventstream (1.3.0)
aws-partitions (1.977.0)
aws-sdk-core (3.206.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.163.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
Expand Down Expand Up @@ -336,8 +336,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.0.2)
meta-tags (2.22.0)
memory_profiler (1.1.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -490,7 +490,7 @@ GEM
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
ruby-statistics (3.0.2)
ruby-statistics (4.0.1)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
Expand Down Expand Up @@ -572,7 +572,7 @@ GEM
tilt (2.4.0)
timeout (0.4.1)
tty-which (0.5.0)
turbo-rails (2.0.9)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand Down Expand Up @@ -600,7 +600,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
22 changes: 11 additions & 11 deletions gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ GEM
money-rails (~> 1.12)
avo-record_link_field (0.0.1)
aws-eventstream (1.3.0)
aws-partitions (1.977.0)
aws-sdk-core (3.206.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.163.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
Expand Down Expand Up @@ -375,8 +375,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.0.2)
meta-tags (2.22.0)
memory_profiler (1.1.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -536,7 +536,7 @@ GEM
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
ruby-statistics (3.0.2)
ruby-statistics (4.0.1)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
Expand Down Expand Up @@ -619,7 +619,7 @@ GEM
tilt (2.4.0)
timeout (0.4.1)
tty-which (0.5.0)
turbo-rails (2.0.9)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand Down Expand Up @@ -648,7 +648,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
22 changes: 11 additions & 11 deletions gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ GEM
money-rails (~> 1.12)
avo-record_link_field (0.0.1)
aws-eventstream (1.3.0)
aws-partitions (1.977.0)
aws-sdk-core (3.206.0)
aws-partitions (1.979.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.163.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.0)
Expand Down Expand Up @@ -349,8 +349,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.4)
matrix (0.4.2)
memory_profiler (1.0.2)
meta-tags (2.22.0)
memory_profiler (1.1.0)
meta-tags (2.22.1)
actionpack (>= 6.0.0, < 8.1)
method_source (1.1.0)
mini_histogram (0.3.1)
Expand Down Expand Up @@ -509,7 +509,7 @@ GEM
rubocop-shopify (2.15.1)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
ruby-statistics (3.0.2)
ruby-statistics (4.0.1)
ruby-vips (2.2.2)
ffi (~> 1.12)
logger
Expand Down Expand Up @@ -592,7 +592,7 @@ GEM
tilt (2.4.0)
timeout (0.4.1)
tty-which (0.5.0)
turbo-rails (2.0.9)
turbo-rails (2.0.10)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand Down Expand Up @@ -621,7 +621,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
webrick (1.8.2)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
Loading

0 comments on commit 60c40eb

Please sign in to comment.