From 5c89f7dd5969f6fef751a11113c185b31463171f Mon Sep 17 00:00:00 2001 From: J Smith Date: Wed, 27 Nov 2024 01:09:39 -0400 Subject: [PATCH] fix: Rename Turbo Stream helpers to avoid clashes in user apps (#3462) --- app/controllers/avo/actions_controller.rb | 12 ++++++------ app/controllers/avo/associations_controller.rb | 2 +- app/controllers/avo/base_controller.rb | 4 ++-- app/helpers/avo/turbo_stream_actions_helper.rb | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/avo/actions_controller.rb b/app/controllers/avo/actions_controller.rb index 3aa65667b..a8ebd870c 100644 --- a/app/controllers/avo/actions_controller.rb +++ b/app/controllers/avo/actions_controller.rb @@ -104,13 +104,13 @@ def respond turbo_response = case @response[:type] when :keep_modal_open # Only render the flash messages if the action keeps the modal open - turbo_stream.flash_alerts + turbo_stream.avo_flash_alerts when :download # Trigger download, removes modal and flash the messages [ - turbo_stream.download(content: Base64.encode64(@response[:path]), filename: @response[:filename]), - turbo_stream.close_modal, - turbo_stream.flash_alerts + turbo_stream.avo_download(content: Base64.encode64(@response[:path]), filename: @response[:filename]), + turbo_stream.avo_close_modal, + turbo_stream.avo_flash_alerts ] when :navigate_to_action src, _ = @response[:action].link_arguments(resource: @action.resource, **@response[:navigate_to_action_args]) @@ -125,8 +125,8 @@ def respond when :close_modal # Close the modal and flash the messages [ - turbo_stream.close_modal, - turbo_stream.flash_alerts + turbo_stream.avo_close_modal, + turbo_stream.avo_flash_alerts ] else # Reload the page diff --git a/app/controllers/avo/associations_controller.rb b/app/controllers/avo/associations_controller.rb index 5542f51a9..f6be30b54 100644 --- a/app/controllers/avo/associations_controller.rb +++ b/app/controllers/avo/associations_controller.rb @@ -254,7 +254,7 @@ def reload_frame_turbo_streams turbo_streams = super # We want to close the modal if the user wants to add just one record - turbo_streams << turbo_stream.close_modal if params[:button] != "attach_another" + turbo_streams << turbo_stream.avo_close_modal if params[:button] != "attach_another" turbo_streams end diff --git a/app/controllers/avo/base_controller.rb b/app/controllers/avo/base_controller.rb index a19bdece0..49f8b5a6c 100644 --- a/app/controllers/avo/base_controller.rb +++ b/app/controllers/avo/base_controller.rb @@ -556,7 +556,7 @@ def destroy_fail_action flash[:error] = destroy_fail_message respond_to do |format| - format.turbo_stream { render turbo_stream: turbo_stream.flash_alerts } + format.turbo_stream { render turbo_stream: turbo_stream.avo_flash_alerts } end end @@ -660,7 +660,7 @@ def sanitized_sort_direction def reload_frame_turbo_streams [ turbo_stream.turbo_frame_reload(params[:turbo_frame]), - turbo_stream.flash_alerts + turbo_stream.avo_flash_alerts ] end end diff --git a/app/helpers/avo/turbo_stream_actions_helper.rb b/app/helpers/avo/turbo_stream_actions_helper.rb index 7dcd33790..e922d6549 100644 --- a/app/helpers/avo/turbo_stream_actions_helper.rb +++ b/app/helpers/avo/turbo_stream_actions_helper.rb @@ -1,16 +1,16 @@ module Avo module TurboStreamActionsHelper - def download(content:, filename:) + def avo_download(content:, filename:) turbo_stream_action_tag :download, content: content, filename: filename end - def flash_alerts + def avo_flash_alerts turbo_stream_action_tag :append, target: "alerts", template: @view_context.render(Avo::FlashAlertsComponent.new(flashes: @view_context.flash.discard)) end - def close_modal + def avo_close_modal turbo_stream_action_tag :replace, target: Avo::MODAL_FRAME_ID, template: @view_context.turbo_frame_tag(Avo::MODAL_FRAME_ID, data: {turbo_temporary: 1})