mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
fix visibility evaluation for create menu (#1017)
This commit is contained in:
@@ -240,13 +240,13 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
...group,
|
...group,
|
||||||
items: (group.items || [])
|
items: (group.items || [])
|
||||||
.filter(entry => !entry.disabled)
|
.filter(entry => !entry.disabled)
|
||||||
.filter(item => this.filterByRules(item))
|
.filter(item => this.filterVisible(item))
|
||||||
.sort(sortByOrder)
|
.sort(sortByOrder)
|
||||||
.map(item => {
|
.map(item => {
|
||||||
if (item.children && item.children.length > 0) {
|
if (item.children && item.children.length > 0) {
|
||||||
item.children = item.children
|
item.children = item.children
|
||||||
.filter(entry => !entry.disabled)
|
.filter(entry => !entry.disabled)
|
||||||
.filter(child => this.filterByRules(child))
|
.filter(child => this.filterVisible(child))
|
||||||
.sort(sortByOrder)
|
.sort(sortByOrder)
|
||||||
.map(child => {
|
.map(child => {
|
||||||
const childRouteRef = this.extensions.getRouteById(
|
const childRouteRef = this.extensions.getRouteById(
|
||||||
@@ -320,7 +320,7 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSidebarTabs(): Array<SidebarTabRef> {
|
getSidebarTabs(): Array<SidebarTabRef> {
|
||||||
return this.sidebar.filter(action => this.filterByRules(<any>action));
|
return this.sidebar.filter(action => this.filterVisible(<any>action));
|
||||||
}
|
}
|
||||||
|
|
||||||
getComponentById(id: string): Type<{}> {
|
getComponentById(id: string): Type<{}> {
|
||||||
@@ -351,6 +351,7 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
|
|
||||||
getCreateActions(): Array<ContentActionRef> {
|
getCreateActions(): Array<ContentActionRef> {
|
||||||
return this.createActions
|
return this.createActions
|
||||||
|
.filter(action => this.filterVisible(action))
|
||||||
.map(action => this.copyAction(action))
|
.map(action => this.copyAction(action))
|
||||||
.map(action => this.buildMenu(action))
|
.map(action => this.buildMenu(action))
|
||||||
.map(action => {
|
.map(action => {
|
||||||
@@ -374,7 +375,7 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
actionRef.children.length > 0
|
actionRef.children.length > 0
|
||||||
) {
|
) {
|
||||||
const children = actionRef.children
|
const children = actionRef.children
|
||||||
.filter(action => this.filterByRules(action))
|
.filter(action => this.filterVisible(action))
|
||||||
.map(action => this.buildMenu(action));
|
.map(action => this.buildMenu(action));
|
||||||
|
|
||||||
actionRef.children = children
|
actionRef.children = children
|
||||||
@@ -403,14 +404,14 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
|
|
||||||
private getAllowedActions(actions: ContentActionRef[]): ContentActionRef[] {
|
private getAllowedActions(actions: ContentActionRef[]): ContentActionRef[] {
|
||||||
return (actions || [])
|
return (actions || [])
|
||||||
.filter(action => this.filterByRules(action))
|
.filter(action => this.filterVisible(action))
|
||||||
.map(action => {
|
.map(action => {
|
||||||
if (action.type === ContentActionType.menu) {
|
if (action.type === ContentActionType.menu) {
|
||||||
const copy = this.copyAction(action);
|
const copy = this.copyAction(action);
|
||||||
if (copy.children && copy.children.length > 0) {
|
if (copy.children && copy.children.length > 0) {
|
||||||
copy.children = copy.children
|
copy.children = copy.children
|
||||||
.filter(entry => !entry.disabled)
|
.filter(entry => !entry.disabled)
|
||||||
.filter(childAction => this.filterByRules(childAction))
|
.filter(childAction => this.filterVisible(childAction))
|
||||||
.sort(sortByOrder)
|
.sort(sortByOrder)
|
||||||
.reduce(reduceSeparators, []);
|
.reduce(reduceSeparators, []);
|
||||||
}
|
}
|
||||||
@@ -435,7 +436,7 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getHeaderActions(): Array<ContentActionRef> {
|
getHeaderActions(): Array<ContentActionRef> {
|
||||||
return this.headerActions.filter(action => this.filterByRules(action));
|
return this.headerActions.filter(action => this.filterVisible(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllowedContextMenuActions(): Array<ContentActionRef> {
|
getAllowedContextMenuActions(): Array<ContentActionRef> {
|
||||||
@@ -449,7 +450,7 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
filterByRules(action: ContentActionRef): boolean {
|
filterVisible(action: ContentActionRef): boolean {
|
||||||
if (action && action.rules && action.rules.visible) {
|
if (action && action.rules && action.rules.visible) {
|
||||||
return this.extensions.evaluateRule(action.rules.visible, this);
|
return this.extensions.evaluateRule(action.rules.visible, this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user