Skip to content

Commit 6caf919

Browse files
authored
Merge pull request #6962 from umbraco/actions
UI Builder: Updated Actions articles
2 parents 968d838 + ec1a691 commit 6caf919

File tree

5 files changed

+117
-77
lines changed

5 files changed

+117
-77
lines changed
Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
description: Controlling the visibility of actions in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Controlling the visibility of actions in Umbraco UI Builder.
33
---
44

55
# Action Visibility
66

7-
By default actions are not visible in the UI and you must expressly define when and where an action should display. This can be achieved in two ways, either on the action definition itself or at the point of registration on the collections config.
7+
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.
88

9-
## Controlling the default action visibility
9+
## Controlling Default Action Visibility
1010

11-
To define the default visibility of an action at the action level you can do this by overriding the `IsVisible` method of the `Action<>` base class.
11+
To define the default visibility of an action, override the `IsVisible` method of the `Action<>` base class.
1212

1313
````csharp
1414
// Example
@@ -24,86 +24,107 @@ public class MyAction : Action<ActionResult>
2424
}
2525
````
2626

27-
The `IsVisible` method is passed a `ActionVisibilityContext` which you should use to decide whether the action should display, returning `true` if it should, or `false` if it should not. For more information check the [Action visibility context](#action-visibility-context).
27+
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 [Action visibility context](#action-visibility-context) section below.
2828

29-
## Overriding an actions visibility
29+
## Overriding Action Visibility
3030

31-
Overriding an actions visibility is controlled via the [collections](../collections/overview.md) configuration.
31+
You can override an action's visibility in the [Collections](../collections/overview.md) settings.
3232

33-
### **AddAction&lt;TMenuActionType&gt;(Lambda actionConfig = null) : CollectionConfigBuilder&lt;TEntityType&gt;**
33+
### Using the `AddAction<TMenuActionType>()` Method
3434

35-
Adds an action of the given type to the collection with the given visibility.
35+
Adds an action of the given type to the collection with the specified visibility.
36+
37+
#### Method Syntax
38+
39+
```cs
40+
AddAction<TMenuActionType>(Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
41+
```
42+
43+
#### Example
3644

3745
````csharp
38-
// Example
3946
collectionConfig.AddAction<ExportMenuAction>(actionConfig => actionConfig
4047
.SetVisibility(x => x.ActionType == ActionType.Bulk
4148
|| x.ActionType == ActionType.Row)
4249
);
4350
````
4451

45-
### **AddAction(Type actionType, Lambda actionConfig = null) : CollectionConfigBuilder&lt;TEntityType&gt;**
52+
### Using the `AddAction(Type actionType, Lambda actionConfig = null)` Method
53+
54+
Adds an action of the given type to the collection by specifying the action type dynamically using `Type` instead of a generic type.
55+
56+
#### Method Syntax
4657

47-
Adds an action of the given type to the collection with the given visibility.
58+
```cs
59+
AddAction(Type actionType, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
60+
```
61+
62+
#### Example
4863

4964
````csharp
50-
// Example
5165
collectionConfig.AddAction(typeof(ExportMenuAction), actionConfig => actionConfig
5266
.SetVisibility(x => x.ActionType == ActionType.Bulk
5367
|| x.ActionType == ActionType.Row)
5468
);
5569
````
5670

57-
### **AddAction(IAction action, Lambda actionConfig = null) : CollectionConfigBuilder&lt;TEntityType&gt;**
71+
### Using the `AddAction(IAction action, Lambda actionConfig = null)` Method
72+
73+
Adds the already defined action instance to the collection with the specified visibility.
5874

59-
Adds the given action to the collection with the given visibility.
75+
#### Method Syntax
76+
77+
```cs
78+
AddAction(IAction action, Lambda actionConfig = null) : CollectionConfigBuilder<TEntityType>
79+
```
80+
81+
#### Example
6082

6183
````csharp
62-
// Example
6384
collectionConfig.AddAction(action, actionConfig => actionConfig
6485
.SetVisibility(x => x.ActionType == ActionType.Bulk
6586
|| x.ActionType == ActionType.Row)
6687
);
6788
````
6889

69-
## Action visibility context
90+
## Action Visibility Context
7091

71-
When controlling the visibility of an action you will be given a `ActionVisibilityContext` object from which you can decide whether to show the action or not. The visibility context contains two key pieces of information on which you can base this decision.
92+
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.
7293

7394
### ActionType
7495

75-
The action type property is an enum property that define which area of the UI it is that wishes to access this action. Enabling an action to display for a given action type will determine where an action is displayed.
96+
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.
7697

7798
#### ContainerMenu
7899

79-
The `ContainerMenu` action type determines that the action will be displayed in both the tree of the collection and its list view actions menu.
100+
The `ContainerMenu` action type displays the action in both the collection tree and its list view actions menu.
80101

81102
![Container Menu](../images/container_actions_menu.png)
82103

83104
#### EntityMenu
84105

85-
The `EntityMenu` action type determines that the action will be displayed in the actions menu of a collection editor UI.
106+
The `EntityMenu` action type shows the action in the collection editor UI's actions menu.
86107

87108
![Entity Menu](../images/entity_actions_menu.png)
88109

89110
#### Bulk
90111

91-
The `Bulk` action type determines that the action will be displayed in the collection list view bulk actions menu.
112+
The `Bulk` action type displays the action in the collection list view bulk actions menu.
92113

93114
![Bulk Actions](../images/bulk_actions_menu.png)
94115

95116
#### Row
96117

97-
The `Row` action type determines that the action will be displayed in the collection list view action row menu.
118+
The `Row` action type shows the action in the collection list view action row menu.
98119

99120
![Row Actions](../images/row_actions_menu.png)
100121

101122
#### Save
102123

103-
The `Save` action type determines that the action will be displayed as a sub button in an entity editors save button. All `Save` action types trigger a save before the action is executed and so to convey this, all `Save` action type button labels are prefixed `Save & [Action Name]`
124+
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]`.
104125

105126
![Save Actions](../images/save_actions_menu.png)
106127

107128
### UserGroups
108129

109-
The user groups collection contains a list of Umbraco `IReadOnlyUserGroup` objects for the current logged-in backoffice user. This allows you to control the visibility of actions for given user group members.
130+
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.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
2-
description: A list of inbuilt actions that come with Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: A list of inbuilt actions that come with Umbraco UI Builder.
33
---
44

55
# Inbuilt Actions
66

7-
Umbraco UI Builder comes with some inbuilt actions that are available for you to use straight away.
7+
Umbraco UI Builder provides different inbuilt actions that you can use right away.
88

99
## ExportEntityAction
1010

11-
**Namespace** Umbraco.UIBuilder.Infrastructure.Configuration.Actions
11+
**Namespace:** `Umbraco.UIBuilder.Infrastructure.Configuration.Actions`
1212

13-
Provides a Comma-Separated Values (CSV) export functionality converting all properties to column headings and rendering each entity property values on each row.
13+
Exports entity data to a Comma-Separated Values (CSV) file. It converts all properties into column headings and renders each entity's property values in rows.
1414

1515
## ImportEntityAction
1616

17-
**Namespace** Umbraco.UIBuilder.Infrastructure.Configuration.Actions
17+
**Namespace:** `Umbraco.UIBuilder.Infrastructure.Configuration.Actions`
1818

19-
Provides a Comma-Separated Values (CSV) import functionality matching column headings with entity properties and mapping row values to an entity.
19+
Imports data from a Comma-Separated Values (CSV) file. This action matches column headings with entity properties and maps row values to an entity.

15/umbraco-ui-builder/actions/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
description: Configuring actions in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Learn how to configure actions in Umbraco UI Builder.
33
---
44

55
# Actions
66

7-
Actions provide an API to perform custom tasks against a collection and its entities from multiple locations in the UI. Examples: menu actions, bulk actions, or individual table row actions.
7+
Actions allow you to perform custom tasks on collections and their entities from different areas in the UI. For Example: menu actions, bulk actions, or individual table row actions.
88

99
![Bulk Actions UI](../images/bulk_actions.png)
1010

11-
Get started with actions by learning about the basics.
11+
To get started with actions, check out the basics:
1212

1313
{% content-ref url="the-basics.md" %}
1414
[the-basics.md](the-basics.md)

15/umbraco-ui-builder/actions/the-basics.md

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
description: Configuring actions in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Configuring actions in Umbraco UI Builder.
33
---
44

55
# The Basics
66

7-
Actions are a powerful way of adding custom functionality to Umbraco UI Builder without needing to create custom UI elements. By providing an action to run, Umbraco UI Builder can automatically trigger actions from a number of UI locations.
7+
Actions allow you to add custom functionality to Umbraco UI Builder without creating custom UI elements. By providing an action to run, Umbraco UI Builder can trigger actions from different UI locations.
88

9-
## Defining an action
9+
## Defining an Action
1010

11-
To define an action create a class that inherits from the base class `Action<>` and configure it like below:
11+
To define an action, create a class that inherits from the base class `Action<>` and configure it as shown below:
1212

1313
````csharp
1414
// Example
@@ -26,33 +26,32 @@ public class MyAction : Action<ActionResult>
2626
}
2727
````
2828

29-
The required configuration options are:
29+
### Configuration Options
3030

31-
* **Name:** The name of the action.
32-
* **Alias:** A unique alias for the action.
33-
* **Icon:** An icon to display next to the name in the action button.
34-
* **Execute:** The method to run against a given list of entities.
31+
| Option | Description | Required |
32+
|:-------------:|:--------------------------------------------------------------------------:|----------|
33+
| Name | The name of the action. | Yes |
34+
| Alias | A unique alias for the action. | Yes |
35+
| Icon | An icon to display next to the action’s name. | Yes |
36+
| Execute | The method that runs for the given list of entities. | Yes |
37+
| ConfirmAction | Set whether a confirm dialog should display before performing this action. | No |
3538

36-
Additional optional configuration options are:
37-
38-
* **ConfirmAction:** Set whether a confirm dialog should display before performing this action.
39-
40-
The generic argument is a return type for the action. See [Controlling the action result](#controlling-the-action-result) below.
39+
The generic argument specifies the return type for the action. For more details, see the [Controlling the Action Result](#controlling-the-action-result) section below.
4140

4241
{% hint style="info" %}
43-
You can use dependency injection to inject any services you require to perform your specific task. When injecting dependencies, it's always recommended that you inject `Lazy<YourService>` implementations of the required services to ensure they are only resolved when needed.
42+
You can use dependency injection to inject any services required for your specific task. It's recommended to inject `Lazy<YourService>` implementations of the required services to ensure they are resolved only when needed.
4443
{% endhint %}
4544

46-
## Controlling the action result
45+
## Controlling the Action Result
4746

48-
Actions by default will return a `ActionResult` but you can return other types of result by swapping the `Action<>` generic argument.
47+
By default, actions return an `ActionResult`, but you can return other types by changing the `Action<>` generic argument.
4948

5049
* **`ActionResult`** - Standard result with a boolean `Success` value.
51-
* **`FileActionResult`** - Returns a file stream / bytes and triggers a download dialog.
50+
* **`FileActionResult`** - Returns a file stream or bytes and triggers a download dialog.
5251

53-
## Capturing settings for an action
52+
## Capturing Settings for an Action
5453

55-
Sometimes you may need to collect further user input before you can perform an action. To achieve this you can use the `Action<>` base class that accepts an additional `TSetting` generic argument.
54+
Sometimes, you need to collect user input before performing an action. You can achieve this by using the `Action<>` base class with an additional `TSetting` generic argument.
5655

5756
````csharp
5857
// Example
@@ -83,37 +82,58 @@ public class MyActionSettings
8382
}
8483
````
8584

86-
By implementing this base class you are required to implement an additional `Configure` method which accepts a `SettingsConfigBuilder<>` parameter. You should use this parameter calling the builders fluent API to define the settings dialog UI and how it maps to the settings type. With the settings config builder you are able to create fieldsets and fields with the same fluent API as defined in the [Collection Editors section](../collections/editors.md#adding-a-fieldset-to-a-tab).
85+
By implementing this base class, you must also implement the `Configure` method which accepts a `SettingsConfigBuilder<>` parameter. Use this builder to define the settings dialog UI and how it maps to the settings type. You can create fieldsets and fields with the same fluent API as in the [Collection Editors](../collections/editors.md#adding-a-fieldset-to-a-tab) section.
86+
87+
Additionally, the `Execute` method now accepts an extra `settings` parameter, which Umbraco UI Builder will pre-populate with the user-entered values. You can adjust the action's behavior based on this data.
88+
89+
## Adding an Action to a Collection
8790

88-
In addition to this `Configure` method, the `Execute` method will now accept an additional `settings` parameter of the settings type. This will be pre-populated by Umbraco UI Builder with the value entered by the user, allowing you to alter your actions behavior accordingly.
91+
Actions are added via the [Collections](../collections/overview.md) settings.
8992

90-
## Adding an action to a collection
93+
### Using the `AddAction<TMenuActionType>()` Method
9194

92-
Actions are added via the [Collections](../collections/overview.md) configuration.
95+
Adds an action of the specified type to the collection.
9396

94-
### **AddAction&lt;TMenuActionType&gt;() : CollectionConfigBuilder&lt;TEntityType&gt;**
97+
#### Method Syntax
9598

96-
Adds an action of the given type to the collection.
99+
```cs
100+
AddAction<TMenuActionType>() : CollectionConfigBuilder<TEntityType>
101+
```
102+
103+
#### Example
97104

98105
````csharp
99-
// Example
100106
collectionConfig.AddAction<ExportMenuAction>();
101107
````
102108

103-
#### **AddAction(Type actionType) : CollectionConfigBuilder&lt;TEntityType&gt;**
109+
#### Using the `AddAction(Type actionType)` Method
110+
111+
Adds an action of the specified type to the collection.
104112

105-
Adds an action of the given type to the collection.
113+
#### Method Syntax
114+
115+
```cs
116+
AddAction(Type actionType) : CollectionConfigBuilder<TEntityType>
117+
```
118+
119+
#### Example
106120

107121
````csharp
108-
// Example
109122
collectionConfig.AddAction(actionType);
110123
````
111124

112-
#### **AddAction(IAction action) : CollectionConfigBuilder&lt;TEntityType&gt;**
125+
#### Using the `AddAction(IAction action)` Method
113126

114127
Adds the given action to the collection.
115128

129+
#### Method Syntax
130+
131+
```cs
132+
AddAction(IAction action) : CollectionConfigBuilder<TEntityType>
133+
```
134+
135+
#### Example
136+
116137
````csharp
117-
// Example
118138
collectionConfig.AddAction(action);
119139
````

15/umbraco-ui-builder/cards/custom-cards.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ public class AvgPersonAgeCard : Card
2929
}
3030
````
3131

32-
The required configuration options are:
33-
34-
* **Name:** The name of the card.
35-
* **Alias:** A unique alias for the card.
36-
* **GetValue(object parentId = null):** A method to retrieve the card's value.
37-
38-
The optional configuration options are:
39-
40-
* **Icon:** An icon displaed in the card.
41-
* **Color:** The color of the card.
42-
* **Suffix:** The suffix displayed after the card value.
32+
### Configuration Options
33+
34+
| Option | Description | Required |
35+
|:--------------------------------:|:------------------------------------------:|----------|
36+
| Name | The name of the card. | Yes |
37+
| Alias | A unique alias for the card. | Yes |
38+
| GetValue(object parentId = null) | A method to retrieve the card's value. | Yes |
39+
| Icon | An icon displaed in the card. | No |
40+
| Color | The color of the card. | No |
41+
| Suffix | The suffix displayed after the card value. | No |
4342

4443
## Adding a Custom Card to a Collection
4544

0 commit comments

Comments
 (0)