Skip to content

Commit 2c6c623

Browse files
committed
Added documentation for new workspace unique condition.
1 parent 91e3f33 commit 2c6c623

File tree

1 file changed

+87
-73
lines changed
  • 15/umbraco-cms/customizing/extending-overview/extension-types

1 file changed

+87
-73
lines changed
Lines changed: 87 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: >-
3-
Learn how to declare requirements for your extensions using the Extension
4-
Conditions.
3+
Learn how to declare requirements for your extensions using the Extension
4+
Conditions.
55
---
66

77
# Extension Conditions
@@ -14,50 +14,58 @@ For information on how to utilize conditions in your Manifest, see the [Utilizin
1414

1515
The following conditions are available out of the box, for all extension types that support Conditions.
1616

17-
* `Umb.Condition.Switch` - Toggles on and off based on the `frequency` set in seconds.
18-
* `Umb.Condition.MultipleAppLanguages` - Requires the app to have more than one language, such as a multi-language site.
19-
* `Umb.Condition.SectionAlias` - Requires the current Section Alias to match the one specified.
20-
* `Umb.Condition.MenuAlias` - Requires the current Menu Alias to match the one specified.
21-
* `Umb.Condition.WorkspaceAlias` - Requires the current Workspace Alias to match the one specified.
22-
* `Umb.Condition.WorkspaceEntityType` - Requires the current workspace to work on the given Entity Type. Examples: 'document', 'block' or 'user'.
23-
* `Umb.Condition.WorkspaceContentTypeAlias` - Requires the current workspace to be based on a Content Type which Alias matches the one specified.
24-
* `Umb.Condition.Workspace.ContentHasProperties` - Requires the Content Type of the current Workspace to have properties.
25-
* `Umb.Condition.WorkspaceHasCollection` - Requires the current Workspace to have a Collection.
26-
* `Umb.Condition.WorkspaceEntityIsNew` - Requires the current Workspace data to be new, not yet persisted on the server.
27-
* `Umb.Condition.EntityIsTrashed` - Requires the current entity to be trashed.
28-
* `Umb.Condition.EntityIsNotTrashed` - Requires the current entity to not be trashed.
29-
* `Umb.Condition.SectionUserPermission` - Requires the current user to have permissions to the given Section Alias.
30-
* `Umb.Condition.UserPermission.Document` - Requires the current user to have specific Document permissions. Example: 'Umb.Document.Save'.
31-
* `Umb.Condition.CurrentUser.GroupId` - Requires the current user to belong to a specific group by GUID. Accepts `match` (GUID), `oneOf` (array), `allOf` (array), and `noneOf` (array). Example: '8d2b3c4d-4f1f-4b1f-8e3d-4a6b7b8c4f1e'.
32-
* `Umb.Condition.CurrentUser.IsAdmin` - Requires the current user to be an admin as defined by the backend, for example, that they belong to the Administrator group.
17+
- `Umb.Condition.Switch` - Toggles on and off based on the `frequency` set in seconds.
18+
- `Umb.Condition.MultipleAppLanguages` - Requires the app to have more than one language, such as a multi-language site.
19+
- `Umb.Condition.SectionAlias` - Requires the current Section Alias to match the one specified.
20+
- `Umb.Condition.MenuAlias` - Requires the current Menu Alias to match the one specified.
21+
- `Umb.Condition.WorkspaceAlias` - Requires the current Workspace Alias to match the one specified.
22+
- `Umb.Condition.WorkspaceContentTypeUnique` - Requires the current workspace Unique (GUID) matches the one specified.
23+
- `Umb.Condition.WorkspaceEntityType` - Requires the current workspace to work on the given Entity Type. Examples: 'document', 'block' or 'user'.
24+
- `Umb.Condition.WorkspaceContentTypeAlias` - Requires the current workspace to be based on a Content Type which Alias matches the one specified.
25+
- `Umb.Condition.Workspace.ContentHasProperties` - Requires the Content Type of the current Workspace to have properties.
26+
- `Umb.Condition.WorkspaceHasCollection` - Requires the current Workspace to have a Collection.
27+
- `Umb.Condition.WorkspaceEntityIsNew` - Requires the current Workspace data to be new, not yet persisted on the server.
28+
- `Umb.Condition.EntityIsTrashed` - Requires the current entity to be trashed.
29+
- `Umb.Condition.EntityIsNotTrashed` - Requires the current entity to not be trashed.
30+
- `Umb.Condition.SectionUserPermission` - Requires the current user to have permissions to the given Section Alias.
31+
- `Umb.Condition.UserPermission.Document` - Requires the current user to have specific Document permissions. Example: 'Umb.Document.Save'.
32+
- `Umb.Condition.CurrentUser.GroupId` - Requires the current user to belong to a specific group by GUID. Accepts `match` (GUID), `oneOf` (array), `allOf` (array), and `noneOf` (array). Example: '8d2b3c4d-4f1f-4b1f-8e3d-4a6b7b8c4f1e'.
33+
- `Umb.Condition.CurrentUser.IsAdmin` - Requires the current user to be an admin as defined by the backend, for example, that they belong to the Administrator group.
3334

3435
## Make your own Conditions
3536

3637
You can make your own Conditions by creating a class that implements the `UmbExtensionCondition` interface.
3738

3839
```typescript
3940
import {
40-
UmbConditionConfigBase,
41-
UmbConditionControllerArguments,
42-
UmbExtensionCondition
43-
} from '@umbraco-cms/backoffice/extension-api';
44-
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry';
45-
import { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
46-
47-
export type MyExtensionConditionConfig = UmbConditionConfigBase<'My.Condition.CustomName'> & {
48-
match?: string;
49-
};
50-
51-
export class MyExtensionCondition extends UmbConditionBase<MyExtensionConditionConfig> implements UmbExtensionCondition {
52-
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<MyExtensionConditionConfig>) {
53-
super(host, args);
54-
55-
// enable extension after 10 seconds
56-
setTimeout(() => {
57-
this.permitted = true;
58-
args.onChange();
59-
}, 10000);
60-
}
41+
UmbConditionConfigBase,
42+
UmbConditionControllerArguments,
43+
UmbExtensionCondition,
44+
} from "@umbraco-cms/backoffice/extension-api";
45+
import { UmbConditionBase } from "@umbraco-cms/backoffice/extension-registry";
46+
import { UmbControllerHost } from "@umbraco-cms/backoffice/controller-api";
47+
48+
export type MyExtensionConditionConfig =
49+
UmbConditionConfigBase<"My.Condition.CustomName"> & {
50+
match?: string;
51+
};
52+
53+
export class MyExtensionCondition
54+
extends UmbConditionBase<MyExtensionConditionConfig>
55+
implements UmbExtensionCondition
56+
{
57+
constructor(
58+
host: UmbControllerHost,
59+
args: UmbConditionControllerArguments<MyExtensionConditionConfig>
60+
) {
61+
super(host, args);
62+
63+
// enable extension after 10 seconds
64+
setTimeout(() => {
65+
this.permitted = true;
66+
args.onChange();
67+
}, 10000);
68+
}
6169
}
6270

6371
// Declare the Condition Configuration Type in the global UmbExtensionConditionConfigMap interface:
@@ -74,47 +82,53 @@ The Condition then needs to be registered in the Extension Registry:
7482

7583
```typescript
7684
export const manifest: UmbExtensionManifest = {
77-
type: 'condition',
78-
name: 'My Condition',
79-
alias: 'My.Condition.CustomName',
80-
api: MyExtensionCondition,
85+
type: "condition",
86+
name: "My Condition",
87+
alias: "My.Condition.CustomName",
88+
api: MyExtensionCondition,
8189
};
8290
```
8391

8492
Finally, you can make use of your condition in any manifests:
8593

8694
```typescript
8795
export const manifest: UmbExtensionManifest = {
88-
type: 'workspaceAction',
89-
name: 'example-workspace-action',
90-
alias: 'My.Example.WorkspaceAction',
91-
elementName: 'my-workspace-action-element',
92-
conditions: [
93-
{
94-
alias: 'Umb.Condition.SectionAlias',
95-
match: 'My.Example.Workspace'
96-
},
97-
{
98-
alias: 'My.Condition.CustomName'
99-
}
100-
]
101-
}
96+
type: "workspaceAction",
97+
name: "example-workspace-action",
98+
alias: "My.Example.WorkspaceAction",
99+
elementName: "my-workspace-action-element",
100+
conditions: [
101+
{
102+
alias: "Umb.Condition.SectionAlias",
103+
match: "My.Example.Workspace",
104+
},
105+
{
106+
alias: "My.Condition.CustomName",
107+
},
108+
],
109+
};
102110
```
103111

104112
As shown in the code above, the configuration property `match` isn't used for our condition. We can do this by replacing the timeout with some other check:
105113

106114
```typescript
107115
// ...
108116

