Skip to content

Commit 66ec0dd

Browse files
committed
add action api example
1 parent 810ae3a commit 66ec0dd

File tree

2 files changed

+36
-0
lines changed
  • 16/umbraco-cms/customizing/extending-overview/extension-types
  • 17/umbraco-cms/customizing/extending-overview/extension-types

2 files changed

+36
-0
lines changed

16/umbraco-cms/customizing/extending-overview/extension-types/menu-item.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ export const menuItemManifest: ManifestMenuItem = {
158158
```
159159
{% endcode %}
160160

161+
{% code title="menu-item.api.ts" %}
162+
```typescript
163+
import { UmbMenuItemActionApiBase } from '@umbraco-cms/backoffice/menu';
164+
165+
export class MyActionMenuItemApi extends UmbMenuItemActionApiBase<never> {
166+
/**
167+
* This method is executed when the menu item is clicked
168+
*/
169+
override async execute() {
170+
console.log('Hello world');
171+
}
172+
}
173+
174+
// Declare an `api` export so the Extension Registry can initialize this class
175+
export { MyActionMenuItemApi as api };
176+
```
177+
{% endcode %}
178+
161179
### Tree
162180

163181
Use a tree menu item to show a submenu based on a tree structure. Any existing, registered Tree Repositories can be referenced by its extension alias (`treeAlias` property) in the Menu Item manifest. This will render a fully functional tree-based menu.

17/umbraco-cms/customizing/extending-overview/extension-types/menu-item.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ export const menuItemManifest: ManifestMenuItem = {
158158
```
159159
{% endcode %}
160160

161+
{% code title="menu-item.api.ts" %}
162+
```typescript
163+
import { UmbMenuItemActionApiBase } from '@umbraco-cms/backoffice/menu';
164+
165+
export class MyActionMenuItemApi extends UmbMenuItemActionApiBase<never> {
166+
/**
167+
* This method is executed when the menu item is clicked
168+
*/
169+
override async execute() {
170+
console.log('Hello world');
171+
}
172+
}
173+
174+
// Declare an `api` export so the Extension Registry can initialize this class
175+
export { MyActionMenuItemApi as api };
176+
```
177+
{% endcode %}
178+
161179
### Tree
162180

163181
Use a tree menu item to show a submenu based on a tree structure. Any existing, registered Tree Repositories can be referenced by its extension alias (`treeAlias` property) in the Menu Item manifest. This will render a fully functional tree-based menu.

0 commit comments

Comments
 (0)