Skip to content

Commit 8c0c4cc

Browse files
authored
Merge pull request #6913 from umbraco/uibuilder-areas-section
Updated UI Builder Areas articles
2 parents 7e70d71 + c580e36 commit 8c0c4cc

File tree

4 files changed

+633
-204
lines changed

4 files changed

+633
-204
lines changed
Lines changed: 157 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,252 @@
11
---
2-
description: Configuring context apps in Umbraco UI Builder, the backoffice UI builder for Umbraco.
2+
description: Configuring context apps in Umbraco UI Builder.
33
---
44

55
# Context Apps
66

7-
Context Apps in Umbraco UI Builder are analogous to Content Apps in Umbraco. They allow you to provide contextual apps that appear in the editor UI of content. From Umbraco UI Builder's perspective, defining context apps allows you to expose collections as content apps. This is where a collection has a relation to the content in question. An example could be something like blog post comments which are linked to individual blog posts. Exposing these as a content app allows them to be managed in context next to the blog post they are linked to.
7+
Context Apps in Umbraco UI Builder function similarly to Content Apps. They provide contextual applications within the content editor UI. By defining context apps, you can expose collections that are directly related to the content in question. For example, blog post comments can be linked to their respective blog posts and managed in context through a content app.
88

99
![Context App](../images/context_app.png)
1010

11-
## Defining a context app
11+
## Defining a Context App
1212

