Skip to content

Commit

Permalink
Merge branch 'main' into feature/confirmation-message-before-save
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Simpson authored Jul 13, 2024
2 parents 7d6aa41 + 93e71b8 commit 3c60924
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 94 deletions.
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GIT

GIT
remote: https://github.com/rails/rails.git
revision: 4fa56814f18fd3da49c83931fa773caa727d8096
revision: 69d904e60f78300270ecbb01e4cf68e78074b30d
branch: main
specs:
actioncable (8.0.0.alpha)
Expand Down Expand Up @@ -115,7 +115,7 @@ GIT
PATH
remote: .
specs:
avo (3.10.2)
avo (3.10.5)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand Down Expand Up @@ -166,8 +166,8 @@ GEM
avo-record_link_field (0.0.1)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.951.0)
aws-sdk-core (3.201.0)
aws-partitions (1.955.0)
aws-sdk-core (3.201.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
Expand Down Expand Up @@ -352,7 +352,7 @@ GEM
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.7.2)
irb (1.13.2)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
iso (0.4.0)
Expand Down Expand Up @@ -390,7 +390,7 @@ GEM
meta-tags (2.2.0)
actionpack (>= 3.2.0)
method_source (1.1.0)
mini_magick (4.13.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.24.1)
Expand Down Expand Up @@ -422,7 +422,7 @@ GEM
orm_adapter (0.5.0)
pagy (8.6.3)
parallel (1.25.1)
parser (3.3.3.0)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
path_expander (1.1.1)
Expand All @@ -437,7 +437,7 @@ GEM
puma (6.4.2)
nio4r (~> 2.0)
racc (1.8.0)
rack (3.1.6)
rack (3.1.7)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -527,7 +527,7 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby_parser (3.21.0)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.9.0)
Expand All @@ -542,7 +542,7 @@ GEM
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
sexp_processor (4.17.1)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down
22 changes: 15 additions & 7 deletions app/controllers/avo/actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def respond

respond_to do |format|
format.turbo_stream do
case @response[:type]
turbo_response = case @response[:type]
when :keep_modal_open
# Only render the flash messages if the action keeps the modal open
render turbo_stream: turbo_stream.flash_alerts
turbo_stream.flash_alerts
when :download
# Trigger download, removes modal and flash the messages
render turbo_stream: [
[
turbo_stream.download(content: Base64.encode64(@response[:path]), filename: @response[:filename]),
turbo_stream.close_action_modal,
turbo_stream.flash_alerts
Expand All @@ -104,25 +104,33 @@ def respond
frame_id = Avo::ACTIONS_TURBO_FRAME_ID
src, _ = @response[:action].link_arguments(resource: @action.resource, **@response[:navigate_to_action_args])

render turbo_stream: turbo_stream.turbo_frame_set_src(frame_id, src)
turbo_stream.turbo_frame_set_src(frame_id, src)
when :redirect
render turbo_stream: turbo_stream.redirect_to(
turbo_stream.redirect_to(
Avo::ExecutionContext.new(target: @response[:path]).handle,
turbo_frame: @response[:redirect_args][:turbo_frame],
**@response[:redirect_args].except(:turbo_frame)
)
when :close_modal
# Close the modal and flash the messages
render turbo_stream: [
[
turbo_stream.close_action_modal,
turbo_stream.flash_alerts
]
else
# Reload the page
back_path = request.referer || params[:referrer].presence || resources_path(resource: @resource)

render turbo_stream: turbo_stream.redirect_to(back_path)
turbo_stream.redirect_to(back_path)
end

responses = if @action.appended_turbo_streams.present?
Array(turbo_response) + Array(instance_exec(&@action.appended_turbo_streams))
else
Array(turbo_response)
end

render turbo_stream: responses
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/avo/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def index
@query = @query.includes(*@resource.includes)
end

# Eager load attachments
if @resource.attachments.present?
@resource.attachments.each do |attachment|
@query = @query.send(:"with_attached_#{attachment}")
end
end

apply_sorting

# Apply filters to the current query
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/avo/debug_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def send_to_hq
body = params[:body]
body = {license_key: license_key, body: body, payload: Avo::Services::DebugService.debug_report(request).to_json}.to_json

Avo::Licensing::Request.post url, body:, timeout:
Avo::Licensing::Request.post(url, body:, timeout:)

render turbo_stream: turbo_stream.replace(:send_to_hq, plain: "Payload sent to Avo HQ.")
end
Expand Down
14 changes: 7 additions & 7 deletions gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
PATH
remote: ..
specs:
avo (3.10.1)
avo (3.10.2)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand Down Expand Up @@ -118,8 +118,8 @@ GEM
avo-record_link_field (0.0.1)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.951.0)
aws-sdk-core (3.201.0)
aws-partitions (1.955.0)
aws-sdk-core (3.201.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
Expand Down Expand Up @@ -309,7 +309,7 @@ GEM
meta-tags (2.21.0)
actionpack (>= 6.0.0, < 7.2)
method_source (1.1.0)
mini_magick (4.13.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.24.1)
monetize (1.13.0)
Expand Down Expand Up @@ -393,7 +393,7 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.1.1)
ransack (4.2.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
Expand Down Expand Up @@ -458,7 +458,7 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby_parser (3.21.0)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.9.1)
Expand All @@ -473,7 +473,7 @@ GEM
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
sexp_processor (4.17.1)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down
14 changes: 7 additions & 7 deletions gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
PATH
remote: ..
specs:
avo (3.10.1)
avo (3.10.2)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand Down Expand Up @@ -118,8 +118,8 @@ GEM
avo-record_link_field (0.0.1)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.951.0)
aws-sdk-core (3.201.0)
aws-partitions (1.955.0)
aws-sdk-core (3.201.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
Expand Down Expand Up @@ -309,7 +309,7 @@ GEM
meta-tags (2.21.0)
actionpack (>= 6.0.0, < 7.2)
method_source (1.1.0)
mini_magick (4.13.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.24.1)
monetize (1.13.0)
Expand Down Expand Up @@ -393,7 +393,7 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.1.1)
ransack (4.2.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
Expand Down Expand Up @@ -458,7 +458,7 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby_parser (3.21.0)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.9.1)
Expand All @@ -473,7 +473,7 @@ GEM
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
sexp_processor (4.17.1)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down
18 changes: 9 additions & 9 deletions gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
PATH
remote: ..
specs:
avo (3.10.1)
avo (3.10.2)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand Down Expand Up @@ -133,8 +133,8 @@ GEM
avo-record_link_field (0.0.1)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.951.0)
aws-sdk-core (3.201.0)
aws-partitions (1.955.0)
aws-sdk-core (3.201.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
Expand Down Expand Up @@ -292,7 +292,7 @@ GEM
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.7.2)
irb (1.13.2)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
iso (0.4.0)
Expand Down Expand Up @@ -330,7 +330,7 @@ GEM
meta-tags (2.21.0)
actionpack (>= 6.0.0, < 7.2)
method_source (1.1.0)
mini_magick (4.13.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.24.1)
monetize (1.13.0)
Expand Down Expand Up @@ -375,7 +375,7 @@ GEM
puma (6.4.2)
nio4r (~> 2.0)
racc (1.8.0)
rack (3.1.6)
rack (3.1.7)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -421,7 +421,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
ransack (4.1.1)
ransack (4.2.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
Expand Down Expand Up @@ -489,7 +489,7 @@ GEM
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
ruby_parser (3.21.0)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.9.1)
Expand All @@ -504,7 +504,7 @@ GEM
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
sexp_processor (4.17.1)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down
Loading

0 comments on commit 3c60924

Please sign in to comment.