app/components/avo/actions_component.rb in avo-2.12.1.pre.1 vs app/components/avo/actions_component.rb in avo-2.13.0
- old
+ new
@@ -1,17 +1,26 @@
# frozen_string_literal: true
class Avo::ActionsComponent < ViewComponent::Base
include Avo::ApplicationHelper
- def initialize(actions: [], resource: nil, view: nil)
- @actions = actions
+ def initialize(actions: [], resource: nil, view: nil, exclude: [], style: :outline, color: :blue)
+ @actions = actions || []
@resource = resource
@view = view
+ @exclude = exclude
+ @color = color
+ @style = style
end
def render?
- @actions.present?
+ actions.present?
+ end
+
+ def actions
+ @actions.select do |action|
+ !action.class.in?(@exclude)
+ end
end
# When running an action for one record we should do it on a special path.
# We do that so we get the `model` param inside the action so we can prefill fields.
def action_path(id)