Umbraco UI Builder
CMSCloudHeartcoreDXP
15.latest
15.latest
  • Umbraco UI Builder Documentation
  • Known Issues
  • Release Notes
  • Getting Started
    • First Steps with UI Builder
    • Requirements
    • Installing Umbraco UI Builder
    • Licensing
    • Configuration
    • User Interface
  • Upgrading
    • Upgrade your UI Builder setup
    • Upgrading Umbraco UI Builder
    • Version Specific Upgrade Notes
    • Migrate from Konstrukt to Umbraco UI Builder
  • How-to Guides
    • Creating your First Integration
  • Areas
    • Explore Areas in UI Builder
    • Sections
      • Summary Dashboards
    • Trees
      • Folders
    • Dashboards
    • Context Apps
  • Collections
    • Work with Collections in UI Builder
    • The Basics
    • List Views
      • Field Views
    • Editors
    • Child Collections
      • Child Collection Groups
      • Retrieve Child Collections
    • Related Collections
    • Entity Identifier Converters
  • Searching
    • Add Search to Your Collections
    • Searchable Properties
  • Filtering
    • Filter Your Data with Ease
    • Global Filters
    • Data Views
      • Data Views Builders
    • Filterable Properties
  • Actions
    • Trigger Actions in UI Builder
    • The Basics
    • Action Visibility
    • Inbuilt Actions
  • Cards
    • Display Insights with Cards
    • Count Cards
    • Custom Cards
  • Property Editors
    • Enhance Input with Property Editors
    • Entity Picker
  • Advanced
    • Ready to go deeper?
    • Virtual Sub Trees
    • Encrypted Properties
    • Value Mappers
    • Repositories
    • Events
  • Miscellaneous
    • Conventions
    • Umbraco Aliases
Powered by GitBook
On this page
  • Controlling Default Action Visibility
  • Overriding Action Visibility
  • Using the AddAction<TMenuActionType>() Method
  • Using the AddAction(Type actionType, Lambda actionConfig = null) Method
  • Using the AddAction(IAction action, Lambda actionConfig = null) Method
  • Action Visibility Context
  • ActionType
  • UserGroups

Was this helpful?

Edit on GitHub
Export as PDF
  1. Actions

Action Visibility

Controlling the visibility of actions in Umbraco UI Builder.

PreviousThe BasicsNextInbuilt Actions

Last updated 1 month ago

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.

Controlling Default Action Visibility

To define the default visibility of an action, override the IsVisible method of the Action<> base class.

// Example
public class MyAction : Action<ActionResult>
{
    ...
    public override bool IsVisible(ActionVisibilityContext ctx)
    {
        return ctx.ActionType == ActionType.Bulk 
            || ctx.ActionType == ActionType.Row;
    }
    ...
}

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.

Overriding Action Visibility

You can override an action's visibility in the settings.

Using the AddAction<TMenuActionType>() Method

Adds an action of the given type to the collection with the specified visibility.

Method Syntax

AddAction<TMenuActionType>(Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>

Example

collectionConfig.AddAction<ExportMenuAction>(actionConfig => actionConfig
    .SetVisibility(x => x.ActionType == ActionType.Bulk 
        || x.ActionType == ActionType.Row)
);

Using the AddAction(Type actionType, Lambda actionConfig = null) Method

Adds an action of the given type to the collection by specifying the action type dynamically using Type instead of a generic type.

Method Syntax

AddAction(Type actionType, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>

Example

collectionConfig.AddAction(typeof(ExportMenuAction), actionConfig => actionConfig
    .SetVisibility(x => x.ActionType == ActionType.Bulk 
        || x.ActionType == ActionType.Row)
);

Using the AddAction(IAction action, Lambda actionConfig = null) Method

Adds the already defined action instance to the collection with the specified visibility.

Method Syntax

AddAction(IAction action, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>

Example

collectionConfig.AddAction(action, actionConfig => actionConfig
    .SetVisibility(x => x.ActionType == ActionType.Bulk 
        || x.ActionType == ActionType.Row)
);

Action Visibility Context

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.

ActionType

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.

ContainerMenu

The ContainerMenu action type displays the action in both the collection tree and its list view actions menu.

EntityMenu

The EntityMenu action type shows the action in the collection editor UI's actions menu.

Bulk

The Bulk action type displays the action in the collection list view bulk actions menu.

Row

The Row action type shows the action in the collection list view action row menu.

Save

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].

UserGroups

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.

Collections
Action visibility context
Container Menu
Entity Menu
Bulk Actions
Row Actions
Save Actions