From 7185089f1de0577049f6f4c3c8c9bb6bbfca95d0 Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 18 Feb 2019 11:22:25 +0100 Subject: [PATCH] Move sections to their own namespace --- src/Umbraco.Core/Manifest/ManifestParser.cs | 2 +- ...ackOfficeSection.cs => ManifestSection.cs} | 4 ++-- src/Umbraco.Core/Manifest/PackageManifest.cs | 2 +- .../ISection.cs} | 4 ++-- src/Umbraco.Core/Umbraco.Core.csproj | 4 ++-- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 17 ++++++++-------- src/Umbraco.Web/CompositionExtensions.cs | 5 +++-- .../Models/Mapping/SectionMapperProfile.cs | 4 ++-- src/Umbraco.Web/Runtime/WebRuntimeComposer.cs | 19 +++++++++--------- .../ContentSection.cs} | 6 +++--- .../FormsSection.cs} | 6 +++--- .../MediaSection.cs} | 6 +++--- .../MembersSection.cs} | 6 +++--- .../PackagesSection.cs} | 6 +++--- src/Umbraco.Web/Sections/SectionCollection.cs | 13 ++++++++++++ .../SectionCollectionBuilder.cs} | 10 +++++----- .../SettingsSection.cs} | 6 +++--- .../TranslationSection.cs} | 6 +++--- .../UsersSection.cs} | 6 +++--- src/Umbraco.Web/Services/ISectionService.cs | 8 ++++---- src/Umbraco.Web/Services/SectionService.cs | 13 ++++++------ .../Trees/BackOfficeSectionCollection.cs | 13 ------------ src/Umbraco.Web/Umbraco.Web.csproj | 20 +++++++++---------- 23 files changed, 95 insertions(+), 91 deletions(-) rename src/Umbraco.Core/Manifest/{ManifestBackOfficeSection.cs => ManifestSection.cs} (75%) rename src/Umbraco.Core/Models/{Trees/IBackOfficeSection.cs => Sections/ISection.cs} (80%) rename src/Umbraco.Web/{Trees/ContentBackOfficeSection.cs => Sections/ContentSection.cs} (69%) rename src/Umbraco.Web/{Trees/FormsBackOfficeSection.cs => Sections/FormsSection.cs} (64%) rename src/Umbraco.Web/{Trees/MediaBackOfficeSection.cs => Sections/MediaSection.cs} (64%) rename src/Umbraco.Web/{Trees/MembersBackOfficeSection.cs => Sections/MembersSection.cs} (69%) rename src/Umbraco.Web/{Trees/PackagesBackOfficeSection.cs => Sections/PackagesSection.cs} (69%) create mode 100644 src/Umbraco.Web/Sections/SectionCollection.cs rename src/Umbraco.Web/{Trees/BackOfficeSectionCollectionBuilder.cs => Sections/SectionCollectionBuilder.cs} (60%) rename src/Umbraco.Web/{Trees/SettingsBackOfficeSection.cs => Sections/SettingsSection.cs} (69%) rename src/Umbraco.Web/{Trees/TranslationBackOfficeSection.cs => Sections/TranslationSection.cs} (69%) rename src/Umbraco.Web/{Trees/UsersBackOfficeSection.cs => Sections/UsersSection.cs} (69%) delete mode 100644 src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index 6ca3b916ea..dc40cd90a2 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -101,7 +101,7 @@ namespace Umbraco.Core.Manifest var gridEditors = new List(); var contentApps = new List(); var dashboards = new List(); - var sections = new List(); + var sections = new List(); foreach (var manifest in manifests) { diff --git a/src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs b/src/Umbraco.Core/Manifest/ManifestSection.cs similarity index 75% rename from src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs rename to src/Umbraco.Core/Manifest/ManifestSection.cs index a1b89d9a01..584e2a157b 100644 --- a/src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs +++ b/src/Umbraco.Core/Manifest/ManifestSection.cs @@ -1,10 +1,10 @@ using System.Runtime.Serialization; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; namespace Umbraco.Core.Manifest { [DataContract(Name = "section", Namespace = "")] - public class ManifestBackOfficeSection : IBackOfficeSection + public class ManifestSection : ISection { [DataMember(Name = "alias")] public string Alias { get; set; } diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs index c272449509..475ee8a7f8 100644 --- a/src/Umbraco.Core/Manifest/PackageManifest.cs +++ b/src/Umbraco.Core/Manifest/PackageManifest.cs @@ -55,6 +55,6 @@ namespace Umbraco.Core.Manifest /// Gets or sets the sections listed in the manifest. /// [JsonProperty("sections")] - public ManifestBackOfficeSection[] Sections { get; set; } = Array.Empty(); + public ManifestSection[] Sections { get; set; } = Array.Empty(); } } diff --git a/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs b/src/Umbraco.Core/Models/Sections/ISection.cs similarity index 80% rename from src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs rename to src/Umbraco.Core/Models/Sections/ISection.cs index 86e2a18fd5..7967a9d01a 100644 --- a/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs +++ b/src/Umbraco.Core/Models/Sections/ISection.cs @@ -1,9 +1,9 @@ -namespace Umbraco.Core.Models.Trees +namespace Umbraco.Core.Models.Sections { /// /// Defines a back office section. /// - public interface IBackOfficeSection + public interface ISection { /// /// Gets the alias of the section. diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 247fed0a5e..1467d36973 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -345,7 +345,7 @@ - + @@ -452,7 +452,7 @@ - + diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index dd9aafa037..f6f8f220b8 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -38,6 +38,7 @@ using Umbraco.Web.Routing; using Umbraco.Web.Trees; using Umbraco.Core.Composing.CompositionExtensions; using Umbraco.Web.Composing.CompositionExtensions; +using Umbraco.Web.Sections; using Current = Umbraco.Core.Composing.Current; using FileSystems = Umbraco.Core.IO.FileSystems; @@ -218,14 +219,14 @@ namespace Umbraco.Tests.Testing Composition.RegisterUnique(); // register back office sections in the order we want them rendered - Composition.WithCollectionBuilder().Append() - .Append() - .Append() - .Append() - .Append() - .Append() - .Append() - .Append(); + Composition.WithCollectionBuilder().Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append(); Composition.RegisterUnique(); } diff --git a/src/Umbraco.Web/CompositionExtensions.cs b/src/Umbraco.Web/CompositionExtensions.cs index f0648b5128..80435d69f8 100644 --- a/src/Umbraco.Web/CompositionExtensions.cs +++ b/src/Umbraco.Web/CompositionExtensions.cs @@ -11,6 +11,7 @@ using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.Search; +using Umbraco.Web.Sections; using Umbraco.Web.Tour; using Umbraco.Web.Trees; using Current = Umbraco.Web.Composing.Current; @@ -93,8 +94,8 @@ namespace Umbraco.Web /// Gets the backoffice sections/applications collection builder. /// /// The composition. - public static BackOfficeSectionCollectionBuilder Sections(this Composition composition) - => composition.WithCollectionBuilder(); + public static SectionCollectionBuilder Sections(this Composition composition) + => composition.WithCollectionBuilder(); /// /// Gets the backoffice dashboards collection builder. diff --git a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs index 7e727a3752..c82e2881b9 100644 --- a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using AutoMapper; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; using Umbraco.Core.Services; using Umbraco.Web.Models.ContentEditing; @@ -10,7 +10,7 @@ namespace Umbraco.Web.Models.Mapping { public SectionMapperProfile(ILocalizedTextService textService) { - CreateMap() + CreateMap() .ForMember(dest => dest.RoutePath, opt => opt.Ignore()) .ForMember(dest => dest.Icon, opt => opt.Ignore()) .ForMember(dest => dest.Name, opt => opt.MapFrom(src => textService.Localize("sections/" + src.Alias, (IDictionary)null))) diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs index 79712e01f1..c8fc209768 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs @@ -31,6 +31,7 @@ using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.Search; +using Umbraco.Web.Sections; using Umbraco.Web.Security; using Umbraco.Web.Security.Providers; using Umbraco.Web.Services; @@ -225,15 +226,15 @@ namespace Umbraco.Web.Runtime .Append(); // register back office sections in the order we want them rendered - composition.WithCollectionBuilder() - .Append() - .Append() - .Append() - .Append() - .Append() - .Append() - .Append() - .Append(); + composition.WithCollectionBuilder() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append(); // register core CMS dashboards and 3rd party types - will be ordered by weight attribute & merged with package.manifest dashboards composition.WithCollectionBuilder() diff --git a/src/Umbraco.Web/Trees/ContentBackOfficeSection.cs b/src/Umbraco.Web/Sections/ContentSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/ContentBackOfficeSection.cs rename to src/Umbraco.Web/Sections/ContentSection.cs index 8b37ce0e12..a93c3040f8 100644 --- a/src/Umbraco.Web/Trees/ContentBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/ContentSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office content section /// - public class ContentBackOfficeSection : IBackOfficeSection + public class ContentSection : ISection { /// public string Alias => Constants.Applications.Content; diff --git a/src/Umbraco.Web/Trees/FormsBackOfficeSection.cs b/src/Umbraco.Web/Sections/FormsSection.cs similarity index 64% rename from src/Umbraco.Web/Trees/FormsBackOfficeSection.cs rename to src/Umbraco.Web/Sections/FormsSection.cs index 048ed47f11..98ca2d1eb5 100644 --- a/src/Umbraco.Web/Trees/FormsBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/FormsSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office media section /// - public class FormsBackOfficeSection : IBackOfficeSection + public class FormsSection : ISection { public string Alias => Constants.Applications.Forms; public string Name => "Forms"; diff --git a/src/Umbraco.Web/Trees/MediaBackOfficeSection.cs b/src/Umbraco.Web/Sections/MediaSection.cs similarity index 64% rename from src/Umbraco.Web/Trees/MediaBackOfficeSection.cs rename to src/Umbraco.Web/Sections/MediaSection.cs index 34ce6b89a9..3d6b16125a 100644 --- a/src/Umbraco.Web/Trees/MediaBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/MediaSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office media section /// - public class MediaBackOfficeSection : IBackOfficeSection + public class MediaSection : ISection { public string Alias => Constants.Applications.Media; public string Name => "Media"; diff --git a/src/Umbraco.Web/Trees/MembersBackOfficeSection.cs b/src/Umbraco.Web/Sections/MembersSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/MembersBackOfficeSection.cs rename to src/Umbraco.Web/Sections/MembersSection.cs index 1d1f66835c..1f82d31131 100644 --- a/src/Umbraco.Web/Trees/MembersBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/MembersSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office members section /// - public class MembersBackOfficeSection : IBackOfficeSection + public class MembersSection : ISection { /// public string Alias => Constants.Applications.Members; diff --git a/src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs b/src/Umbraco.Web/Sections/PackagesSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs rename to src/Umbraco.Web/Sections/PackagesSection.cs index f59d368d91..265b440195 100644 --- a/src/Umbraco.Web/Trees/PackagesBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/PackagesSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office packages section /// - public class PackagesBackOfficeSection : IBackOfficeSection + public class PackagesSection : ISection { /// public string Alias => Constants.Applications.Packages; diff --git a/src/Umbraco.Web/Sections/SectionCollection.cs b/src/Umbraco.Web/Sections/SectionCollection.cs new file mode 100644 index 0000000000..9b3a07eb64 --- /dev/null +++ b/src/Umbraco.Web/Sections/SectionCollection.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Umbraco.Core.Composing; +using Umbraco.Core.Models.Sections; + +namespace Umbraco.Web.Sections +{ + public class SectionCollection : BuilderCollectionBase + { + public SectionCollection(IEnumerable items) + : base(items) + { } + } +} diff --git a/src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs b/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs similarity index 60% rename from src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs rename to src/Umbraco.Web/Sections/SectionCollectionBuilder.cs index 290e28fab8..e38da85cfa 100644 --- a/src/Umbraco.Web/Trees/BackOfficeSectionCollectionBuilder.cs +++ b/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs @@ -3,15 +3,15 @@ using System.Linq; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Manifest; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { - public class BackOfficeSectionCollectionBuilder : OrderedCollectionBuilderBase + public class SectionCollectionBuilder : OrderedCollectionBuilderBase { - protected override BackOfficeSectionCollectionBuilder This => this; + protected override SectionCollectionBuilder This => this; - protected override IEnumerable CreateItems(IFactory factory) + protected override IEnumerable CreateItems(IFactory factory) { // get the manifest parser just-in-time - injecting it in the ctor would mean that // simply getting the builder in order to configure the collection, would require diff --git a/src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs b/src/Umbraco.Web/Sections/SettingsSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs rename to src/Umbraco.Web/Sections/SettingsSection.cs index 71b9781cd1..4185cd123a 100644 --- a/src/Umbraco.Web/Trees/SettingsBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/SettingsSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office settings section /// - public class SettingsBackOfficeSection : IBackOfficeSection + public class SettingsSection : ISection { /// public string Alias => Constants.Applications.Settings; diff --git a/src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs b/src/Umbraco.Web/Sections/TranslationSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs rename to src/Umbraco.Web/Sections/TranslationSection.cs index bba1f5d8a3..b23dbde93b 100644 --- a/src/Umbraco.Web/Trees/TranslationBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/TranslationSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office translation section /// - public class TranslationBackOfficeSection : IBackOfficeSection + public class TranslationSection : ISection { /// public string Alias => Constants.Applications.Translation; diff --git a/src/Umbraco.Web/Trees/UsersBackOfficeSection.cs b/src/Umbraco.Web/Sections/UsersSection.cs similarity index 69% rename from src/Umbraco.Web/Trees/UsersBackOfficeSection.cs rename to src/Umbraco.Web/Sections/UsersSection.cs index 0096b2abbb..ac4255ac96 100644 --- a/src/Umbraco.Web/Trees/UsersBackOfficeSection.cs +++ b/src/Umbraco.Web/Sections/UsersSection.cs @@ -1,12 +1,12 @@ using Umbraco.Core; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; -namespace Umbraco.Web.Trees +namespace Umbraco.Web.Sections { /// /// Defines the back office users section /// - public class UsersBackOfficeSection : IBackOfficeSection + public class UsersSection : ISection { /// public string Alias => Constants.Applications.Users; diff --git a/src/Umbraco.Web/Services/ISectionService.cs b/src/Umbraco.Web/Services/ISectionService.cs index 1cb8b6d450..94ff6cf511 100644 --- a/src/Umbraco.Web/Services/ISectionService.cs +++ b/src/Umbraco.Web/Services/ISectionService.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; namespace Umbraco.Web.Services { @@ -8,20 +8,20 @@ namespace Umbraco.Web.Services /// /// The cache storage for all applications /// - IEnumerable GetSections(); + IEnumerable GetSections(); /// /// Get the user group's allowed sections /// /// /// - IEnumerable GetAllowedSections(int userId); + IEnumerable GetAllowedSections(int userId); /// /// Gets the application by its alias. /// /// The application alias. /// - IBackOfficeSection GetByAlias(string appAlias); + ISection GetByAlias(string appAlias); } } diff --git a/src/Umbraco.Web/Services/SectionService.cs b/src/Umbraco.Web/Services/SectionService.cs index 0be28b0294..c001233152 100644 --- a/src/Umbraco.Web/Services/SectionService.cs +++ b/src/Umbraco.Web/Services/SectionService.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Umbraco.Core.Models.Trees; +using Umbraco.Core.Models.Sections; using Umbraco.Core.Services; +using Umbraco.Web.Sections; using Umbraco.Web.Trees; namespace Umbraco.Web.Services @@ -10,11 +11,11 @@ namespace Umbraco.Web.Services internal class SectionService : ISectionService { private readonly IUserService _userService; - private readonly BackOfficeSectionCollection _sectionCollection; + private readonly SectionCollection _sectionCollection; public SectionService( IUserService userService, - BackOfficeSectionCollection sectionCollection) + SectionCollection sectionCollection) { _userService = userService ?? throw new ArgumentNullException(nameof(userService)); _sectionCollection = sectionCollection ?? throw new ArgumentNullException(nameof(sectionCollection)); @@ -23,11 +24,11 @@ namespace Umbraco.Web.Services /// /// The cache storage for all applications /// - public IEnumerable GetSections() + public IEnumerable GetSections() => _sectionCollection; /// - public IEnumerable GetAllowedSections(int userId) + public IEnumerable GetAllowedSections(int userId) { var user = _userService.GetUserById(userId); if (user == null) @@ -37,7 +38,7 @@ namespace Umbraco.Web.Services } /// - public IBackOfficeSection GetByAlias(string appAlias) + public ISection GetByAlias(string appAlias) => GetSections().FirstOrDefault(t => t.Alias == appAlias); } } diff --git a/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs b/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs deleted file mode 100644 index f604fa1124..0000000000 --- a/src/Umbraco.Web/Trees/BackOfficeSectionCollection.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using Umbraco.Core.Composing; -using Umbraco.Core.Models.Trees; - -namespace Umbraco.Web.Trees -{ - public class BackOfficeSectionCollection : BuilderCollectionBase - { - public BackOfficeSectionCollection(IEnumerable items) - : base(items) - { } - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 126e725a50..0618634452 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -219,16 +219,16 @@ - - - - - - - + + + + + + + - + @@ -248,7 +248,7 @@ - + @@ -631,7 +631,7 @@ - +