Skip to content

Commit fd5077d

Browse files
Example Docs: Add menu item examples (#20910)
Add menu item registration examples Introduces example implementations for registering action, link, and entity menu items in the backoffice. Includes manifests and API to demonstrate how to extend the menu system.
1 parent 3d90fff commit fd5077d

File tree

7 files changed

+81
-0
lines changed

7 files changed

+81
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Menu Item Example
2+
3+
This example demonstrates how to register a Menu Item.
4+
5+
The example includes:
6+
7+
- Action Menu Item Registration
8+
- Link Menu Item Registration
9+
- Entity Menu Item Registration
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { UmbMenuItemActionApiBase } from '@umbraco-cms/backoffice/menu';
2+
3+
/**
4+
* Example menu item action API
5+
* This action will log "Hello world" to the console when executed.
6+
*/
7+
export class ExampleActionMenuItemApi extends UmbMenuItemActionApiBase<never> {
8+
/**
9+
* This method is executed when the menu item is clicked
10+
*/
11+
override async execute() {
12+
console.log('Hello world');
13+
}
14+
}
15+
16+
// Declare an `api` export so the Extension Registry can initialize this class
17+
export { ExampleActionMenuItemApi as api };
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { UMB_CONTENT_MENU_ALIAS } from '@umbraco-cms/backoffice/document';
2+
3+
export const manifests: Array<UmbExtensionManifest> = [
4+
{
5+
type: 'menuItem',
6+
kind: 'action',
7+
alias: 'Example.MenuItem.Action',
8+
name: 'Example Action Menu Item',
9+
api: () => import('./action-menu-item.api.js'),
10+
meta: {
11+
label: 'Example Action Menu Item',
12+
icon: 'icon-hammer',
13+
menus: [UMB_CONTENT_MENU_ALIAS],
14+
},
15+
},
16+
];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { UMB_CONTENT_MENU_ALIAS } from '@umbraco-cms/backoffice/document';
2+
3+
export const manifests: Array<UmbExtensionManifest> = [
4+
{
5+
type: 'menuItem',
6+
alias: 'Example.MenuItem.Entity',
7+
name: 'Example Entity Menu Item',
8+
meta: {
9+
label: 'Example Entity Menu Item',
10+
icon: 'icon-wand',
11+
entityType: 'example-entity-type',
12+
menus: [UMB_CONTENT_MENU_ALIAS],
13+
},
14+
},
15+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { manifests as actionManifests } from './action/manifests.js';
2+
import { manifests as entityManifests } from './entity/manifests.js';
3+
import { manifests as linkManifests } from './link/manifests.js';
4+
5+
export const manifests = [...actionManifests, ...entityManifests, ...linkManifests];
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { UMB_CONTENT_MENU_ALIAS } from '@umbraco-cms/backoffice/document';
2+
3+
export const manifests: Array<UmbExtensionManifest> = [
4+
{
5+
type: 'menuItem',
6+
kind: 'link',
7+
alias: 'Example.MenuItem.ExternalLink',
8+
name: 'Example External Link Menu Item',
9+
meta: {
10+
label: 'Example Link Menu Item',
11+
icon: 'icon-link',
12+
href: 'https://',
13+
menus: [UMB_CONTENT_MENU_ALIAS],
14+
},
15+
},
16+
];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Tree Menu Item
2+
3+
See the Tree Example of how to register a tree and use it as a menu item in the sidebar.

0 commit comments

Comments
 (0)