From bcca0528c0711b2a177fb021c1651ba5d7b2bfbb Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 21 Jun 2018 08:14:01 +0200 Subject: [PATCH] U4-11462 Error when using Simple Injector - 'The Tree controller is missing the Umbraco.Web.Trees.TreeAttribute attribute' --- build/NuSpecs/tools/trees.config.install.xdt | 2 +- .../config/trees.Release.config | 2 +- src/Umbraco.Web.UI/config/trees.config | 2 +- ...troller.cs => DictionaryBaseController.cs} | 23 +++++++++++++++++- .../Trees/SettingsDictionaryTreeController.cs | 24 ------------------- .../TranslationDictionaryTreeController.cs | 24 ------------------- src/Umbraco.Web/Umbraco.Web.csproj | 4 +--- 7 files changed, 26 insertions(+), 55 deletions(-) rename src/Umbraco.Web/Trees/{DictionaryTreeBaseController.cs => DictionaryBaseController.cs} (78%) delete mode 100644 src/Umbraco.Web/Trees/SettingsDictionaryTreeController.cs delete mode 100644 src/Umbraco.Web/Trees/TranslationDictionaryTreeController.cs diff --git a/build/NuSpecs/tools/trees.config.install.xdt b/build/NuSpecs/tools/trees.config.install.xdt index 8cc3e5435f..59360041e1 100644 --- a/build/NuSpecs/tools/trees.config.install.xdt +++ b/build/NuSpecs/tools/trees.config.install.xdt @@ -46,7 +46,7 @@ - - + diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config index 0c51e39649..14f8fd9dcf 100644 --- a/src/Umbraco.Web.UI/config/trees.config +++ b/src/Umbraco.Web.UI/config/trees.config @@ -14,7 +14,7 @@ - + diff --git a/src/Umbraco.Web/Trees/DictionaryTreeBaseController.cs b/src/Umbraco.Web/Trees/DictionaryBaseController.cs similarity index 78% rename from src/Umbraco.Web/Trees/DictionaryTreeBaseController.cs rename to src/Umbraco.Web/Trees/DictionaryBaseController.cs index d56f0a1b13..2046bdbf05 100644 --- a/src/Umbraco.Web/Trees/DictionaryTreeBaseController.cs +++ b/src/Umbraco.Web/Trees/DictionaryBaseController.cs @@ -5,11 +5,32 @@ using umbraco.BusinessLogic.Actions; using Umbraco.Core; using Umbraco.Core.Services; using Umbraco.Web.Models.Trees; +using Umbraco.Web.WebApi.Filters; namespace Umbraco.Web.Trees { - public class DictionaryTreeBaseController : TreeController + [UmbracoTreeAuthorize(Constants.Trees.Dictionary)] + [Mvc.PluginController("UmbracoTrees")] + [CoreTree] + [Tree(Constants.Applications.Settings, Constants.Trees.Dictionary, null, sortOrder: 3)] + public class DictionaryTreeController : TreeController { + protected override TreeNode CreateRootNode(FormDataCollection queryStrings) + { + var root = base.CreateRootNode(queryStrings); + + // the default section is settings, falling back to this if we can't + // figure out where we are from the querystring parameters + var section = Constants.Applications.Settings; + if (queryStrings["application"] != null) + section = queryStrings["application"]; + + // this will load in a custom UI instead of the dashboard for the root node + root.RoutePath = $"{section}/{Constants.Trees.Dictionary}/list"; + + return root; + } + /// /// The method called to render the contents of the tree structure /// diff --git a/src/Umbraco.Web/Trees/SettingsDictionaryTreeController.cs b/src/Umbraco.Web/Trees/SettingsDictionaryTreeController.cs deleted file mode 100644 index edde759d49..0000000000 --- a/src/Umbraco.Web/Trees/SettingsDictionaryTreeController.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Net.Http.Formatting; -using Umbraco.Core; -using Umbraco.Web.Models.Trees; -using Umbraco.Web.WebApi.Filters; - -namespace Umbraco.Web.Trees -{ - [UmbracoTreeAuthorize(Constants.Trees.Dictionary)] - [Tree(Constants.Applications.Settings, Constants.Trees.Dictionary, null, sortOrder: 3)] - [Mvc.PluginController("UmbracoTrees")] - [CoreTree] - public class SettingsDictionaryTreeController : DictionaryTreeBaseController - { - 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 = $"{Constants.Applications.Settings}/{Constants.Trees.Dictionary}/list"; - - return root; - } - } -} diff --git a/src/Umbraco.Web/Trees/TranslationDictionaryTreeController.cs b/src/Umbraco.Web/Trees/TranslationDictionaryTreeController.cs deleted file mode 100644 index 11658994a3..0000000000 --- a/src/Umbraco.Web/Trees/TranslationDictionaryTreeController.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Net.Http.Formatting; -using Umbraco.Core; -using Umbraco.Web.Models.Trees; -using Umbraco.Web.WebApi.Filters; - -namespace Umbraco.Web.Trees -{ - [UmbracoTreeAuthorize(Constants.Trees.Dictionary)] - [Tree(Constants.Applications.Translation, Constants.Trees.Dictionary, null, sortOrder: 3)] - [Mvc.PluginController("UmbracoTrees")] - [CoreTree] - public class TranslationDictionaryTreeController : DictionaryTreeBaseController - { - 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 = $"{Constants.Applications.Translation}/{Constants.Trees.Dictionary}/list"; - - return root; - } - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index f25e553f35..c9ad24d4a1 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -528,9 +528,7 @@ - - - +