filter children by rule (#735)

This commit is contained in:
Cilibiu Bogdan
2018-10-18 21:21:58 +03:00
committed by Denys Vuika
parent 3bf9cc1fb2
commit 061836d217

View File

@@ -360,7 +360,26 @@ export class AppExtensionService implements RuleContext {
}
getAllowedContextMenuActions(): Array<ContentActionRef> {
return this.contextMenuActions.filter(action => this.filterByRules(action));
return this.contextMenuActions
.filter(action => this.filterByRules(action))
.map(action => {
if (action.type === ContentActionType.menu) {
if (action.type === ContentActionType.menu) {
const copy = this.copyAction(action);
if (copy.children && copy.children.length > 0) {
copy.children = copy.children
.filter(childAction => this.filterByRules(childAction))
.reduce(reduceSeparators, []);
}
return copy;
}
return action;
} else {
return action;
}
})
.reduce(reduceEmptyMenus, [])
.reduce(reduceSeparators, []);
}
copyAction(action: ContentActionRef): ContentActionRef {