Action Visibility
Controlling the visibility of actions in Umbraco UI Builder.
Last updated
Was this helpful?
Controlling the visibility of actions in Umbraco UI Builder.
Last updated
Was this helpful?
By default, actions are hidden in the UI. You must define when and where an action should appear. This can be done either at the action definition level or when registering it in the collection config.
To define the default visibility of an action, override the IsVisible
method of the Action<>
base class.
The IsVisible
method receives an ActionVisibilityContext
. You can use this context to decide whether the action should be displayed. Return true
to show it, or false
to hide it. For more information, see the section below.
You can override an action's visibility in the settings.
AddAction<TMenuActionType>()
MethodAdds an action of the given type to the collection with the specified visibility.
AddAction(Type actionType, Lambda actionConfig = null)
MethodAdds an action of the given type to the collection by specifying the action type dynamically using Type
instead of a generic type.
AddAction(IAction action, Lambda actionConfig = null)
MethodAdds the already defined action instance to the collection with the specified visibility.
When controlling the visibility of an action, you will receive an ActionVisibilityContext
object. This context allows you to decide whether to show the action. The context contains two key pieces of information for this decision.
The ActionType
property is an enum property that defines which area of the UI wants to access the action. This property helps determine where the action is displayed.
The ContainerMenu
action type displays the action in both the collection tree and its list view actions menu.
The EntityMenu
action type shows the action in the collection editor UI's actions menu.
The Bulk
action type displays the action in the collection list view bulk actions menu.
The Row
action type shows the action in the collection list view action row menu.
The Save
action type displays the action as a sub-button in the entity editor’s save button. All Save
actions trigger a save before executing. Their labels are prefixed with Save & [Action Name]
.
The UserGroups
collection contains a list of IReadOnlyUserGroup
objects for the current logged-in backoffice user. This allows you to control action visibility for members of specific user groups.