From ff02b28d26fdd5cce767b9b2e0c2e160955acbbc Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 3 Jul 2017 16:31:47 +1000 Subject: [PATCH] Fixes tree for single tree sections, fixes creating a user group so you can select default permissions --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 13 ---------- .../Editors/UserGroupsController.cs | 2 +- .../Models/Mapping/PermissionsResolver.cs | 2 +- src/Umbraco.Web/Security/WebSecurity.cs | 2 +- .../Trees/ApplicationTreeController.cs | 24 +++++++++++++++---- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index fb7222c04f..a4c549ac75 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -573,7 +573,6 @@ - @@ -583,13 +582,6 @@ umbraco.aspx - - EditUser.aspx - ASPXCodeBehind - - - EditUser.aspx - @@ -1011,10 +1003,6 @@ - - - - @@ -1068,7 +1056,6 @@ - diff --git a/src/Umbraco.Web/Editors/UserGroupsController.cs b/src/Umbraco.Web/Editors/UserGroupsController.cs index 498e792446..78dc0afeda 100644 --- a/src/Umbraco.Web/Editors/UserGroupsController.cs +++ b/src/Umbraco.Web/Editors/UserGroupsController.cs @@ -39,7 +39,7 @@ namespace Umbraco.Web.Editors /// public UserGroupDisplay GetEmptyUserGroup() { - return new UserGroupDisplay(); + return Mapper.Map(new UserGroup()); } /// diff --git a/src/Umbraco.Web/Models/Mapping/PermissionsResolver.cs b/src/Umbraco.Web/Models/Mapping/PermissionsResolver.cs index 297b4092cb..d39ddf5998 100644 --- a/src/Umbraco.Web/Models/Mapping/PermissionsResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/PermissionsResolver.cs @@ -46,7 +46,7 @@ namespace Umbraco.Web.Models.Mapping : attribute.Name; result.Description = _textService.Localize(String.Format("actionDescriptions/{0}", action.Alias)); result.Icon = action.Icon; - result.Checked = source.Permissions.Contains(action.Letter.ToString(CultureInfo.InvariantCulture)); + result.Checked = source.Permissions != null && source.Permissions.Contains(action.Letter.ToString(CultureInfo.InvariantCulture)); result.PermissionCode = action.Letter.ToString(CultureInfo.InvariantCulture); return result; } diff --git a/src/Umbraco.Web/Security/WebSecurity.cs b/src/Umbraco.Web/Security/WebSecurity.cs index 9178215706..e4a29bd6cc 100644 --- a/src/Umbraco.Web/Security/WebSecurity.cs +++ b/src/Umbraco.Web/Security/WebSecurity.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Security public WebSecurity(HttpContextBase httpContext, ApplicationContext applicationContext) { _httpContext = httpContext; - _applicationContext = applicationContext; + _applicationContext = applicationContext; } /// diff --git a/src/Umbraco.Web/Trees/ApplicationTreeController.cs b/src/Umbraco.Web/Trees/ApplicationTreeController.cs index f6b5e82fc3..566d723460 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeController.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeController.cs @@ -42,7 +42,7 @@ namespace Umbraco.Web.Trees //find all tree definitions that have the current application alias var appTrees = ApplicationContext.Current.Services.ApplicationTreeService.GetApplicationTrees(application, onlyInitialized).ToArray(); - if (appTrees.Count() == 1 || string.IsNullOrEmpty(tree) == false ) + if (string.IsNullOrEmpty(tree) == false || appTrees.Length == 1) { var apptree = string.IsNullOrEmpty(tree) == false ? appTrees.SingleOrDefault(x => x.Alias == tree) @@ -55,11 +55,12 @@ namespace Umbraco.Web.Trees Constants.System.Root.ToString(CultureInfo.InvariantCulture), queryStrings, application); - - return result; + + //this will be null if it cannot convert to ta single root section + if (result != null) + return result; } - var collection = new TreeNodeCollection(); foreach (var apptree in appTrees) { @@ -107,6 +108,7 @@ namespace Umbraco.Web.Trees /// /// /// + /// /// private async Task GetRootForSingleAppTree(ApplicationTree configTree, string id, FormDataCollection queryStrings, string application) { @@ -121,6 +123,16 @@ namespace Umbraco.Web.Trees //This should really never happen if we've successfully got the children above. throw new InvalidOperationException("Could not create root node for tree " + configTree.Alias); } + + //if the root node has a route path, we cannot create a single root section because by specifying the route path this would + //override the dashboard route and that means there can be no dashboard for that section which is a breaking change. + if (rootNode.Result.RoutePath.IsNullOrWhiteSpace() == false + && rootNode.Result.RoutePath != "#" + && rootNode.Result.RoutePath != application) + { + //null indicates this cannot be converted + return null; + } var sectionRoot = SectionRootNode.CreateSingleTreeSectionRoot( rootId, @@ -128,6 +140,10 @@ namespace Umbraco.Web.Trees rootNode.Result.MenuUrl, rootNode.Result.Name, byControllerAttempt.Result); + + //This can't be done currently because the root will default to routing to a dashboard and if we disable dashboards for a section + //that is really considered a breaking change. See above. + //sectionRoot.RoutePath = rootNode.Result.RoutePath; foreach (var d in rootNode.Result.AdditionalData) {