-
-
Notifications
You must be signed in to change notification settings - Fork 927
/
add-action-bar-item.ts
32 lines (31 loc) · 1.01 KB
/
add-action-bar-item.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { APP_INITIALIZER, Provider } from '@angular/core';
import { ActionBarItem } from '../providers/nav-builder/nav-builder-types';
import { NavBuilderService } from '../providers/nav-builder/nav-builder.service';
/**
* @description
* Adds a button to the ActionBar at the top right of each list or detail view. The locationId can
* be determined by pressing `ctrl + u` when running the Admin UI in dev mode.
*
* @example
* ```ts title="providers.ts"
* export default [
* addActionBarItem({
* id: 'print-invoice',
* label: 'Print Invoice',
* locationId: 'order-detail',
* routerLink: ['/extensions/invoicing'],
* }),
* ];
* ```
* @docsCategory action-bar
*/
export function addActionBarItem(config: ActionBarItem): Provider {
return {
provide: APP_INITIALIZER,
multi: true,
useFactory: (navBuilderService: NavBuilderService) => () => {
navBuilderService.addActionBarItem(config);
},
deps: [NavBuilderService],
};
}