diff --git a/src/Umbraco.Core/Manifest/ManifestContentAppDefinition.cs b/src/Umbraco.Core/Manifest/ManifestContentAppDefinition.cs index 6b8534a88f..8d1acb843a 100644 --- a/src/Umbraco.Core/Manifest/ManifestContentAppDefinition.cs +++ b/src/Umbraco.Core/Manifest/ManifestContentAppDefinition.cs @@ -6,6 +6,9 @@ using System.Text.RegularExpressions; using Umbraco.Core.IO; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; +using Umbraco.Core.Models.Membership; +using Umbraco.Core.Services; + namespace Umbraco.Core.Manifest { @@ -82,9 +85,9 @@ namespace Umbraco.Core.Manifest public string[] Show { get; set; } = Array.Empty(); /// - public ContentApp GetContentAppFor(object o) + public ContentApp GetContentAppFor(object o, IEnumerable userGroups) { - string partA, partB; + string partA, partB; switch (o) { @@ -112,6 +115,18 @@ namespace Umbraco.Core.Manifest // else iterate over each entry foreach (var rule in rules) { + if (rule.PartA == "role") + { + foreach (var group in userGroups) + { + if (rule.Matches(rule.PartA, group.Alias)) + { + ok = rule.Show; + break; + } + } + } + // if the entry does not apply, skip it if (!rule.Matches(partA, partB)) continue; diff --git a/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs b/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs index 5e0c421742..2d30fc6ba9 100644 --- a/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs +++ b/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs @@ -1,4 +1,7 @@ -namespace Umbraco.Core.Models.ContentEditing +using System.Collections.Generic; +using Umbraco.Core.Models.Membership; + +namespace Umbraco.Core.Models.ContentEditing { /// /// Represents a content app definition. @@ -15,6 +18,6 @@ /// the content app should be displayed or not, and return either a /// instance, or null. /// - ContentApp GetContentAppFor(object source); + ContentApp GetContentAppFor(object source, IEnumerable userGroups); } } diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 35cfa96d67..14d4539d59 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -5464,8 +5464,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -5880,8 +5879,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -5937,7 +5935,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5981,14 +5978,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -8526,10 +8521,10 @@ "resolved": "https://registry.npmjs.org/jquery-migrate/-/jquery-migrate-1.4.0.tgz", "integrity": "sha1-4AKOSDHMFH2PIvOCBRbr+5dReaU=" }, - "jquery-ui": { + "jquery-ui-dist": { "version": "1.12.1", - "resolved": "https://registry.npmjs.org/jquery-ui/-/jquery-ui-1.12.1.tgz", - "integrity": "sha1-vLQEXI3QU5wTS8FIjN0+dop6nlE=" + "resolved": "https://registry.npmjs.org/jquery-ui-dist/-/jquery-ui-dist-1.12.1.tgz", + "integrity": "sha1-XAgV08xvkP9fqvWyaKbiO0ypBPo=" }, "jquery-validation": { "version": "1.17.0", diff --git a/src/Umbraco.Web/ContentApps/ContentAppDefinitionCollection.cs b/src/Umbraco.Web/ContentApps/ContentAppDefinitionCollection.cs index 7dda00e62c..bdd7455386 100644 --- a/src/Umbraco.Web/ContentApps/ContentAppDefinitionCollection.cs +++ b/src/Umbraco.Web/ContentApps/ContentAppDefinitionCollection.cs @@ -5,6 +5,7 @@ using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.Logging; +using Umbraco.Core.Models.Membership; namespace Umbraco.Web.ContentApps { @@ -18,9 +19,11 @@ namespace Umbraco.Web.ContentApps _logger = logger; } - public IEnumerable GetContentAppsFor(object o) + public IEnumerable GetContentAppsFor(object o, IEnumerable userGroups=null) { - var apps = this.Select(x => x.GetContentAppFor(o)).WhereNotNull().OrderBy(x => x.Weight).ToList(); + var currentUser = UmbracoContext.Current.Security.CurrentUser; + var roles = currentUser.Groups; + var apps = this.Select(x => x.GetContentAppFor(o, roles)).WhereNotNull().OrderBy(x => x.Weight).ToList(); var aliases = new HashSet(); List dups = null; diff --git a/src/Umbraco.Web/ContentApps/ContentEditorContentAppDefinition.cs b/src/Umbraco.Web/ContentApps/ContentEditorContentAppDefinition.cs index c2d6341e87..d54d1a44d4 100644 --- a/src/Umbraco.Web/ContentApps/ContentEditorContentAppDefinition.cs +++ b/src/Umbraco.Web/ContentApps/ContentEditorContentAppDefinition.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; +using Umbraco.Core.Models.Membership; namespace Umbraco.Web.ContentApps { @@ -12,7 +14,7 @@ namespace Umbraco.Web.ContentApps private ContentApp _contentApp; private ContentApp _mediaApp; - public ContentApp GetContentAppFor(object o) + public ContentApp GetContentAppFor(object o, IEnumerable userGroups) { switch (o) { diff --git a/src/Umbraco.Web/ContentApps/ContentInfoContentAppDefinition.cs b/src/Umbraco.Web/ContentApps/ContentInfoContentAppDefinition.cs index be7a40f007..de490439ba 100644 --- a/src/Umbraco.Web/ContentApps/ContentInfoContentAppDefinition.cs +++ b/src/Umbraco.Web/ContentApps/ContentInfoContentAppDefinition.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; +using Umbraco.Core.Models.Membership; namespace Umbraco.Web.ContentApps { @@ -12,7 +14,7 @@ namespace Umbraco.Web.ContentApps private ContentApp _contentApp; private ContentApp _mediaApp; - public ContentApp GetContentAppFor(object o) + public ContentApp GetContentAppFor(object o, IEnumerable userGroups) { switch (o) { diff --git a/src/Umbraco.Web/ContentApps/ListViewContentAppDefinition.cs b/src/Umbraco.Web/ContentApps/ListViewContentAppDefinition.cs index 5c73b2fa8c..ce3ea258d1 100644 --- a/src/Umbraco.Web/ContentApps/ListViewContentAppDefinition.cs +++ b/src/Umbraco.Web/ContentApps/ListViewContentAppDefinition.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; +using Umbraco.Core.Models.Membership; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; @@ -22,7 +23,7 @@ namespace Umbraco.Web.ContentApps _propertyEditors = propertyEditors; } - public ContentApp GetContentAppFor(object o) + public ContentApp GetContentAppFor(object o, IEnumerable userGroups) { string contentTypeAlias, entityType;