From 0160f141f4104c1048cf96f498b2dc1cc4a20e06 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 17 Jan 2019 17:04:53 +1100 Subject: [PATCH] cleanup and explicitly registering sections --- .../Services/SectionServiceTests.cs | 2 +- .../TreesAndSections/ApplicationTreeTest.cs | 397 ----------------- .../ResourceFiles.Designer.cs | 91 ---- .../TreesAndSections/ResourceFiles.resx | 127 ------ .../TreesAndSections/SectionTests.cs | 252 ----------- .../TreesAndSections/applications.config | 16 - .../TreesAndSections/trees.config | 8 - src/Umbraco.Tests/Umbraco.Tests.csproj | 13 - .../Cache/ApplicationTreeCacheRefresher.cs | 46 -- .../Cache/DistributedCacheBinder_Handlers.cs | 47 -- .../Cache/DistributedCacheExtensions.cs | 19 - .../ContentEditing/IBackOfficeSection.cs | 15 - .../Models/Mapping/SectionMapperProfile.cs | 1 + .../Models/Trees/ApplicationDefinitions.cs | 77 ---- .../Models/Trees/IBackOfficeSection.cs | 12 + .../{SectionRootNode.cs => TreeRootNode.cs} | 0 src/Umbraco.Web/Runtime/WebRuntimeComposer.cs | 11 +- src/Umbraco.Web/Services/ISectionService.cs | 1 + src/Umbraco.Web/Services/ITreeService.cs | 10 +- src/Umbraco.Web/Services/SectionService.cs | 253 +---------- src/Umbraco.Web/Services/TreeService.cs | 410 +----------------- .../Trees/BackOfficeSectionCollection.cs | 8 +- .../BackOfficeSectionCollectionBuilder.cs | 10 + .../Trees/ContentBackOfficeSection.cs | 15 + src/Umbraco.Web/Trees/ITree.cs | 1 + .../Trees/MediaBackOfficeSection.cs | 15 + .../Trees/MembersBackOfficeSection.cs | 15 + .../Trees/PackagesBackOfficeSection.cs | 15 + .../Trees/SettingsBackOfficeSection.cs | 15 + .../Trees/TranslationBackOfficeSection.cs | 15 + src/Umbraco.Web/Trees/TreeCollection.cs | 27 -- .../Trees/TreeCollectionBuilder.cs | 18 + .../Trees/UsersBackOfficeSection.cs | 15 + src/Umbraco.Web/Umbraco.Web.csproj | 15 +- 34 files changed, 183 insertions(+), 1809 deletions(-) delete mode 100644 src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs delete mode 100644 src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs delete mode 100644 src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx delete mode 100644 src/Umbraco.Tests/TreesAndSections/SectionTests.cs delete mode 100644 src/Umbraco.Tests/TreesAndSections/applications.config delete mode 100644 src/Umbraco.Tests/TreesAndSections/trees.config delete mode 100644 src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs delete mode 100644 src/Umbraco.Web/Models/ContentEditing/IBackOfficeSection.cs delete mode 100644 src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs create mode 100644 src/Umbraco.Web/Models/Trees/IBackOfficeSection.cs rename src/Umbraco.Web/Models/Trees/{SectionRootNode.cs => TreeRootNode.cs} (100%) create mode 100644 src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs create mode 100644 src/Umbraco.Web/Trees/ContentBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/MediaBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/MembersBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs create mode 100644 src/Umbraco.Web/Trees/TreeCollectionBuilder.cs create mode 100644 src/Umbraco.Web/Trees/UsersBackOfficeSection.cs diff --git a/src/Umbraco.Tests/Services/SectionServiceTests.cs b/src/Umbraco.Tests/Services/SectionServiceTests.cs index 206c99ffbf..9211755251 100644 --- a/src/Umbraco.Tests/Services/SectionServiceTests.cs +++ b/src/Umbraco.Tests/Services/SectionServiceTests.cs @@ -16,7 +16,7 @@ namespace Umbraco.Tests.Services public class SectionServiceTests : TestWithSomeContentBase { //fixme - private ISectionService SectionService => new SectionService(ServiceContext.UserService, null, null); + private ISectionService SectionService => new SectionService(ServiceContext.UserService, null); [Test] diff --git a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs b/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs deleted file mode 100644 index 95d90f1463..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs +++ /dev/null @@ -1,397 +0,0 @@ -//using System.IO; -//using NUnit.Framework; -//using Umbraco.Core.Services; -//using Umbraco.Tests.TestHelpers; -//using System; -//using System.Linq; -//using System.Threading; -//using Umbraco.Tests.Testing; -//using Umbraco.Web.Services; -//using Current = Umbraco.Web.Composing.Current; - -//namespace Umbraco.Tests.TreesAndSections -//{ - - -// /// -// ///This is a test class for ApplicationTreeTest and is intended -// ///to contain all ApplicationTreeTest Unit Tests -// /// -// [TestFixture] -// [Apartment(ApartmentState.STA)] -// [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] -// public class ApplicationTreeTest : TestWithDatabaseBase -// { -// public override void SetUp() -// { -// base.SetUp(); - -// var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config"); -// var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config"); -// Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")); -// using (var writer = File.CreateText(treesConfig)) -// { -// writer.Write(ResourceFiles.trees); -// } -// using (var writer = File.CreateText(appConfig)) -// { -// writer.Write(ResourceFiles.applications); -// } - -// //ApplicationTreeService.TreeConfigFilePath = treesConfig; -// SectionService.AppConfigFilePath = appConfig; -// } - -// public override void TearDown() -// { -// base.TearDown(); - -// if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"))) -// { -// Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true); -// } -// //ApplicationTreeService.TreeConfigFilePath = null; -// SectionService.AppConfigFilePath = null; -// } - -// ///// -// ///// Creates a new app tree linked to an application, then delete the application and make sure the tree is gone as well -// ///// -// //[Test()] -// //public void ApplicationTree_Make_New_Then_Delete_App() -// //{ -// // //create new app -// // var appName = Guid.NewGuid().ToString("N"); -// // var treeName = Guid.NewGuid().ToString("N"); -// // Current.Services.SectionService.MakeNew(appName, appName, "icon.jpg"); - -// // //check if it exists -// // var app = Current.Services.SectionService.GetByAlias(appName); -// // Assert.IsNotNull(app); - -// // //create the new app tree assigned to the new app -// // Current.Services.ApplicationTreeService.MakeNew(false, 0, app.Alias, treeName, treeName, "icon.jpg", "icon.jpg", "Umbraco.Web.Trees.ContentTreeController, Umbraco.Web"); -// // var tree = Current.Services.ApplicationTreeService.GetByAlias(treeName); -// // Assert.IsNotNull(tree); - -// // //now delete the app -// // Current.Services.SectionService.DeleteSection(app); - -// // //check that the tree is gone -// // Assert.AreEqual(0, Current.Services.ApplicationTreeService.GetApplicationTrees(treeName).Count()); -// //} - - -// #region Tests to write -// ///// -// /////A test for ApplicationTree Constructor -// ///// -// //[TestMethod()] -// //public void ApplicationTreeConstructorTest() -// //{ -// // bool silent = false; // TODO: Initialize to an appropriate value -// // bool initialize = false; // TODO: Initialize to an appropriate value -// // byte sortOrder = 0; // TODO: Initialize to an appropriate value -// // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value -// // string alias = string.Empty; // TODO: Initialize to an appropriate value -// // string title = string.Empty; // TODO: Initialize to an appropriate value -// // string iconClosed = string.Empty; // TODO: Initialize to an appropriate value -// // string iconOpened = string.Empty; // TODO: Initialize to an appropriate value -// // string assemblyName = string.Empty; // TODO: Initialize to an appropriate value -// // string type = string.Empty; // TODO: Initialize to an appropriate value -// // string action = string.Empty; // TODO: Initialize to an appropriate value -// // ApplicationTree target = new ApplicationTree(silent, initialize, sortOrder, applicationAlias, alias, title, iconClosed, iconOpened, assemblyName, type, action); -// // Assert.Inconclusive("TODO: Implement code to verify target"); -// //} - -// ///// -// /////A test for ApplicationTree Constructor -// ///// -// //[TestMethod()] -// //public void ApplicationTreeConstructorTest1() -// //{ -// // ApplicationTree target = new ApplicationTree(); -// // Assert.Inconclusive("TODO: Implement code to verify target"); -// //} - -// ///// -// /////A test for Delete -// ///// -// //[TestMethod()] -// //public void DeleteTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // target.Delete(); -// // Assert.Inconclusive("A method that does not return a value cannot be verified."); -// //} - - -// ///// -// /////A test for Save -// ///// -// //[TestMethod()] -// //public void SaveTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // target.Save(); -// // Assert.Inconclusive("A method that does not return a value cannot be verified."); -// //} - -// ///// -// /////A test for getAll -// ///// -// //[TestMethod()] -// //public void getAllTest() -// //{ -// // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value -// // ApplicationTree[] actual; -// // actual = ApplicationTree.getAll(); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for getApplicationTree -// ///// -// //[TestMethod()] -// //public void getApplicationTreeTest() -// //{ -// // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value -// // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value -// // ApplicationTree[] actual; -// // actual = ApplicationTree.getApplicationTree(applicationAlias); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for getApplicationTree -// ///// -// //[TestMethod()] -// //public void getApplicationTreeTest1() -// //{ -// // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value -// // bool onlyInitializedApplications = false; // TODO: Initialize to an appropriate value -// // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value -// // ApplicationTree[] actual; -// // actual = ApplicationTree.getApplicationTree(applicationAlias, onlyInitializedApplications); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for getByAlias -// ///// -// //[TestMethod()] -// //public void getByAliasTest() -// //{ -// // string treeAlias = string.Empty; // TODO: Initialize to an appropriate value -// // ApplicationTree expected = null; // TODO: Initialize to an appropriate value -// // ApplicationTree actual; -// // actual = ApplicationTree.getByAlias(treeAlias); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Action -// ///// -// //[TestMethod()] -// //public void ActionTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.Action = expected; -// // actual = target.Action; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Alias -// ///// -// //[TestMethod()] -// //public void AliasTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string actual; -// // actual = target.Alias; -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for ApplicationAlias -// ///// -// //[TestMethod()] -// //public void ApplicationAliasTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string actual; -// // actual = target.ApplicationAlias; -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for AssemblyName -// ///// -// //[TestMethod()] -// //public void AssemblyNameTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.AssemblyName = expected; -// // actual = target.AssemblyName; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for IconClosed -// ///// -// //[TestMethod()] -// //public void IconClosedTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.IconClosed = expected; -// // actual = target.IconClosed; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for IconOpened -// ///// -// //[TestMethod()] -// //public void IconOpenedTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.IconOpened = expected; -// // actual = target.IconOpened; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Initialize -// ///// -// //[TestMethod()] -// //public void InitializeTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // bool expected = false; // TODO: Initialize to an appropriate value -// // bool actual; -// // target.Initialize = expected; -// // actual = target.Initialize; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Silent -// ///// -// //[TestMethod()] -// //public void SilentTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // bool expected = false; // TODO: Initialize to an appropriate value -// // bool actual; -// // target.Silent = expected; -// // actual = target.Silent; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for SortOrder -// ///// -// //[TestMethod()] -// //public void SortOrderTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // byte expected = 0; // TODO: Initialize to an appropriate value -// // byte actual; -// // target.SortOrder = expected; -// // actual = target.SortOrder; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for SqlHelper -// ///// -// //[TestMethod()] -// //public void SqlHelperTest() -// //{ -// // ISqlHelper actual; -// // actual = ApplicationTree.SqlHelper; -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Title -// ///// -// //[TestMethod()] -// //public void TitleTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.Title = expected; -// // actual = target.Title; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for Type -// ///// -// //[TestMethod()] -// //public void TypeTest() -// //{ -// // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.Type = expected; -// // actual = target.Type; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} -// #endregion - -// #region Additional test attributes -// // -// //You can use the following additional attributes as you write your tests: -// // -// //Use ClassInitialize to run code before running the first test in the class -// //[ClassInitialize()] -// //public static void MyClassInitialize(TestContext testContext) -// //{ -// //} -// // -// //Use ClassCleanup to run code after all tests in a class have run -// //[ClassCleanup()] -// //public static void MyClassCleanup() -// //{ -// //} -// // -// //Use TestInitialize to run code before running each test -// //[TestInitialize()] -// //public void MyTestInitialize() -// //{ -// //} -// // -// //Use TestCleanup to run code after each test has run -// //[TestCleanup()] -// //public void MyTestCleanup() -// //{ -// //} -// // -// #endregion -// } -//} diff --git a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs b/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs deleted file mode 100644 index 02bc84649e..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs +++ /dev/null @@ -1,91 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Tests.TreesAndSections { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class ResourceFiles { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ResourceFiles() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.TreesAndSections.ResourceFiles", typeof(ResourceFiles).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?> - ///<applications> - /// <add alias="content" name="content" icon="file" sortOrder="0" /> - /// <add alias="0b486ac9c0f1456996192c6ed1f03e57" name="0b486ac9c0f1456996192c6ed1f03e57" icon="icon.jpg" sortOrder="1" /> - /// <add alias="1ffbc301744c4e75ae3054d741954c7b" name="1ffbc301744c4e75ae3054d741954c7b" icon="icon.jpg" sortOrder="2" /> - /// <add alias="1838c3e1591f4008bbafe59a06a00a31" name="1838c3e1591f4008bbafe59a06a00a31" icon="icon.jpg" sortOrder="3" /> - /// <add alias="e5badae2 [rest of string was truncated]";. - /// - internal static string applications { - get { - return ResourceManager.GetString("applications", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?> - ///<trees> - /// <add initialize="false" sortOrder="0" alias="1838c3e1591f4008bbafe59a06a00a31" application="1838c3e1591f4008bbafe59a06a00a31" title="1838c3e1591f4008bbafe59a06a00a31" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" /> - /// <add initialize="false" sortOrder="0" alias="e5badae2fc5e4cd7acb3700320e33b8b" application="e5badae2fc5e4cd7acb3700320e33b8b" title="e5badae2fc5e4cd7acb3700320e33b8b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" /> - /// [rest of string was truncated]";. - /// - internal static string trees { - get { - return ResourceManager.GetString("trees", resourceCulture); - } - } - } -} diff --git a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx b/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx deleted file mode 100644 index fac58dc842..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - applications.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - - trees.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - \ No newline at end of file diff --git a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs b/src/Umbraco.Tests/TreesAndSections/SectionTests.cs deleted file mode 100644 index 83de6c4479..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs +++ /dev/null @@ -1,252 +0,0 @@ -//using System.IO; -//using NUnit.Framework; -//using Umbraco.Core.Services; -//using Umbraco.Tests.TestHelpers; -//using System; -//using Umbraco.Core.Composing; -//using Umbraco.Tests.Testing; -//using Umbraco.Web.Services; - -//namespace Umbraco.Tests.TreesAndSections -//{ -// /// -// ///This is a test class for ApplicationTest and is intended -// ///to contain all ApplicationTest Unit Tests -// /// -// [TestFixture] -// [UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)] -// public class SectionTests : TestWithDatabaseBase -// { -// protected override void Compose() -// { -// base.Compose(); -// Composition.RegisterUnique(); -// } - -// public override void SetUp() -// { -// base.SetUp(); - -// var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config"); -// var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config"); -// Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")); -// using (var writer = File.CreateText(treesConfig)) -// { -// writer.Write(ResourceFiles.trees); -// } -// using (var writer = File.CreateText(appConfig)) -// { -// writer.Write(ResourceFiles.applications); -// } - -// ApplicationTreeService.TreeConfigFilePath = treesConfig; -// SectionService.AppConfigFilePath = appConfig; -// } - -// public override void TearDown() -// { -// base.TearDown(); - -// if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"))) -// { -// Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true); -// } -// ApplicationTreeService.TreeConfigFilePath = null; -// SectionService.AppConfigFilePath = null; -// } - -// ///// -// ///// Create a new application and delete it -// ///// -// //[Test()] -// //public void Application_Make_New() -// //{ -// // var name = Guid.NewGuid().ToString("N"); -// // ServiceContext.SectionService.MakeNew(name, name, "icon.jpg"); - -// // //check if it exists -// // var app = ServiceContext.SectionService.GetByAlias(name); -// // Assert.IsNotNull(app); - -// // //now remove it -// // ServiceContext.SectionService.DeleteSection(app); -// // Assert.IsNull(ServiceContext.SectionService.GetByAlias(name)); -// //} - -// #region Tests to write - - -// ///// -// /////A test for Application Constructor -// ///// -// //[TestMethod()] -// //public void ApplicationConstructorTest() -// //{ -// // string name = string.Empty; // TODO: Initialize to an appropriate value -// // string alias = string.Empty; // TODO: Initialize to an appropriate value -// // string icon = string.Empty; // TODO: Initialize to an appropriate value -// // Application target = new Application(name, alias, icon); -// // Assert.Inconclusive("TODO: Implement code to verify target"); -// //} - -// ///// -// /////A test for Application Constructor -// ///// -// //[TestMethod()] -// //public void ApplicationConstructorTest1() -// //{ -// // Application target = new Application(); -// // Assert.Inconclusive("TODO: Implement code to verify target"); -// //} - -// ///// -// /////A test for Delete -// ///// -// //[TestMethod()] -// //public void DeleteTest() -// //{ -// // Application target = new Application(); // TODO: Initialize to an appropriate value -// // target.Delete(); -// // Assert.Inconclusive("A method that does not return a value cannot be verified."); -// //} - - - -// ///// -// /////A test for MakeNew -// ///// -// //[TestMethod()] -// //public void MakeNewTest1() -// //{ -// // string name = string.Empty; // TODO: Initialize to an appropriate value -// // string alias = string.Empty; // TODO: Initialize to an appropriate value -// // string icon = string.Empty; // TODO: Initialize to an appropriate value -// // Application.MakeNew(name, alias, icon); -// // Assert.Inconclusive("A method that does not return a value cannot be verified."); -// //} - -// ///// -// /////A test for RegisterIApplications -// ///// -// //[TestMethod()] -// //public void RegisterIApplicationsTest() -// //{ -// // Application.RegisterIApplications(); -// // Assert.Inconclusive("A method that does not return a value cannot be verified."); -// //} - -// ///// -// /////A test for getAll -// ///// -// //[TestMethod()] -// //public void getAllTest() -// //{ -// // List expected = null; // TODO: Initialize to an appropriate value -// // List actual; -// // actual = Application.getAll(); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for getByAlias -// ///// -// //[TestMethod()] -// //public void getByAliasTest() -// //{ -// // string appAlias = string.Empty; // TODO: Initialize to an appropriate value -// // Application expected = null; // TODO: Initialize to an appropriate value -// // Application actual; -// // actual = Application.getByAlias(appAlias); -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for SqlHelper -// ///// -// //[TestMethod()] -// //public void SqlHelperTest() -// //{ -// // ISqlHelper actual; -// // actual = Application.SqlHelper; -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for alias -// ///// -// //[TestMethod()] -// //public void aliasTest() -// //{ -// // Application target = new Application(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.alias = expected; -// // actual = target.alias; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for icon -// ///// -// //[TestMethod()] -// //public void iconTest() -// //{ -// // Application target = new Application(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.icon = expected; -// // actual = target.icon; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} - -// ///// -// /////A test for name -// ///// -// //[TestMethod()] -// //public void nameTest() -// //{ -// // Application target = new Application(); // TODO: Initialize to an appropriate value -// // string expected = string.Empty; // TODO: Initialize to an appropriate value -// // string actual; -// // target.name = expected; -// // actual = target.name; -// // Assert.AreEqual(expected, actual); -// // Assert.Inconclusive("Verify the correctness of this test method."); -// //} -// #endregion - -// #region Additional test attributes -// // -// //You can use the following additional attributes as you write your tests: -// // -// //Use ClassInitialize to run code before running the first test in the class -// //[ClassInitialize()] -// //public static void MyClassInitialize(TestContext testContext) -// //{ -// //} -// // -// //Use ClassCleanup to run code after all tests in a class have run -// //[ClassCleanup()] -// //public static void MyClassCleanup() -// //{ -// //} -// // -// //Use TestInitialize to run code before running each test -// //[TestInitialize()] -// //public void MyTestInitialize() -// //{ -// //} -// // -// //Use TestCleanup to run code after each test has run -// //[TestCleanup()] -// //public void MyTestCleanup() -// //{ -// //} -// // -// #endregion -// } -//} diff --git a/src/Umbraco.Tests/TreesAndSections/applications.config b/src/Umbraco.Tests/TreesAndSections/applications.config deleted file mode 100644 index aadd1c5407..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/applications.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Tests/TreesAndSections/trees.config b/src/Umbraco.Tests/TreesAndSections/trees.config deleted file mode 100644 index d21fea28a9..0000000000 --- a/src/Umbraco.Tests/TreesAndSections/trees.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index e49ba250fa..408b0f96ca 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -423,13 +423,6 @@ - - True - True - ResourceFiles.resx - - - @@ -525,8 +518,6 @@ Designer Always - - Designer @@ -561,10 +552,6 @@ ImportResources.Designer.cs Designer - - ResXFileCodeGenerator - ResourceFiles.Designer.cs - ResXFileCodeGenerator TestFiles.Designer.cs diff --git a/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs b/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs deleted file mode 100644 index 4d6740a0b1..0000000000 --- a/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs +++ /dev/null @@ -1,46 +0,0 @@ -//using System; -//using Umbraco.Core.Cache; - -//namespace Umbraco.Web.Cache -//{ -// public sealed class ApplicationTreeCacheRefresher : CacheRefresherBase -// { -// public ApplicationTreeCacheRefresher(CacheHelper cacheHelper) -// : base(cacheHelper) -// { } - -// #region Define - -// protected override ApplicationTreeCacheRefresher This => this; - -// public static readonly Guid UniqueId = Guid.Parse("0AC6C028-9860-4EA4-958D-14D39F45886E"); - -// public override Guid RefresherUniqueId => UniqueId; - -// public override string Name => "Application Tree Cache Refresher"; - -// #endregion - -// #region Refresher - -// public override void RefreshAll() -// { -// CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey); -// base.RefreshAll(); -// } - -// public override void Refresh(int id) -// { -// Remove(id); -// base.Refresh(id); -// } - -// public override void Remove(int id) -// { -// CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey); -// base.Remove(id); -// } - -// #endregion -// } -//} diff --git a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs index 421eb546a4..3a3eb1b8fb 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs @@ -46,20 +46,6 @@ namespace Umbraco.Web.Cache _logger.Info("Initializing Umbraco internal event handlers for cache refreshing."); - //// bind to application tree events - //Bind(() => ApplicationTreeService.Deleted += ApplicationTreeService_Deleted, - // () => ApplicationTreeService.Deleted -= ApplicationTreeService_Deleted); - //Bind(() => ApplicationTreeService.Updated += ApplicationTreeService_Updated, - // () => ApplicationTreeService.Updated -= ApplicationTreeService_Updated); - //Bind(() => ApplicationTreeService.New += ApplicationTreeService_New, - // () => ApplicationTreeService.New -= ApplicationTreeService_New); - - //// bind to application events - //Bind(() => SectionService.Deleted += SectionService_Deleted, - // () => SectionService.Deleted -= SectionService_Deleted); - //Bind(() => SectionService.New += SectionService_New, - // () => SectionService.New -= SectionService_New); - // bind to user and user group events Bind(() => UserService.SavedUserGroup += UserService_SavedUserGroup, () => UserService.SavedUserGroup -= UserService_SavedUserGroup); @@ -231,39 +217,6 @@ namespace Umbraco.Web.Cache #endregion - //#region ApplicationTreeService - - //private void ApplicationTreeService_New(ApplicationTree sender, EventArgs e) - //{ - // _distributedCache.RefreshAllApplicationTreeCache(); - //} - - //private void ApplicationTreeService_Updated(ApplicationTree sender, EventArgs e) - //{ - // _distributedCache.RefreshAllApplicationTreeCache(); - //} - - //private void ApplicationTreeService_Deleted(ApplicationTree sender, EventArgs e) - //{ - // _distributedCache.RefreshAllApplicationTreeCache(); - //} - - //#endregion - - //#region Application event handlers - - //private void SectionService_New(ISectionService sender, EventArgs e) - //{ - // _distributedCache.RefreshAllApplicationCache(); - //} - - //private void SectionService_Deleted(ISectionService sender, EventArgs e) - //{ - // _distributedCache.RefreshAllApplicationCache(); - //} - - //#endregion - #region LocalizationService / Dictionary private void LocalizationService_SavedDictionaryItem(ILocalizationService sender, SaveEventArgs e) diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index aab0f9b157..80c49e279c 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -18,24 +18,6 @@ namespace Umbraco.Web.Cache #endregion - //#region ApplicationTreeCache - - //public static void RefreshAllApplicationTreeCache(this DistributedCache dc) - //{ - // dc.RefreshAll(ApplicationTreeCacheRefresher.UniqueId); - //} - - //#endregion - - //#region ApplicationCache - - //public static void RefreshAllApplicationCache(this DistributedCache dc) - //{ - // dc.RefreshAll(ApplicationCacheRefresher.UniqueId); - //} - - //#endregion - #region User cache public static void RemoveUserCache(this DistributedCache dc, int userId) @@ -74,7 +56,6 @@ namespace Umbraco.Web.Cache #endregion - #region TemplateCache public static void RefreshTemplateCache(this DistributedCache dc, int templateId) diff --git a/src/Umbraco.Web/Models/ContentEditing/IBackOfficeSection.cs b/src/Umbraco.Web/Models/ContentEditing/IBackOfficeSection.cs deleted file mode 100644 index f27941035a..0000000000 --- a/src/Umbraco.Web/Models/ContentEditing/IBackOfficeSection.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Umbraco.Core.Composing; - -namespace Umbraco.Web.Models.ContentEditing -{ - - /// - /// Defines a back office section - /// - public interface IBackOfficeSection : IDiscoverable - { - string Alias { get; } - string Name { get; } - int SortOrder { get; } - } -} diff --git a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs index 683fce36e8..5aa99e4652 100644 --- a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs @@ -3,6 +3,7 @@ using AutoMapper; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Models.Mapping { diff --git a/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs b/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs deleted file mode 100644 index ba48c9e240..0000000000 --- a/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs +++ /dev/null @@ -1,77 +0,0 @@ -using Umbraco.Core; -using Umbraco.Core.Models; -using Umbraco.Core.Models.ContentEditing; -using Umbraco.Web.Models.ContentEditing; - -namespace Umbraco.Web.Models.Trees -{ - /// - /// Defines the back office content section - /// - public class ContentBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Content; - public string Name => "Content"; - public int SortOrder => 0; - } - - /// - /// Defines the back office media section - /// - public class MediaBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Media; - public string Name => "Media"; - public int SortOrder => 1; - } - - /// - /// Defines the back office settings section - /// - public class SettingsBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Settings; - public string Name => "Settings"; - public int SortOrder => 2; - } - - /// - /// Defines the back office packages section - /// - public class PackagesBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Packages; - public string Name => "Packages"; - public int SortOrder => 3; - } - - /// - /// Defines the back office users section - /// - public class UsersBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Users; - public string Name => "Users"; - public int SortOrder => 4; - } - - /// - /// Defines the back office members section - /// - public class MembersBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Members; - public string Name => "Members"; - public int SortOrder => 5; - } - - /// - /// Defines the back office translation section - /// - public class TranslationBackOfficeSectionDefinition : IBackOfficeSection - { - public string Alias => Constants.Applications.Translation; - public string Name => "Translation"; - public int SortOrder => 6; - } -} diff --git a/src/Umbraco.Web/Models/Trees/IBackOfficeSection.cs b/src/Umbraco.Web/Models/Trees/IBackOfficeSection.cs new file mode 100644 index 0000000000..0cc505fb19 --- /dev/null +++ b/src/Umbraco.Web/Models/Trees/IBackOfficeSection.cs @@ -0,0 +1,12 @@ +namespace Umbraco.Web.Models.Trees +{ + + /// + /// Defines a back office section + /// + public interface IBackOfficeSection + { + string Alias { get; } + string Name { get; } + } +} diff --git a/src/Umbraco.Web/Models/Trees/SectionRootNode.cs b/src/Umbraco.Web/Models/Trees/TreeRootNode.cs similarity index 100% rename from src/Umbraco.Web/Models/Trees/SectionRootNode.cs rename to src/Umbraco.Web/Models/Trees/TreeRootNode.cs diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs index 047d080a88..134ed7b1d0 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs @@ -25,6 +25,7 @@ using Umbraco.Web.Features; using Umbraco.Web.HealthCheck; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.PublishedContent; +using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; @@ -195,9 +196,15 @@ namespace Umbraco.Web.Runtime .Append() .Append(); - // register back office sections + // register back office sections in the order we want them rendered composition.WithCollectionBuilder() - .Add(() => composition.TypeLoader.GetTypes()); + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append(); // register back office trees foreach (var treeControllerType in umbracoApiControllerTypes) diff --git a/src/Umbraco.Web/Services/ISectionService.cs b/src/Umbraco.Web/Services/ISectionService.cs index c325020cf1..f0a16dc965 100644 --- a/src/Umbraco.Web/Services/ISectionService.cs +++ b/src/Umbraco.Web/Services/ISectionService.cs @@ -2,6 +2,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Services { diff --git a/src/Umbraco.Web/Services/ITreeService.cs b/src/Umbraco.Web/Services/ITreeService.cs index ce734cc5e4..17998ae1a7 100644 --- a/src/Umbraco.Web/Services/ITreeService.cs +++ b/src/Umbraco.Web/Services/ITreeService.cs @@ -29,15 +29,7 @@ namespace Umbraco.Web.Services /// The application alias. /// Returns a ApplicationTree Array IEnumerable GetApplicationTrees(string applicationAlias); - - ///// - ///// Gets the application tree for the applcation with the specified alias - ///// - ///// The application alias. - ///// - ///// Returns a ApplicationTree Array - //IEnumerable GetApplicationTrees(string applicationAlias, bool onlyInitialized); - + /// /// Gets the grouped application trees for the application with the specified alias /// diff --git a/src/Umbraco.Web/Services/SectionService.cs b/src/Umbraco.Web/Services/SectionService.cs index bb154976f0..e6af27534c 100644 --- a/src/Umbraco.Web/Services/SectionService.cs +++ b/src/Umbraco.Web/Services/SectionService.cs @@ -25,270 +25,31 @@ namespace Umbraco.Web.Services private readonly IUserService _userService; private readonly BackOfficeSectionCollection _sectionCollection; - private readonly Lazy> _allAvailableSections; - //private readonly IApplicationTreeService _applicationTreeService; - //private readonly IScopeProvider _scopeProvider; - private readonly CacheHelper _cache; - //internal const string AppConfigFileName = "applications.config"; - //private static string _appConfig; - //private static readonly object Locker = new object(); - public SectionService( IUserService userService, - BackOfficeSectionCollection sectionCollection, - CacheHelper cache) + BackOfficeSectionCollection sectionCollection) { - //_applicationTreeService = applicationTreeService ?? throw new ArgumentNullException(nameof(applicationTreeService)); - _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _userService = userService; _sectionCollection = sectionCollection; - //_scopeProvider = scopeProvider; - //_allAvailableSections = new Lazy>(() => new LazyEnumerableSections()); } - - - ///// - ///// gets/sets the application.config file path - ///// - ///// - ///// The setter is generally only going to be used in unit tests, otherwise it will attempt to resolve it using the IOHelper.MapPath - ///// - //internal static string AppConfigFilePath - //{ - // get - // { - // if (string.IsNullOrWhiteSpace(_appConfig)) - // { - // _appConfig = IOHelper.MapPath(SystemDirectories.Config + "/" + AppConfigFileName); - // } - // return _appConfig; - // } - // set => _appConfig = value; - //} - + /// /// The cache storage for all applications /// - public IEnumerable GetSections() - { - return _sectionCollection; - } + public IEnumerable GetSections() => _sectionCollection; - //internal void LoadXml(Func callback, bool saveAfterCallbackIfChanged) - //{ - // lock (Locker) - // { - // var doc = File.Exists(AppConfigFilePath) - // ? XDocument.Load(AppConfigFilePath) - // : XDocument.Parse(""); - - // if (doc.Root != null) - // { - // var changed = callback.Invoke(doc); - - // if (saveAfterCallbackIfChanged && changed) - // { - // //ensure the folder is created! - // Directory.CreateDirectory(Path.GetDirectoryName(AppConfigFilePath)); - - // doc.Save(AppConfigFilePath); - - // //remove the cache so it gets re-read ... SD: I'm leaving this here even though it - // // is taken care of by events as well, I think unit tests may rely on it being cleared here. - // _cache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey); - // } - // } - // } - //} - - /// - /// Get the user's allowed sections - /// - /// - /// + /// public IEnumerable GetAllowedSections(int userId) { - var user = _userService.GetUserById(userId); if (user == null) - { throw new InvalidOperationException("No user found with id " + userId); - } return GetSections().Where(x => user.AllowedSections.Contains(x.Alias)); } - /// - /// Gets the application by its alias. - /// - /// The application alias. - /// - public IBackOfficeSection GetByAlias(string appAlias) - { - return GetSections().FirstOrDefault(t => t.Alias == appAlias); - } - - ///// - ///// Creates a new applcation if no application with the specified alias is found. - ///// - ///// The application name. - ///// The application alias. - ///// The application icon, which has to be located in umbraco/images/tray folder. - //public void MakeNew(string name, string alias, string icon) - //{ - // var sections = GetSections(); - // var nextSortOrder = sections.Any() ? sections.Max(x => x.SortOrder) + 1 : 1; - // MakeNew(name, alias, icon, nextSortOrder); - //} - - ///// - ///// Makes the new. - ///// - ///// The name. - ///// The alias. - ///// The icon. - ///// The sort order. - //public void MakeNew(string name, string alias, string icon, int sortOrder) - //{ - // if (GetSections().All(x => x.Alias != alias)) - // { - // LoadXml(doc => - // { - // doc.Root.Add(new XElement("add", - // new XAttribute("alias", alias), - // new XAttribute("name", name), - // new XAttribute("icon", icon), - // new XAttribute("sortOrder", sortOrder))); - // return true; - // }, true); - - // //raise event - // OnNew(this /*new Section(name, alias, sortOrder)*/, new EventArgs()); - // } - //} - - ///// - ///// Deletes the section - ///// - //public void DeleteSection(Section section) - //{ - // lock (Locker) - // { - // //delete the assigned applications - // using (var scope = _scopeProvider.CreateScope()) - // { - // scope.Database.Execute("delete from umbracoUserGroup2App where app = @appAlias", - // new { appAlias = section.Alias }); - // scope.Complete(); - // } - - // //delete the assigned trees - // var trees = _applicationTreeService.GetApplicationTrees(section.Alias); - // foreach (var t in trees) - // { - // _applicationTreeService.DeleteTree(t); - // } - - // LoadXml(doc => - // { - // doc.Root.Elements("add").Where(x => x.Attribute("alias") != null && x.Attribute("alias").Value == section.Alias) - // .Remove(); - - // return true; - // }, true); - - // //raise event - // OnDeleted(this, new EventArgs()); - // } - //} - - //private List
ReadFromXmlAndSort() - //{ - // var tmp = new List
(); - - // LoadXml(doc => - // { - // foreach (var addElement in doc.Root.Elements("add").OrderBy(x => - // { - // var sortOrderAttr = x.Attribute("sortOrder"); - // return sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0; - // })) - // { - // var sortOrderAttr = addElement.Attribute("sortOrder"); - // tmp.Add(new Section(addElement.Attribute("name").Value, - // addElement.Attribute("alias").Value, - // sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0)); - // } - // return false; - // }, false); - - // return tmp; - //} - - //internal static event TypedEventHandler Deleted; - //private static void OnDeleted(ISectionService app, EventArgs args) - //{ - // if (Deleted != null) - // { - // Deleted(app, args); - // } - //} - - //internal static event TypedEventHandler New; - //private static void OnNew(ISectionService app, EventArgs args) - //{ - // if (New != null) - // { - // New(app, args); - // } - //} - - ///// - ///// This class is here so that we can provide lazy access to tree scanning for when it is needed - ///// - //private class LazyEnumerableSections : IEnumerable
- //{ - // public LazyEnumerableSections() - // { - // _lazySections = new Lazy>(() => - // { - // // Load all Applications by attribute and add them to the XML config - - // //don't cache the result of this because it is only used once during app startup, caching will just add a bit more mem overhead for no reason - // var types = Current.TypeLoader.GetTypesWithAttribute(cache: false); // fixme - inject - - // //since applications don't populate their metadata from the attribute and because it is an interface, - // //we need to interrogate the attributes for the data. Would be better to have a base class that contains - // //metadata populated by the attribute. Oh well i guess. - // var attrs = types.Select(x => x.GetCustomAttributes(false).Single()); - // return attrs.Select(x => new Section(x.Name, x.Alias, x.SortOrder)).ToArray(); - // }); - // } - - // private readonly Lazy> _lazySections; - - // /// - // /// Returns an enumerator that iterates through the collection. - // /// - // /// - // /// A that can be used to iterate through the collection. - // /// - // public IEnumerator
GetEnumerator() - // { - // return _lazySections.Value.GetEnumerator(); - // } - - // /// - // /// Returns an enumerator that iterates through a collection. - // /// - // /// - // /// An object that can be used to iterate through the collection. - // /// - // IEnumerator IEnumerable.GetEnumerator() - // { - // return GetEnumerator(); - // } - //} - + /// + public IBackOfficeSection GetByAlias(string appAlias) => GetSections().FirstOrDefault(t => t.Alias == appAlias); + } } diff --git a/src/Umbraco.Web/Services/TreeService.cs b/src/Umbraco.Web/Services/TreeService.cs index cf010f1480..670f57ce49 100644 --- a/src/Umbraco.Web/Services/TreeService.cs +++ b/src/Umbraco.Web/Services/TreeService.cs @@ -1,237 +1,22 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Xml.Linq; using Umbraco.Core; -using Umbraco.Core.Cache; -using Umbraco.Core.Events; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Core.Composing; -using Umbraco.Core.Models.ContentEditing; -using Umbraco.Core.Services; -using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Trees; namespace Umbraco.Web.Services { internal class TreeService : ITreeService { - private readonly ILogger _logger; private readonly TreeCollection _treeCollection; - private static readonly object Locker = new object(); private readonly Lazy>> _groupedTrees; - public TreeService(ILogger logger, TreeCollection treeCollection) + public TreeService(TreeCollection treeCollection) { - _logger = logger; _treeCollection = treeCollection; _groupedTrees = new Lazy>>(InitGroupedTrees); } - ///// - ///// gets/sets the trees.config file path - ///// - ///// - ///// The setter is generally only going to be used in unit tests, otherwise it will attempt to resolve it using the IOHelper.MapPath - ///// - //internal static string TreeConfigFilePath - //{ - // get - // { - // if (string.IsNullOrWhiteSpace(_treeConfig)) - // { - // _treeConfig = IOHelper.MapPath(SystemDirectories.Config + "/" + TreeConfigFileName); - // } - // return _treeConfig; - // } - // set { _treeConfig = value; } - //} - - ///// - ///// The main entry point to get application trees - ///// - ///// - ///// This lazily on first access will scan for plugin trees and ensure the trees.config is up-to-date with the plugins. If plugins - ///// haven't changed on disk then the file will not be saved. The trees are all then loaded from this config file into cache and returned. - ///// - //private List GetAppTrees() - //{ - // return _cache.RuntimeCache.GetCacheItem>( - // CacheKeys.ApplicationTreeCacheKey, - // () => - // { - // var list = ReadFromXmlAndSort(); - - // //now we can check the non-volatile flag - // if (_allAvailableTrees != null) - // { - // var hasChanges = false; - - // LoadXml(doc => - // { - // //Now, load in the xml structure and update it with anything that is not declared there and save the file. - - // //NOTE: On the first iteration here, it will lazily scan all trees, etc... this is because this ienumerable is lazy - // // based on the ApplicationTreeRegistrar - and as noted there this is not an ideal way to do things but were stuck like this - // // currently because of the legacy assemblies and types not in the Core. - - // //Get all the trees not registered in the config (those not matching by alias casing will be detected as "unregistered") - // var unregistered = _allAvailableTrees.Value - // .Where(x => list.Any(l => l.Alias == x.Alias) == false) - // .ToArray(); - - // hasChanges = unregistered.Any(); - - // if (hasChanges == false) return false; - - // //add or edit the unregistered ones and re-save the file if any changes were found - // var count = 0; - // foreach (var tree in unregistered) - // { - // var existingElement = doc.Root.Elements("add").SingleOrDefault(x => - // string.Equals(x.Attribute("alias").Value, tree.Alias, - // StringComparison.InvariantCultureIgnoreCase) && - // string.Equals(x.Attribute("application").Value, tree.ApplicationAlias, - // StringComparison.InvariantCultureIgnoreCase)); - // if (existingElement != null) - // { - // existingElement.SetAttributeValue("alias", tree.Alias); - // } - // else - // { - // if (tree.Title.IsNullOrWhiteSpace()) - // { - // doc.Root.Add(new XElement("add", - // new XAttribute("initialize", tree.Initialize), - // new XAttribute("sortOrder", tree.SortOrder), - // new XAttribute("alias", tree.Alias), - // new XAttribute("application", tree.ApplicationAlias), - // new XAttribute("iconClosed", tree.IconClosed), - // new XAttribute("iconOpen", tree.IconOpened), - // new XAttribute("type", tree.Type))); - // } - // else - // { - // doc.Root.Add(new XElement("add", - // new XAttribute("initialize", tree.Initialize), - // new XAttribute("sortOrder", tree.SortOrder), - // new XAttribute("alias", tree.Alias), - // new XAttribute("application", tree.ApplicationAlias), - // new XAttribute("title", tree.Title), - // new XAttribute("iconClosed", tree.IconClosed), - // new XAttribute("iconOpen", tree.IconOpened), - // new XAttribute("type", tree.Type))); - // } - - // } - // count++; - // } - - // //don't save if there's no changes - // return count > 0; - // }, true); - - // if (hasChanges) - // { - // //If there were changes, we need to re-read the structures from the XML - // list = ReadFromXmlAndSort(); - // } - // } - - // return list; - // }, new TimeSpan(0, 10, 0)); - //} - - ///// - ///// Creates a new application tree. - ///// - ///// if set to true [initialize]. - ///// The sort order. - ///// The application alias. - ///// The alias. - ///// The title. - ///// The icon closed. - ///// The icon opened. - ///// The type. - //public void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type) - //{ - // LoadXml(doc => - // { - // var el = doc.Root.Elements("add").SingleOrDefault(x => x.Attribute("alias").Value == alias && x.Attribute("application").Value == applicationAlias); - - // if (el == null) - // { - // doc.Root.Add(new XElement("add", - // new XAttribute("initialize", initialize), - // new XAttribute("sortOrder", sortOrder), - // new XAttribute("alias", alias), - // new XAttribute("application", applicationAlias), - // new XAttribute("title", title), - // new XAttribute("iconClosed", iconClosed), - // new XAttribute("iconOpen", iconOpened), - // new XAttribute("type", type))); - // } - - // return true; - - // }, true); - - // OnNew(new ApplicationTree(initialize, sortOrder, applicationAlias, alias, title, iconClosed, iconOpened, type), new EventArgs()); - //} - - ///// - ///// Saves this instance. - ///// - //public void SaveTree(ApplicationTree tree) - //{ - // LoadXml(doc => - // { - // var el = doc.Root.Elements("add").SingleOrDefault(x => x.Attribute("alias").Value == tree.Alias && x.Attribute("application").Value == tree.ApplicationAlias); - - // if (el != null) - // { - // el.RemoveAttributes(); - - // el.Add(new XAttribute("initialize", tree.Initialize)); - // el.Add(new XAttribute("sortOrder", tree.SortOrder)); - // el.Add(new XAttribute("alias", tree.Alias)); - // el.Add(new XAttribute("application", tree.ApplicationAlias)); - // el.Add(new XAttribute("title", tree.Title)); - // el.Add(new XAttribute("iconClosed", tree.IconClosed)); - // el.Add(new XAttribute("iconOpen", tree.IconOpened)); - // el.Add(new XAttribute("type", tree.Type)); - // } - - // return true; - - // }, true); - - // OnUpdated(tree, new EventArgs()); - //} - - ///// - ///// Deletes this instance. - ///// - //public void DeleteTree(ApplicationTree tree) - //{ - // LoadXml(doc => - // { - // doc.Root.Elements("add") - // .Where(x => x.Attribute("application") != null - // && x.Attribute("application").Value == tree.ApplicationAlias - // && x.Attribute("alias") != null && x.Attribute("alias").Value == tree.Alias).Remove(); - - // return true; - - // }, true); - - // OnDeleted(tree, new EventArgs()); - //} - /// public ApplicationTree GetByAlias(string treeAlias) => _treeCollection.FirstOrDefault(t => t.TreeAlias == treeAlias); @@ -242,26 +27,6 @@ namespace Umbraco.Web.Services public IEnumerable GetApplicationTrees(string applicationAlias) => GetAll().Where(x => x.ApplicationAlias.InvariantEquals(applicationAlias)).OrderBy(x => x.SortOrder).ToList(); - ///// - ///// Gets the application tree for the applcation with the specified alias - ///// - ///// The application alias. - ///// - ///// Returns a ApplicationTree Array - //public IEnumerable GetApplicationTrees(string applicationAlias, bool onlyInitialized) - //{ - // var list = GetAppTrees().FindAll( - // t => - // { - // if (onlyInitialized) - // return (t.ApplicationAlias == applicationAlias && t.Initialize); - // return (t.ApplicationAlias == applicationAlias); - // } - // ); - - // return list.OrderBy(x => x.SortOrder).ToArray(); - //} - public IDictionary> GetGroupedApplicationTrees(string applicationAlias) { var result = new Dictionary>(); @@ -273,11 +38,10 @@ namespace Umbraco.Web.Services { foreach(var treeAliasInGroup in treeGroup) { - if (tree.TreeAlias == treeAliasInGroup) - { - if (resultGroup == null) resultGroup = new List(); - resultGroup.Add(tree); - } + if (tree.TreeAlias != treeAliasInGroup) continue; + + if (resultGroup == null) resultGroup = new List(); + resultGroup.Add(tree); } } if (resultGroup != null) @@ -302,169 +66,5 @@ namespace Umbraco.Web.Services return result; } - ///// - ///// Loads in the xml structure from disk if one is found, otherwise loads in an empty xml structure, calls the - ///// callback with the xml document and saves the structure back to disk if saveAfterCallback is true. - ///// - ///// - ///// - //internal void LoadXml(Func callback, bool saveAfterCallbackIfChanges) - //{ - // lock (Locker) - // { - // var doc = System.IO.File.Exists(TreeConfigFilePath) - // ? XDocument.Load(TreeConfigFilePath) - // : XDocument.Parse(""); - - // if (doc.Root != null) - // { - // var hasChanges = callback.Invoke(doc); - - // if (saveAfterCallbackIfChanges && hasChanges - // //Don't save it if it is empty, in some very rare cases if the app domain get's killed in the middle of this process - // // in some insane way the file saved will be empty. I'm pretty sure it's not actually anything to do with the xml doc and - // // more about the IO trying to save the XML doc, but it doesn't hurt to check. - // && doc.Root != null && doc.Root.Elements().Any()) - // { - // //ensures the folder exists - // Directory.CreateDirectory(Path.GetDirectoryName(TreeConfigFilePath)); - - // //saves it - // doc.Save(TreeConfigFilePath); - - // //remove the cache now that it has changed SD: I'm leaving this here even though it - // // is taken care of by events as well, I think unit tests may rely on it being cleared here. - // _cache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey); - // } - // } - // } - //} - - //private List ReadFromXmlAndSort() - //{ - // var list = new List(); - - // //read in the xml file containing trees and convert them all to ApplicationTree instances - // LoadXml(doc => - // { - // foreach (var addElement in doc.Root.Elements("add").OrderBy(x => - // { - // var sortOrderAttr = x.Attribute("sortOrder"); - // return sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0; - // })) - // { - // var applicationAlias = (string)addElement.Attribute("application"); - // var type = (string)addElement.Attribute("type"); - // var assembly = (string)addElement.Attribute("assembly"); - - // var clrType = Type.GetType(type); - // if (clrType == null) - // { - // _logger.Warn("The tree definition: {AddElement} could not be resolved to a .Net object type", addElement); - // continue; - // } - - // //check if the tree definition (applicationAlias + type + assembly) is already in the list - - // if (list.Any(tree => tree.ApplicationAlias.InvariantEquals(applicationAlias) && tree.GetRuntimeType() == clrType) == false) - // { - // list.Add(new ApplicationTree( - // addElement.Attribute("initialize") == null || Convert.ToBoolean(addElement.Attribute("initialize").Value), - // addElement.Attribute("sortOrder") != null - // ? Convert.ToByte(addElement.Attribute("sortOrder").Value) - // : (byte)0, - // (string)addElement.Attribute("application"), - // (string)addElement.Attribute("alias"), - // (string)addElement.Attribute("title"), - // (string)addElement.Attribute("iconClosed"), - // (string)addElement.Attribute("iconOpen"), - // (string)addElement.Attribute("type"))); - // } - // } - - // return false; - - // }, false); - - // return list; - //} - - - //internal static event TypedEventHandler Deleted; - //private static void OnDeleted(ApplicationTree app, EventArgs args) - //{ - // if (Deleted != null) - // { - // Deleted(app, args); - // } - //} - - //internal static event TypedEventHandler New; - //private static void OnNew(ApplicationTree app, EventArgs args) - //{ - // if (New != null) - // { - // New(app, args); - // } - //} - - //internal static event TypedEventHandler Updated; - //private static void OnUpdated(ApplicationTree app, EventArgs args) - //{ - // if (Updated != null) - // { - // Updated(app, args); - // } - //} - - ///// - ///// This class is here so that we can provide lazy access to tree scanning for when it is needed - ///// - //private class LazyEnumerableTrees : IEnumerable - //{ - // public LazyEnumerableTrees(TypeLoader typeLoader) - // { - // _lazyTrees = new Lazy>(() => - // { - // var added = new List(); - - // // Load all Controller Trees by attribute - // var types = typeLoader.GetTypesWithAttribute(); // fixme inject - // //convert them to ApplicationTree instances - // var items = types - // .Select(x => (tree: x, treeAttribute: x.GetCustomAttributes(false).Single())) - // .Select(x => new ApplicationTree(x.treeAttribute.Initialize, x.treeAttribute.SortOrder, x.treeAttribute.ApplicationAlias, x.treeAttribute.Alias, x.treeAttribute.Title, x.treeAttribute.IconClosed, x.treeAttribute.IconOpen, x.tree.GetFullNameWithAssembly())) - // .ToArray(); - - // added.AddRange(items.Select(x => x.Alias)); - - // return items.ToArray(); - // }); - // } - - // private readonly Lazy> _lazyTrees; - - // /// - // /// Returns an enumerator that iterates through the collection. - // /// - // /// - // /// A that can be used to iterate through the collection. - // /// - // public IEnumerator GetEnumerator() - // { - // return _lazyTrees.Value.GetEnumerator(); - // } - - // /// - // /// Returns an enumerator that iterates through a collection. - // /// - // /// - // /// An object that can be used to iterate through the collection. - // /// - // IEnumerator IEnumerable.GetEnumerator() - // { - // return GetEnumerator(); - // } - //} } } diff --git a/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs b/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs index 2b5a78d758..54762e73d8 100644 --- a/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs +++ b/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs @@ -2,6 +2,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; namespace Umbraco.Web.Trees { @@ -11,11 +12,4 @@ namespace Umbraco.Web.Trees : base(items) { } } - - public class BackOfficeSectionCollectionBuilder : LazyCollectionBuilderBase - { - protected override BackOfficeSectionCollectionBuilder This => this; - - //TODO: can we allow for re-ordering OOTB without exposing other methods? - } } diff --git a/src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs b/src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs new file mode 100644 index 0000000000..62d61a4090 --- /dev/null +++ b/src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs @@ -0,0 +1,10 @@ +using Umbraco.Core.Composing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + public class BackOfficeSectionCollectionBuilder : OrderedCollectionBuilderBase + { + protected override BackOfficeSectionCollectionBuilder This => this; + } +} diff --git a/src/Umbraco.Web/Trees/ContentBackOfficeSection.cs b/src/Umbraco.Web/Trees/ContentBackOfficeSection.cs new file mode 100644 index 0000000000..0109a6916d --- /dev/null +++ b/src/Umbraco.Web/Trees/ContentBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office content section + /// + public class ContentBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Content; + public string Name => "Content"; + } +} diff --git a/src/Umbraco.Web/Trees/ITree.cs b/src/Umbraco.Web/Trees/ITree.cs index 40be7338b0..f408ce5e60 100644 --- a/src/Umbraco.Web/Trees/ITree.cs +++ b/src/Umbraco.Web/Trees/ITree.cs @@ -1,5 +1,6 @@ namespace Umbraco.Web.Trees { + //fixme - we don't really use this, it is nice to have the treecontroller, attribute and ApplicationTree streamlined to implement this but it's not used public interface ITree { /// diff --git a/src/Umbraco.Web/Trees/MediaBackOfficeSection.cs b/src/Umbraco.Web/Trees/MediaBackOfficeSection.cs new file mode 100644 index 0000000000..aac4fd036f --- /dev/null +++ b/src/Umbraco.Web/Trees/MediaBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office media section + /// + public class MediaBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Media; + public string Name => "Media"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/MembersBackOfficeSection.cs b/src/Umbraco.Web/Trees/MembersBackOfficeSection.cs new file mode 100644 index 0000000000..bfaead33d5 --- /dev/null +++ b/src/Umbraco.Web/Trees/MembersBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office members section + /// + public class MembersBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Members; + public string Name => "Members"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs b/src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs new file mode 100644 index 0000000000..41f049c092 --- /dev/null +++ b/src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office packages section + /// + public class PackagesBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Packages; + public string Name => "Packages"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs b/src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs new file mode 100644 index 0000000000..623f593c30 --- /dev/null +++ b/src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office settings section + /// + public class SettingsBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Settings; + public string Name => "Settings"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs b/src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs new file mode 100644 index 0000000000..41254b3179 --- /dev/null +++ b/src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office translation section + /// + public class TranslationBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Translation; + public string Name => "Translation"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/TreeCollection.cs b/src/Umbraco.Web/Trees/TreeCollection.cs index c7b60dea16..51b79ce67b 100644 --- a/src/Umbraco.Web/Trees/TreeCollection.cs +++ b/src/Umbraco.Web/Trees/TreeCollection.cs @@ -16,31 +16,4 @@ namespace Umbraco.Web.Trees : base(items) { } } - - public class TreeCollectionBuilder : LazyCollectionBuilderBase - { - protected override TreeCollectionBuilder This => this; - - private readonly List _instances = new List(); - - public void AddTree(ApplicationTree tree) - { - _instances.Add(tree); - } - - protected override IEnumerable CreateItems(IFactory factory) - { - return _instances; - - //var items = base.CreateItems(factory).ToList(); - //throw new NotImplementedException(); - ////validate the items, no actions should exist that do not either expose notifications or permissions - //var invalidItems = items.Where(x => !x.CanBePermissionAssigned && !x.ShowInNotifier).ToList(); - //if (invalidItems.Count == 0) return items; - - //var invalidActions = string.Join(", ", invalidItems.Select(x => "'" + x.Alias + "'")); - //throw new InvalidOperationException($"Invalid actions {invalidActions}'. All {typeof(IAction)} implementations must be true for either {nameof(IAction.CanBePermissionAssigned)} or {nameof(IAction.ShowInNotifier)}."); - } - } - } diff --git a/src/Umbraco.Web/Trees/TreeCollectionBuilder.cs b/src/Umbraco.Web/Trees/TreeCollectionBuilder.cs new file mode 100644 index 0000000000..2f92e72419 --- /dev/null +++ b/src/Umbraco.Web/Trees/TreeCollectionBuilder.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Umbraco.Core.Composing; + +namespace Umbraco.Web.Trees +{ + //fixme - how will we allow users to modify these items? they will need to be able to change the ApplicationTree's registered (i.e. sort order, section) + public class TreeCollectionBuilder : CollectionBuilderBase + { + private readonly List _instances = new List(); + + public void AddTree(ApplicationTree tree) + { + _instances.Add(tree); + } + + protected override IEnumerable CreateItems(IFactory factory) => _instances; + } +} diff --git a/src/Umbraco.Web/Trees/UsersBackOfficeSection.cs b/src/Umbraco.Web/Trees/UsersBackOfficeSection.cs new file mode 100644 index 0000000000..90a65cb508 --- /dev/null +++ b/src/Umbraco.Web/Trees/UsersBackOfficeSection.cs @@ -0,0 +1,15 @@ +using Umbraco.Core; +using Umbraco.Web.Models.ContentEditing; +using Umbraco.Web.Models.Trees; + +namespace Umbraco.Web.Trees +{ + /// + /// Defines the back office users section + /// + public class UsersBackOfficeSection : IBackOfficeSection + { + public string Alias => Constants.Applications.Users; + public string Name => "Users"; + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 0b1603c9e3..161f6c6689 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -166,8 +166,16 @@ + + + + + + + + - + @@ -591,7 +599,7 @@ - + @@ -673,7 +681,6 @@ - @@ -970,7 +977,7 @@ - +