app/components/avo/actions_component.rb in avo-3.5.6.beta1 vs app/components/avo/actions_component.rb in avo-3.5.6
- old
+ new
@@ -77,6 +77,44 @@
action_id: action.to_param,
arguments: Avo::BaseAction.encode_arguments(action.arguments)
}.compact
).to_s
end
+
+ def icon(action)
+ svg action.icon, class: "h-5 mr-1 inline pointer-events-none"
+ end
+
+ def render_item(action)
+ if action.is_a?(Avo::DividerComponent)
+ render Avo::DividerComponent.new
+ else
+ render_action_link(action)
+ end
+ end
+
+ private
+
+ def render_action_link(action)
+ link_to action_path(action),
+ data: action_data_attributes(action),
+ title: action.action_name,
+ class: action_css_class(action) do
+ raw("#{icon(action)} #{action.action_name}")
+ end
+ end
+
+ def action_data_attributes(action)
+ {
+ action_name: action.action_name,
+ "turbo-frame": Avo::ACTIONS_TURBO_FRAME_ID,
+ action: "click->actions-picker#visitAction",
+ "actions-picker-target": action.standalone ? "standaloneAction" : "resourceAction",
+ disabled: is_disabled?(action),
+ turbo_prefetch: false,
+ }
+ end
+
+ def action_css_class(action)
+ "flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100 border-b#{is_disabled?(action) ? " text-gray-500" : " text-black"}"
+ end
end