1313
You can define a context app by calling one of the `AddContextApp` methods on a [`WithTreeConfigBuilder`](trees.md#extending-an-existing-tree) instance.
1414

15-
### **AddContextApp(string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
15+
### Using the `AddContextApp()` Method
1616

17-
Adds a context app with the given name and default icon.
17+
Adds a context app with the specified name and default icon.
18+
19+
#### Method Syntax
20+
21+
```cs
22+
AddContextApp(string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
23+
```
24+
25+
#### Example
1826

1927
```csharp
20-
// Example
2128
withTreeConfig.AddContextApp("Comments", contextAppConfig => {
2229
...
2330
});
2431
```
2532

26-
### **AddContextApp(string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
33+
### Using the `AddContextApp()` Method with Custom Icon
34+
35+
Adds a context app with the specified name and custom icon.
36+
37+
#### Method Syntax
2738

28-
Adds a context app to the Umbraco menu with the given name and icon.
39+
```cs
40+
AddContextApp(string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
41+
```
42+
43+
#### Example
2944

3045
```csharp
31-
// Example
3246
withTreeConfig.AddContextApp("Comments", "icon-chat", contextAppConfig => {
3347
...
3448
});
3549
```
3650

37-
### **AddContextAppBefore(string beforeAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
51+
### Using the `AddContextAppBefore()` Method
52+
53+
Adds a context app with the specified name and default icon before another context app specified by its alias.
54+
55+
#### Method Syntax
56+
57+
```cs
58+
AddContextAppBefore(string beforeAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
59+
```
3860

39-
Adds a context app with the given name and default icon **before** the context app with the given alias.
61+
#### Example
4062

4163
```csharp
42-
// Example
4364
withTreeConfig.AddContextAppBefore("umbContent", "Comments", contextAppConfig => {
4465
...
4566
});
4667
```
4768

48-
### **AddContextAppBefore(string beforeAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
69+
### Using the `AddContextAppBefore()` Method with a Custom Icon
4970

50-
Adds a context app to the Umbraco menu with the given name and icon **before** the context app with the given alias.
71+
Adds a context app with the specified name and custom icon before another context app specified by its alias.
72+
73+
#### Method Syntax
74+
75+
```cs
76+
AddContextAppBefore(string beforeAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
77+
```
78+
79+
#### Example
5180

5281
```csharp
53-
// Example
5482
withTreeConfig.AddContextAppBefore("umbContent", "Comments", "icon-chat", contextAppConfig => {
5583
...
5684
});
5785
```
5886

59-
### **AddContextAppAfter(string afterAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
87+
### Using the `AddContextAppAfter()` Method
88+
89+
Adds a context app with the specified name and default icon after another context app specified by its alias.
90+
91+
#### Method Syntax
6092

61-
Adds a context app with the given name and default icon **after** the context app with the given alias.
93+
```cs
94+
AddContextAppAfter(string afterAlias, string name, Lambda contextAppConfig = null) : ContextAppConfigBuilder
95+
```
96+
97+
#### Example
6298

6399
```csharp
64-
// Example
100+
65101
withTreeConfig.AddContextAppAfter("umbContent", "Comments", contextAppConfig => {
66102
...
67103
});
68104
```
69105

70-
### **AddContextAppAfter(string afterAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder**
106+
### Using the `AddContextAppAfter()` Method with a Custom Icon
107+
108+
Adds a context app with the specified name and custom icon after another context app specified by its alias.
109+
110+
#### Method Syntax
111+
112+
```cs
113+
AddContextAppAfter(string afterAlias, string name, string icon, Lambda contextAppConfig = null) : ContextAppConfigBuilder
114+
```
71115

72-
Adds a context app to the Umbraco menu with the given name and icon **after** the context app with the given alias.
116+
#### Example
73117

74118
```csharp
75-
// Example
76119
withTreeConfig.AddContextAppAfter("umbContent", "Comments", "icon-chat", contextAppConfig => {
77120
...
78121
});
79122
```
80123

81-
## Changing a context app alias
124+
## Changing a Context App Alias
125+
126+
### Using the `SetAlias()` Method
82127

83-
### **SetAlias(string alias) : ContextAppConfigBuilder**
128+
Sets the alias of the context app. By default, an alias is automatically generated from the context app's name. You can use the `SetAlias` method to specify a custom alias.
129+
130+
#### Method Syntax
84131

85-
Sets the alias of the context app.
132+
```cs
133+
SetAlias(string alias) : ContextAppConfigBuilder
134+
```
86135

87-
**Optional:** When adding a new context app, an alias is automatically generated from the supplied name for you. However, you can use the `SetAlias` method to override this if you need a specific alias.
136+
#### Example
88137

89138
```csharp
90-
// Example
91139
contextAppConfig.SetAlias("comments");
92140
```
93141

94-
## Changing a context app icon color
142+
## Changing a Context App Icon Color
143+
144+
### Using the `SetIconColor()` Method
145+
146+
Sets the context app icon color to the given color. The available colors are: `black`, `green`, `yellow`, `orange`, `blue` or `red`.
147+
148+
#### Method Syntax
95149

96-
### **SetIconColor(string color) : ContextAppConfigBuilder**
150+
```cs
151+
SetIconColor(string color) : ContextAppConfigBuilder
152+
```
97153

98-
Sets the context app icon color to the given color. Possible options are `black`, `green`, `yellow`, `orange`, `blue` or `red`.
154+
#### Example
99155

100156
````csharp
101-
// Example
102157
contextAppConfig.SetIconColor("blue");
103158
````
104159

105-
## Changing when a context app should display
160+
## Changing Context App Visibility
161+
162+
Context app visibility is controlled by a delegate that takes a `ContextAppVisibilityContext` instance. This method contains a `Source` property which holds a reference to the source object that the content app is being displayed on (i.e., an `IContent` instance). It also holds a reference to a `UserGroups` collection of the currently logged-in user's user groups. You can use these values to determine when the context app should be displayed.
163+
164+
By default, context apps are pre-filtered to only appear on the tree they are defined in. This default behavior is combined with the SetVisibility configuration to control visibility.
106165

107-
Changing when a context app is displayed, is controlled by a delegate method which is passed a `ContextAppVisibilityContext` instance. This method contains a `Source` property which holds a reference to the source object that the content app is being displayed on (i.e., an `IContent` instance). It also holds a reference to a `UserGroups` collection of the currently logged-in user's user groups. You can use any value from those to return a boolean result which sets whether to display the context app or not.
166+
### Using the `SetIconColor()` Method
108167

109-
By default, Umbraco UI Builder will pre-filter context apps to only display on the tree it is defined in. This will be combined with the `SetVisibility` config to decide when to display the context app.
168+
Defines the visibility of the context app based on a delegate expression.
110169

111-
### **SetVisibility(Func<ContextAppVisibilityContext, bool> visibilityExpression) : ContextAppConfigBuilder**
170+
#### Method Syntax
112171

113-
Sets the context app visibility delegate.
172+
```cs
173+
SetVisibility(Func<ContextAppVisibilityContext, bool> visibilityExpression) : ContextAppConfigBuilder
174+
```
175+
176+
#### Example
114177

115178
````csharp
116-
// Example
117179
contextAppConfig.SetVisibility(appCtx => appCtx.Source is IContent content && content.ContentType.Alias == "blogPost");
118180
````
119181

120-
## Adding a collection to a context app
182+
## Adding a Collection to a Context App
121183

122184
Context apps can consist of one or more collections. If a context app contains multiple collections, the collection list views will be displayed in tabs within the context app.
123185

124-
### **AddCollection&lt;TEntityType&gt;(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, Lambda collectionConfig = null) : ContextAppConfigBuilder**
186+
### Using the `AddCollection<>()` Method
187+
188+
Adds a collection to the current context app with the specified names, descriptions, and default icons. Each collection requires an ID field and a foreign key field, linking to Umbraco node UDI values. For more details, see the [Collections](../collections/overview.md) article.
125189

126-
Adds a collection to the current content app with the given names, descriptions and default icons. An ID property accessor expression is required so that Umbraco UI Builder knows which property is the ID property. A foreign key property accessor is also required so that the Umbraco UI Builder knows which property holds the Umbraco nodes UDI value. You can read more about this in the [Collections documentation](../collections/overview.md).
190+
#### Method Syntax
191+
192+
```cs
193+
AddCollection<TEntityType>(
194+
Lambda idFieldExpression,
195+
Lambda fkFieldExpression,
196+
string nameSingular,
197+
string namePlural,
198+
string description,
199+
Lambda collectionConfig = null
200+
) : ContextAppConfigBuilder
201+
```
202+
203+
#### Example
127204

128205
```csharp
129-
// Example
130-
contextAppConfig.AddCollection<Comment>(p => p.Id, p=> "Comment", "Comments", "A collection of comments", collectionConfig => {
131-
...
132-
});
206+
contextAppConfig.AddCollection<Comment>(
207+
p => p.Id,
208+
p => "Comment",
209+
"Comments",
210+
"A collection of comments",
211+
collectionConfig => {
212+
// Collection configuration here
213+
}
214+
);
133215
```
134216

135-
### **AddCollection&lt;TEntityType&gt;(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, string iconSingular, string iconPlural, Lambda collectionConfig = null) : ContextAppConfigBuilder**
217+
### Using the `AddCollection<>()` Method with Custom Icon
218+
219+
**AddCollection&lt;TEntityType&gt;(Lambda idFieldExpression, Lambda fkFieldExpression, string nameSingular, string namePlural, string description, string iconSingular, string iconPlural, Lambda collectionConfig = null) : ContextAppConfigBuilder**
136220

137-
Adds a collection to the current context app with the given names, description and icons. An ID property accessor expression is required so that Umbraco UI Builder knows which property is the ID property. A foreign key property accessor is also required so that Umbraco UI Builder knows which property holds the Umbraco nodes UDI value. You can read more about this in the [Collections documentation](../collections/overview.md).
221+
Adds a collection to the current context app with the specified names, descriptions, and custom icons. Each collection requires an ID field and a foreign key field, linking to Umbraco node UDI values. For more details, see the [Collections](../collections/overview.md) article.
222+
223+
#### Method Syntax
224+
225+
```cs
226+
AddCollection<TEntityType>(
227+
Lambda idFieldExpression,
228+
Lambda fkFieldExpression,
229+
string nameSingular,
230+
string namePlural,
231+
string description,
232+
string iconSingular,
233+
string iconPlural,
234+
Lambda collectionConfig = null
235+
) : ContextAppConfigBuilder
236+
```
237+
238+
#### Example
138239

139240
```csharp
140-
// Example
141-
contextAppConfig.AddCollection<Comment>(p => p.Id, "Comment", "Comments", "A collection of comments", "icon-chat", "icon-chat", collectionConfig => {
142-
...
143-
});
241+
contextAppConfig.AddCollection<Comment>(
242+
p => p.Id,
243+
"Comment",
244+
"Comments",
245+
"A collection of comments",
246+
"icon-chat",
247+
"icon-chat",
248+
collectionConfig => {
249+
// Collection configuration here
250+
}
251+
);
144252
```

0 commit comments

Comments
 (0)