From 1a89fea81600b9bd35da624af5e58f6e4d258efe Mon Sep 17 00:00:00 2001 From: Warren Date: Fri, 24 Aug 2018 10:53:53 +0100 Subject: [PATCH] Adds a Logs Tree controller in the Developer section --- src/Umbraco.Core/Constants-Applications.cs | 2 + .../config/trees.Release.config | 1 + src/Umbraco.Web.UI/config/trees.config | 1 + src/Umbraco.Web/Trees/LogsTreeController.cs | 44 +++++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 5 files changed, 49 insertions(+) create mode 100644 src/Umbraco.Web/Trees/LogsTreeController.cs diff --git a/src/Umbraco.Core/Constants-Applications.cs b/src/Umbraco.Core/Constants-Applications.cs index 9a1883a065..a3dd878d67 100644 --- a/src/Umbraco.Core/Constants-Applications.cs +++ b/src/Umbraco.Core/Constants-Applications.cs @@ -145,6 +145,8 @@ public const string PartialViewMacros = "partialViewMacros"; + public const string Logs = "logs"; + //TODO: Fill in the rest! } } diff --git a/src/Umbraco.Web.UI/config/trees.Release.config b/src/Umbraco.Web.UI/config/trees.Release.config index c5a56be290..cd3335d8c4 100644 --- a/src/Umbraco.Web.UI/config/trees.Release.config +++ b/src/Umbraco.Web.UI/config/trees.Release.config @@ -22,6 +22,7 @@ + diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config index c445e92807..fe4075e096 100644 --- a/src/Umbraco.Web.UI/config/trees.config +++ b/src/Umbraco.Web.UI/config/trees.config @@ -22,6 +22,7 @@ + diff --git a/src/Umbraco.Web/Trees/LogsTreeController.cs b/src/Umbraco.Web/Trees/LogsTreeController.cs new file mode 100644 index 0000000000..e87d79da9f --- /dev/null +++ b/src/Umbraco.Web/Trees/LogsTreeController.cs @@ -0,0 +1,44 @@ +using System.Net.Http.Formatting; +using Umbraco.Web.Models.Trees; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi.Filters; +using Constants = Umbraco.Core.Constants; + +namespace Umbraco.Web.Trees +{ + [UmbracoTreeAuthorize(Constants.Trees.Logs)] + [Tree(Constants.Applications.Developer, Constants.Trees.Logs, null, sortOrder: 7)] + [PluginController("UmbracoTrees")] + [CoreTree] + public class LogsTreeController : TreeController + { + protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) + { + //We don't have any child nodes & only use the root node to load a custom UI + return new TreeNodeCollection(); + } + + protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) + { + //We don't have any menu item options (such as create/delete/reload) & only use the root node to load a custom UI + return null; + } + + /// + /// Helper method to create a root model for a tree + /// + /// + protected override TreeNode CreateRootNode(FormDataCollection queryStrings) + { + var root = base.CreateRootNode(queryStrings); + + //this will load in a custom UI instead of the dashboard for the root node + root.RoutePath = string.Format("{0}/{1}/{2}", Constants.Applications.Developer, Constants.Trees.Logs, "overview"); + root.Icon = "icon-bug"; + root.HasChildren = false; + root.MenuUrl = null; + + return root; + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 6d25493914..d9a1445da3 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -114,6 +114,7 @@ +