109-
export class MyExtensionCondition extends UmbConditionBase<MyExtensionConditionConfig> implements UmbExtensionCondition {
110-
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<MyExtensionConditionConfig>) {
111-
super(host, args);
112-
113-
if (args.config.match === 'Yes') {
114-
this.permitted = true;
115-
args.onChange();
117+
export class MyExtensionCondition
118+
extends UmbConditionBase<MyExtensionConditionConfig>
119+
implements UmbExtensionCondition
120+
{
121+
constructor(
122+
host: UmbControllerHost,
123+
args: UmbConditionControllerArguments<MyExtensionConditionConfig>
124+
) {
125+
super(host, args);
126+
127+
if (args.config.match === "Yes") {
128+
this.permitted = true;
129+
args.onChange();
130+
}
116131
}
117-
}
118132
}
119133

120134
// ...
@@ -124,13 +138,13 @@ With all that in place, the configuration can look like shown below:
124138

125139
```typescript
126140
{
127-
// ...
128-
conditions: [
129-
// ...
130-
{
131-
alias: 'My.Condition.CustomName',
132-
match: 'Yes'
133-
}
134-
]
141+
// ...
142+
conditions: [
143+
// ...
144+
{
145+
alias: "My.Condition.CustomName",
146+
match: "Yes",
147+
},
148+
];
135149
}
136150
```

0 commit comments

Comments
 (0)