From 21a32f9f5b0b5d7b9febb160ae1ef2118fda489c Mon Sep 17 00:00:00 2001 From: binarygit <87677429+binarygit@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:06:05 +0545 Subject: [PATCH] Provide info that you do not need to manually register an action before using it (#242) * Actions no longer need to be registered inside actions method * Update * Add note on warning * Update docs/3.0/customizable-controls.md * Update docs/3.0/customizable-controls.md --------- Co-authored-by: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> --- docs/3.0/customizable-controls.md | 3 ++- docs/3.0/upgrade.md | 45 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/3.0/customizable-controls.md b/docs/3.0/customizable-controls.md index 4be45b42..66780736 100644 --- a/docs/3.0/customizable-controls.md +++ b/docs/3.0/customizable-controls.md @@ -201,7 +201,8 @@ action Avo::Actions::PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ::: -:::warning +:::warning WARNING (**NOT** applicable for versions greater than ) + When you use the `action` helper in any customizable block it will act only as a shortcut to display the action button, it will not also register it to the resource. You must manually register it with the `action` declaration. diff --git a/docs/3.0/upgrade.md b/docs/3.0/upgrade.md index 98ed97d8..21346f40 100644 --- a/docs/3.0/upgrade.md +++ b/docs/3.0/upgrade.md @@ -13,6 +13,51 @@ In versions lower than , boolean fields with a `nil` + +## Upgrade from 3.10 to 3.11 + +### Actions no longer need to be registered inside actions method + +Actions inside customizable blocks no longer need to be declared in the `actions` method. + +```ruby +# Before + +class Avo::Resources::Fish < Avo::BaseResource + self.title = :name + + self.show_controls = -> do + # In order to use it here + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end + + # 👇 Also declare it here 👇 + def actions + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end +end + +# After + +class Avo::Resources::Fish < Avo::BaseResource + self.title = :name + + self.show_controls = -> do + # In order to use it here + action Avo::Actions::ReleaseFish, style: :primary, color: :fuchsia, arguments: { + action_on_show_controls: "Will use this arguments" + } + end + + # 👇 No need to declare it here 👇 + def actions + end +end +``` ## Upgrade from 3.9.2 to 3.10 Deprecated [`fetch_labels`](fields/tags#fetch_labels) option in favor of [`format_using`](fields/tags#format_using) on tags field.