Skip to content

Commit 5c89f7d

Browse files
committed
fix: Rename Turbo Stream helpers to avoid clashes in user apps (avo-hq#3462)
1 parent c60e854 commit 5c89f7d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

app/controllers/avo/actions_controller.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ def respond
104104
turbo_response = case @response[:type]
105105
when :keep_modal_open
106106
# Only render the flash messages if the action keeps the modal open
107-
turbo_stream.flash_alerts
107+
turbo_stream.avo_flash_alerts
108108
when :download
109109
# Trigger download, removes modal and flash the messages
110110
[
111-
turbo_stream.download(content: Base64.encode64(@response[:path]), filename: @response[:filename]),
112-
turbo_stream.close_modal,
113-
turbo_stream.flash_alerts
111+
turbo_stream.avo_download(content: Base64.encode64(@response[:path]), filename: @response[:filename]),
112+
turbo_stream.avo_close_modal,
113+
turbo_stream.avo_flash_alerts
114114
]
115115
when :navigate_to_action
116116
src, _ = @response[:action].link_arguments(resource: @action.resource, **@response[:navigate_to_action_args])
@@ -125,8 +125,8 @@ def respond
125125
when :close_modal
126126
# Close the modal and flash the messages
127127
[
128-
turbo_stream.close_modal,
129-
turbo_stream.flash_alerts
128+
turbo_stream.avo_close_modal,
129+
turbo_stream.avo_flash_alerts
130130
]
131131
else
132132
# Reload the page

app/controllers/avo/associations_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def reload_frame_turbo_streams
254254
turbo_streams = super
255255

256256
# We want to close the modal if the user wants to add just one record
257-
turbo_streams << turbo_stream.close_modal if params[:button] != "attach_another"
257+
turbo_streams << turbo_stream.avo_close_modal if params[:button] != "attach_another"
258258

259259
turbo_streams
260260
end

app/controllers/avo/base_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def destroy_fail_action
556556
flash[:error] = destroy_fail_message
557557

558558
respond_to do |format|
559-
format.turbo_stream { render turbo_stream: turbo_stream.flash_alerts }
559+
format.turbo_stream { render turbo_stream: turbo_stream.avo_flash_alerts }
560560
end
561561
end
562562

@@ -660,7 +660,7 @@ def sanitized_sort_direction
660660
def reload_frame_turbo_streams
661661
[
662662
turbo_stream.turbo_frame_reload(params[:turbo_frame]),
663-
turbo_stream.flash_alerts
663+
turbo_stream.avo_flash_alerts
664664
]
665665
end
666666
end

app/helpers/avo/turbo_stream_actions_helper.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
module Avo
22
module TurboStreamActionsHelper
3-
def download(content:, filename:)
3+
def avo_download(content:, filename:)
44
turbo_stream_action_tag :download, content: content, filename: filename
55
end
66

7-
def flash_alerts
7+
def avo_flash_alerts
88
turbo_stream_action_tag :append,
99
target: "alerts",
1010
template: @view_context.render(Avo::FlashAlertsComponent.new(flashes: @view_context.flash.discard))
1111
end
1212

13-
def close_modal
13+
def avo_close_modal
1414
turbo_stream_action_tag :replace,
1515
target: Avo::MODAL_FRAME_ID,
1616
template: @view_context.turbo_frame_tag(Avo::MODAL_FRAME_ID, data: {turbo_temporary: 1})

0 commit comments

Comments
 (0)