[ACA-1830] create menu enhancements (#670)

* nested menus for create button

* evaluate sub-menu permissions

* demo plugin

* "create library" action

* unit tests and proper effect name
This commit is contained in:
Denys Vuika
2018-09-27 09:07:24 +01:00
committed by GitHub
parent 23df2ad6a2
commit 457fa74048
22 changed files with 347 additions and 186 deletions

View File

@@ -196,7 +196,8 @@ export class AppExtensionService implements RuleContext {
getCreateActions(): Array<ContentActionRef> {
return this.createActions
.filter(action => this.filterByRules(action))
.map(action => this.copyAction(action))
.map(action => this.buildMenu(action))
.map(action => {
let disabled = false;
@@ -211,6 +212,39 @@ export class AppExtensionService implements RuleContext {
});
}
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
if (
actionRef.type === ContentActionType.menu &&
actionRef.children &&
actionRef.children.length > 0
) {
const children = actionRef.children
.filter(action => this.filterByRules(action))
.map(action => this.buildMenu(action));
actionRef.children = children
.map(action => {
let disabled = false;
if (action.rules && action.rules.enabled) {
disabled = !this.extensions.evaluateRule(
action.rules.enabled,
this
);
}
return {
...action,
disabled
};
})
.reduce(reduceEmptyMenus, [])
.reduce(reduceSeparators, []);
}
return actionRef;
}
// evaluates content actions for the selection and parent folder node
getAllowedToolbarActions(): Array<ContentActionRef> {
return this.toolbarActions