Skip to content

Commit 9755b71

Browse files
authored
fix: run actions from custom controls (#4435)
* fix: run actions from custom controls * lint
1 parent 314067c commit 9755b71

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

app/controllers/avo/actions_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ def set_action
115115
def action_class
116116
@resource.hydrate(view: action_params[:resource_view].presence, user: _current_user, params: params)
117117

118-
registered_action = @resource.get_actions.find do |action|
119-
action[:class].to_s == params[:action_id]
120-
end
118+
registered_action = @resource.find_action(params[:action_id])
121119

122120
if registered_action.nil?
123121
if Rails.env.development?

lib/avo/resources/base.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@ def divider(**kwargs)
399399
end
400400
end
401401

402+
def find_action(action_id)
403+
actions = get_actions + Array(safe_call(:get_actions_from_custom_controls))
404+
405+
actions
406+
.uniq { |action| action[:class].to_s }
407+
.find { |action| action[:class].to_s == action_id.to_s }
408+
end
409+
402410
def hydrate(...)
403411
super
404412

0 commit comments

Comments
 (0)