Skip to content

Commit d0a9802

Browse files
authored
Merge pull request #7538 from umbraco/v17/cms/additional-preview-kinds
CMS V17: Document different "kinds" of workspaceActionMenuItem (relevant for additional preview environments)
2 parents af860bc + eddbae7 commit d0a9802

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

17/umbraco-cms/customizing/extending-overview/extension-types/workspaces/workspace-action-menu-items.md

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,58 @@ Workspace Action Menu Items extend existing workspace actions by adding dropdown
3434
- **`meta.label`** - Text displayed in dropdown
3535
- **`meta.icon`** - Icon displayed alongside label
3636

37+
## Kinds
38+
39+
The `kind` property determines the behavior and purpose of the workspace action menu item. Each kind provides specialized functionality for different use cases.
40+
41+
### default
42+
43+
The `default` kind provides standard menu item functionality for executing custom actions.
44+
45+
**Properties:**
46+
- **`api`** - Class that extends `UmbWorkspaceActionMenuItemBase` and implements either `execute()` or `getHref()` method
47+
- **`meta.label`** - Text displayed in the menu item
48+
- **`meta.icon`** - Optional icon displayed alongside the label
49+
50+
The API class provides either a `getHref()` method or an `execute()` method. If the `getHref()` method is provided, the action will open the returned URL. Otherwise, the `execute()` method will be run when the menu item is clicked.
51+
52+
**Use case:** General purpose menu items that execute custom logic or navigate to a URL when clicked.
53+
54+
### previewOption
55+
56+
The `previewOption` kind creates menu items for document preview scenarios, integrating with server-side URL providers to generate preview URLs for different environments.
57+
58+
**Properties:**
59+
- **`meta.label`** - Text displayed in the menu item
60+
- **`meta.icon`** - Icon displayed alongside the label
61+
- **`meta.urlProviderAlias`** - Alias of the server-side `IUrlProvider` that generates the preview URL
62+
63+
**Use case:** Custom preview options that open documents in different preview environments (staging, production, or custom domains).
64+
65+
{% code caption="Custom Preview Option Manifest" %}
66+
```typescript
67+
{
68+
type: 'workspaceActionMenuItem',
69+
kind: 'previewOption',
70+
alias: 'My.Custom.PreviewOption',
71+
name: 'My Custom Preview Option',
72+
forWorkspaceActions: 'Umb.WorkspaceAction.Document.SaveAndPreview',
73+
weight: 101,
74+
meta: {
75+
icon: 'icon-umbraco',
76+
label: 'Preview on Staging',
77+
urlProviderAlias: 'MyStagingUrlProvider',
78+
},
79+
}
80+
```
81+
{% endcode %}
82+
83+
{% hint style="info" %}
84+
The `previewOption` kind requires a server-side `IUrlProvider` to be registered with the matching `urlProviderAlias`. The provider generates the preview URL when the menu item is clicked.
85+
86+
Learn more about implementing server-side URL providers in the [Additional preview environments support](../../../../reference/content-delivery-api/additional-preview-environments-support.md) article.
87+
{% endhint %}
88+
3789
## Implementation
3890

3991
Create a workspace action menu item by extending `UmbWorkspaceActionMenuItemBase` and implementing the `execute` method. This provides the functionality that runs when a user interacts with the menu item:
@@ -50,7 +102,7 @@ export class ExampleResetCounterMenuItemAction extends UmbWorkspaceActionMenuIte
50102
if (!context) {
51103
throw new Error('Could not get the counter context');
52104
}
53-
105+
54106
context.reset();
55107
}
56108
}
@@ -84,9 +136,9 @@ Menu items display a dropdown menu for their associated actions:
84136
}
85137

86138
{
87-
type: 'workspaceActionMenuItem',
139+
type: 'workspaceActionMenuItem',
88140
alias: 'example.menuItem.saveAsDraft',
89141
forWorkspaceActions: 'example.workspaceAction.save',
90142
meta: { label: 'Save as Draft' },
91143
}
92-
```
144+
```

17/umbraco-cms/reference/content-delivery-api/additional-preview-environments-support.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ On the client side, you'll need an extension of:
8282
- Kind: `previewOption`.
8383

8484
{% hint style="info" %}
85-
You can read more about extensions in the [Extending the Umbraco Backoffice](https://docs.umbraco.com/welcome/getting-started/developing-websites-with-umbraco/extending-the-umbraco-backoffice) article.
85+
Learn more about the `previewOption` kind and workspace action menu items in the [Workspace Action Menu Items](../../customizing/extending-overview/extension-types/workspaces/workspace-action-menu-items.md) article.
86+
87+
You can also read more about extensions in the [Extending the Umbraco Backoffice](https://docs.umbraco.com/welcome/getting-started/developing-websites-with-umbraco/extending-the-umbraco-backoffice) article.
8688
{% endhint %}
8789

8890
Here's a sample extension:
@@ -121,4 +123,13 @@ The default "Save and preview" button is also an extension of this type.
121123
In other words, multiple preview options can co-exist. If you have multiple external environments, you can create preview options for all of them.
122124

123125
The extension `weight` determines the order of appearance. A `weight` above 100 will swap the default preview option with the custom one.
126+
127+
{% hint style="tip" %}
128+
**Alternative approach without server-side URL provider**
129+
130+
If you want to create a preview option that opens a specific URL without server-side logic, you can use the `default` kind instead of `previewOption`. With the `default` kind, you provide an `api` class that implements a `getHref()` method to return the URL to open.
131+
132+
This is useful for static preview URLs or when you can construct the preview URL entirely on the client side.
133+
134+
Learn more in the [Workspace Action Menu Items](../../customizing/extending-overview/extension-types/workspaces/workspace-action-menu-items.md#default) article.
124135
{% endhint %}

0 commit comments

Comments
 (0)