diff --git a/src/Umbraco.Core/Models/ApplicationTree.cs b/src/Umbraco.Core/Models/ApplicationTree.cs index 0397b4238d..92002f1e99 100644 --- a/src/Umbraco.Core/Models/ApplicationTree.cs +++ b/src/Umbraco.Core/Models/ApplicationTree.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Concurrent; using System.Diagnostics; -using Umbraco.Core.Logging; namespace Umbraco.Core.Models { diff --git a/src/Umbraco.Web/Editors/SectionController.cs b/src/Umbraco.Web/Editors/SectionController.cs index 6563e18b17..ae69d9da0a 100644 --- a/src/Umbraco.Web/Editors/SectionController.cs +++ b/src/Umbraco.Web/Editors/SectionController.cs @@ -1,11 +1,8 @@ using System.Collections.Generic; using AutoMapper; -using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; -using Umbraco.Web.WebApi; using System.Linq; -using System.Net.Http.Formatting; using Umbraco.Web.Trees; namespace Umbraco.Web.Editors @@ -17,23 +14,23 @@ namespace Umbraco.Web.Editors public class SectionController : UmbracoAuthorizedJsonController { public IEnumerable
GetSections() - { + { var sections = Services.SectionService.GetAllowedSections(Security.GetUserId()); - var sectionModels = sections.Select(Mapper.Map).ToArray(); - - //Check if there are empty dashboards or dashboards that will end up empty based on the current user's access - //and add the meta data about them - var dashboardHelper = new DashboardHelper(Services.SectionService); - //this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that - //since tree's by nature are controllers and require request contextual data. + var sectionModels = sections.Select(Mapper.Map).ToArray(); + + //Check if there are empty dashboards or dashboards that will end up empty based on the current user's access + //and add the meta data about them + var dashboardHelper = new DashboardHelper(Services.SectionService); + //this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that + //since tree's by nature are controllers and require request contextual data. var appTreeController = new ApplicationTreeController { ControllerContext = ControllerContext }; - var dashboards = dashboardHelper.GetDashboards(Security.CurrentUser); - //now we can add metadata for each section so that the UI knows if there's actually anything at all to render for + var dashboards = dashboardHelper.GetDashboards(Security.CurrentUser); + //now we can add metadata for each section so that the UI knows if there's actually anything at all to render for //a dashboard for a given section, then the UI can deal with it accordingly (i.e. redirect to the first tree) foreach (var section in sectionModels) { @@ -49,11 +46,11 @@ namespace Umbraco.Web.Editors { //get the first tree in the section and get it's root node route path var sectionTrees = appTreeController.GetApplicationTrees(section.Alias, null, null).Result; - section.RoutePath = sectionTrees.IsContainer == false - ? sectionTrees.RoutePath + section.RoutePath = sectionTrees.IsContainer == false + ? sectionTrees.RoutePath : sectionTrees.Children[0].RoutePath; } - } + } return sectionModels; } diff --git a/src/Umbraco.Web/Trees/ApplicationTreeController.cs b/src/Umbraco.Web/Trees/ApplicationTreeController.cs index dcec993dfe..89a615f353 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeController.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeController.cs @@ -1,15 +1,12 @@ using System; using System.Globalization; using System.Linq; -using System.Management.Instrumentation; using System.Net; using System.Net.Http.Formatting; using System.Threading.Tasks; using System.Web.Http; -using System.Web.Mvc; using Umbraco.Core; using Umbraco.Core.Models; -using Umbraco.Core.Services; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; diff --git a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs index 13e4885efd..c312452a39 100644 --- a/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs +++ b/src/Umbraco.Web/Trees/ApplicationTreeExtensions.cs @@ -1,13 +1,9 @@ using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Management.Instrumentation; using System.Net.Http; using System.Net.Http.Formatting; -using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Web.Http; using System.Web.Http.Controllers; @@ -17,18 +13,16 @@ using Umbraco.Core; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; -using umbraco.BusinessLogic; using umbraco.cms.presentation.Trees; using Umbraco.Core.Services; using ApplicationTree = Umbraco.Core.Models.ApplicationTree; -using IAuthorizationFilter = System.Web.Http.Filters.IAuthorizationFilter; using UrlHelper = System.Web.Http.Routing.UrlHelper; namespace Umbraco.Web.Trees { internal static class ApplicationTreeExtensions { - + private static readonly ConcurrentDictionary TreeAttributeCache = new ConcurrentDictionary(); internal static TreeAttribute GetTreeAttribute(this Type treeControllerType) @@ -48,15 +42,15 @@ namespace Umbraco.Web.Trees //assign the properties of this object to those of the metadata attribute return treeAttributes[0]; }); - } + } internal static TreeAttribute GetTreeAttribute(this ApplicationTree tree) { return tree.GetRuntimeType().GetTreeAttribute(); - } + } internal static string GetRootNodeDisplayName(this TreeAttribute attribute, ILocalizedTextService textService) - { + { //if title is defined, return that if (string.IsNullOrEmpty(attribute.Title) == false) return attribute.Title; @@ -69,7 +63,7 @@ namespace Umbraco.Web.Trees //is returned to signal that a label was not found return "[" + attribute.Alias + "]"; - } + } internal static Attempt TryGetControllerTree(this ApplicationTree appTree) {