-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Add support for custom action bar dropdown menus
Closes #2678
- Loading branch information
1 parent
81419e4
commit 4d8bc74
Showing
50 changed files
with
473 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/admin-ui/src/lib/core/src/extension/add-action-bar-dropdown-menu-item.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { APP_INITIALIZER, Provider } from '@angular/core'; | ||
import { ActionBarDropdownMenuItem } from '../providers/nav-builder/nav-builder-types'; | ||
import { NavBuilderService } from '../providers/nav-builder/nav-builder.service'; | ||
|
||
/** | ||
* @description | ||
* Adds a dropdown menu item 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" | ||
* import { addActionBarDropdownMenuItem } from '\@vendure/admin-ui/core'; | ||
* | ||
* export default [ | ||
* addActionBarDropdownMenuItem({ | ||
* id: 'print-invoice', | ||
* label: 'Print Invoice', | ||
* locationId: 'order-detail', | ||
* routerLink: ['/extensions/invoicing'], | ||
* }), | ||
* ]; | ||
* ``` | ||
* @docsCategory action-bar | ||
*/ | ||
export function addActionBarDropdownMenuItem(config: ActionBarDropdownMenuItem): Provider { | ||
return { | ||
provide: APP_INITIALIZER, | ||
multi: true, | ||
useFactory: (navBuilderService: NavBuilderService) => () => { | ||
navBuilderService.addActionBarDropdownMenuItem(config); | ||
}, | ||
deps: [NavBuilderService], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
28 changes: 28 additions & 0 deletions
28
...re/src/shared/components/action-bar-dropdown-menu/action-bar-dropdown-menu.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<vdr-ui-extension-point [locationId]="locationId" api="actionBarDropdown" [leftPx]="-24"> | ||
<vdr-dropdown #dropdownComponent *ngIf="alwaysShow || (items$ | async)?.length"> | ||
<button class="icon-button" vdrDropdownTrigger> | ||
<clr-icon shape="ellipsis-vertical"></clr-icon> | ||
</button> | ||
<vdr-dropdown-menu vdrPosition="bottom-right"> | ||
<ng-content /> | ||
<ng-container *ngFor="let item of items$ | async"> | ||
<ng-container *ngIf="buttonStates[item.id] | async as buttonState"> | ||
<div class="dropdown-divider" *ngIf="item.hasDivider === true"></div> | ||
<button | ||
type="button" | ||
vdrDropdownItem | ||
*vdrIfPermissions="item.requiresPermission" | ||
[routerLink]="getRouterLink(item)" | ||
[class.hidden]="buttonState.visible === false" | ||
[disabled]="buttonState.disabled" | ||
(click)="handleClick($event, item)" | ||
class="mr-2" | ||
> | ||
<clr-icon *ngIf="item.icon" [attr.shape]="item.icon"></clr-icon> | ||
{{ item.label | translate }} | ||
</button> | ||
</ng-container> | ||
</ng-container> | ||
</vdr-dropdown-menu> | ||
</vdr-dropdown> | ||
</vdr-ui-extension-point> |
Oops, something went wrong.