Bit of cleanup
This commit is contained in:
@@ -73,7 +73,6 @@ namespace Umbraco.Core.Composing.Composers
|
||||
factory.GetInstance<CompiledPackageXmlParser>(), factory.GetInstance<IPackageActionRunner>(),
|
||||
new DirectoryInfo(IOHelper.GetRootDirectorySafe())));
|
||||
|
||||
|
||||
return composition;
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ namespace Umbraco.Core.Composing.Composers
|
||||
/// <param name="packageRepoFileName"></param>
|
||||
/// <returns></returns>
|
||||
private static PackagesRepository CreatePackageRepository(IFactory factory, string packageRepoFileName)
|
||||
=> new PackagesRepository(
|
||||
=> new PackagesRepository(
|
||||
factory.GetInstance<IContentService>(), factory.GetInstance<IContentTypeService>(), factory.GetInstance<IDataTypeService>(), factory.GetInstance<IFileService>(), factory.GetInstance<IMacroService>(), factory.GetInstance<ILocalizationService>(), factory.GetInstance<IEntityXmlSerializer>(), factory.GetInstance<ILogger>(),
|
||||
packageRepoFileName);
|
||||
|
||||
|
||||
15
src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs
Normal file
15
src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
{
|
||||
[DataContract(Name = "section", Namespace = "")]
|
||||
public class ManifestBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
[DataMember(Name = "alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[DataMember(Name = "name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
@@ -101,7 +102,7 @@ namespace Umbraco.Core.Manifest
|
||||
var gridEditors = new List<GridEditor>();
|
||||
var contentApps = new List<ManifestContentAppDefinition>();
|
||||
var dashboards = new List<ManifestDashboardDefinition>();
|
||||
var sections = new Dictionary<string, string>();
|
||||
var sections = new List<ManifestBackOfficeSection>();
|
||||
|
||||
foreach (var manifest in manifests)
|
||||
{
|
||||
@@ -112,9 +113,7 @@ namespace Umbraco.Core.Manifest
|
||||
if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors);
|
||||
if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps);
|
||||
if (manifest.Dashboards != null) dashboards.AddRange(manifest.Dashboards);
|
||||
if (manifest.Sections != null)
|
||||
foreach (var (key, value) in manifest.Sections)
|
||||
sections[key] = value;
|
||||
if (manifest.Sections != null) sections.AddRange(manifest.Sections.DistinctBy(x => x.Alias.ToLowerInvariant()));
|
||||
}
|
||||
|
||||
return new PackageManifest
|
||||
@@ -126,7 +125,7 @@ namespace Umbraco.Core.Manifest
|
||||
GridEditors = gridEditors.ToArray(),
|
||||
ContentApps = contentApps.ToArray(),
|
||||
Dashboards = dashboards.ToArray(),
|
||||
Sections = sections
|
||||
Sections = sections.ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
@@ -11,31 +9,52 @@ namespace Umbraco.Core.Manifest
|
||||
/// </summary>
|
||||
public class PackageManifest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the scripts listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("javascript")]
|
||||
public string[] Scripts { get; set; } = Array.Empty<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the stylesheets listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("css")]
|
||||
public string[] Stylesheets { get; set; }= Array.Empty<string>();
|
||||
public string[] Stylesheets { get; set; } = Array.Empty<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the property editors listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("propertyEditors")]
|
||||
public IDataEditor[] PropertyEditors { get; set; } = Array.Empty<IDataEditor>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parameter editors listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("parameterEditors")]
|
||||
public IDataEditor[] ParameterEditors { get; set; } = Array.Empty<IDataEditor>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the grid editors listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("gridEditors")]
|
||||
public GridEditor[] GridEditors { get; set; } = Array.Empty<GridEditor>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content apps listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("contentApps")]
|
||||
public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty<ManifestContentAppDefinition>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dashboards listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("dashboards")]
|
||||
public ManifestDashboardDefinition[] Dashboards { get; set; } = Array.Empty<ManifestDashboardDefinition>();
|
||||
|
||||
/// <summary>
|
||||
/// Declares the back office sections that this package installs
|
||||
/// Gets or sets the sections listed in the manifest.
|
||||
/// </summary>
|
||||
[JsonProperty("sections")]
|
||||
public IReadOnlyDictionary<string, string> Sections { get; set; } = new Dictionary<string, string>();
|
||||
public ManifestBackOfficeSection[] Sections { get; set; } = Array.Empty<ManifestBackOfficeSection>();
|
||||
}
|
||||
}
|
||||
|
||||
18
src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
Normal file
18
src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Umbraco.Core.Models.Trees
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a back office section.
|
||||
/// </summary>
|
||||
public interface IBackOfficeSection
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the alias of the section.
|
||||
/// </summary>
|
||||
string Alias { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the section.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -355,6 +355,7 @@
|
||||
<Compile Include="Logging\Serilog\LoggerConfigExtensions.cs" />
|
||||
<Compile Include="Logging\Serilog\Enrichers\Log4NetLevelMapperEnricher.cs" />
|
||||
<Compile Include="Manifest\DashboardAccessRuleConverter.cs" />
|
||||
<Compile Include="Manifest\ManifestBackOfficeSection.cs" />
|
||||
<Compile Include="Manifest\ManifestContentAppDefinition.cs" />
|
||||
<Compile Include="Manifest\ManifestContentAppFactory.cs" />
|
||||
<Compile Include="Manifest\ManifestDashboardDefinition.cs" />
|
||||
@@ -449,6 +450,7 @@
|
||||
<Compile Include="Models\PublishedContent\VariationContext.cs" />
|
||||
<Compile Include="Models\PublishedContent\ThreadCultureVariationContextAccessor.cs" />
|
||||
<Compile Include="Models\PublishedContent\VariationContextAccessorExtensions.cs" />
|
||||
<Compile Include="Models\Trees\IBackOfficeSection.cs" />
|
||||
<Compile Include="Packaging\CompiledPackageXmlParser.cs" />
|
||||
<Compile Include="Packaging\ICreatedPackagesRepository.cs" />
|
||||
<Compile Include="Packaging\IInstalledPackagesRepository.cs" />
|
||||
|
||||
@@ -433,19 +433,17 @@ javascript: ['~/test.js',/*** some note about stuff asd09823-4**09234*/ '~/test2
|
||||
[Test]
|
||||
public void CanParseManifest_Sections()
|
||||
{
|
||||
const string json = @"{'sections': {
|
||||
'content': 'Content',
|
||||
'hello': 'World'
|
||||
}
|
||||
}";
|
||||
const string json = @"{'sections': [
|
||||
{ ""alias"": ""content"", ""name"": ""Content"" },
|
||||
{ ""alias"": ""hello"", ""name"": ""World"" }
|
||||
]}";
|
||||
|
||||
var manifest = _parser.ParseManifest(json);
|
||||
Assert.AreEqual(2, manifest.Sections.Count);
|
||||
Assert.AreEqual("content", manifest.Sections.Keys.ElementAt(0));
|
||||
Assert.AreEqual("hello", manifest.Sections.Keys.ElementAt(1));
|
||||
Assert.AreEqual("Content", manifest.Sections["content"]);
|
||||
Assert.AreEqual("World", manifest.Sections["hello"]);
|
||||
|
||||
Assert.AreEqual(2, manifest.Sections.Length);
|
||||
Assert.AreEqual("content", manifest.Sections[0].Alias);
|
||||
Assert.AreEqual("hello", manifest.Sections[1].Alias);
|
||||
Assert.AreEqual("Content", manifest.Sections[0].Name);
|
||||
Assert.AreEqual("World", manifest.Sections[1].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Services
|
||||
public class SectionServiceTests : TestWithSomeContentBase
|
||||
{
|
||||
private ISectionService SectionService => Factory.GetInstance<ISectionService>();
|
||||
|
||||
|
||||
[Test]
|
||||
public void SectionService_Can_Get_Allowed_Sections_For_User()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Umbraco.Web.Models.Trees
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Defines a back office section
|
||||
/// </summary>
|
||||
public interface IBackOfficeSection
|
||||
{
|
||||
string Alias { get; }
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
{
|
||||
@@ -26,7 +23,5 @@ namespace Umbraco.Web.Services
|
||||
/// <param name="appAlias">The application alias.</param>
|
||||
/// <returns></returns>
|
||||
IBackOfficeSection GetByAlias(string appAlias);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.Trees;
|
||||
|
||||
namespace Umbraco.Web.Services
|
||||
@@ -19,11 +19,12 @@ namespace Umbraco.Web.Services
|
||||
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
|
||||
_sectionCollection = sectionCollection ?? throw new ArgumentNullException(nameof(sectionCollection));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The cache storage for all applications
|
||||
/// </summary>
|
||||
public IEnumerable<IBackOfficeSection> GetSections() => _sectionCollection;
|
||||
public IEnumerable<IBackOfficeSection> GetSections()
|
||||
=> _sectionCollection;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IBackOfficeSection> GetAllowedSections(int userId)
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Web.Services
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IBackOfficeSection GetByAlias(string appAlias) => GetSections().FirstOrDefault(t => t.Alias == appAlias);
|
||||
|
||||
public IBackOfficeSection GetByAlias(string appAlias)
|
||||
=> GetSections().FirstOrDefault(t => t.Alias == appAlias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -11,6 +9,5 @@ namespace Umbraco.Web.Trees
|
||||
public BackOfficeSectionCollection(IEnumerable<IBackOfficeSection> items)
|
||||
: base(items)
|
||||
{ }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
//fixme: how can a developer re-sort the items in this collection ?
|
||||
public class BackOfficeSectionCollectionBuilder : OrderedCollectionBuilderBase<BackOfficeSectionCollectionBuilder, BackOfficeSectionCollection, IBackOfficeSection>
|
||||
{
|
||||
protected override BackOfficeSectionCollectionBuilder This => this;
|
||||
@@ -19,20 +17,7 @@ namespace Umbraco.Web.Trees
|
||||
// its dependencies too, and that can create cycles or other oddities
|
||||
var manifestParser = factory.GetInstance<ManifestParser>();
|
||||
|
||||
return base.CreateItems(factory)
|
||||
.Concat(manifestParser.Manifest.Sections.Select(x => new ManifestBackOfficeSection(x.Key, x.Value)));
|
||||
}
|
||||
|
||||
private class ManifestBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
public ManifestBackOfficeSection(string @alias, string name)
|
||||
{
|
||||
Alias = alias;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public string Alias { get; }
|
||||
public string Name { get; }
|
||||
return base.CreateItems(factory).Concat(manifestParser.Manifest.Sections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class ContentBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Content;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Content";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -12,4 +11,4 @@ namespace Umbraco.Web.Trees
|
||||
public string Alias => Constants.Applications.Media;
|
||||
public string Name => "Media";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class MembersBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Members;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Members";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class PackagesBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Packages;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Packages";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class SettingsBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Settings;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Settings";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class TranslationBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Translation;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Translation";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Core.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -9,7 +8,10 @@ namespace Umbraco.Web.Trees
|
||||
/// </summary>
|
||||
public class UsersBackOfficeSection : IBackOfficeSection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Alias => Constants.Applications.Users;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Users";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,6 @@
|
||||
<Compile Include="Trees\TreeCollectionBuilder.cs" />
|
||||
<Compile Include="Trees\UsersBackOfficeSection.cs" />
|
||||
<Compile Include="Trees\Tree.cs" />
|
||||
<Compile Include="Models\Trees\IBackOfficeSection.cs" />
|
||||
<Compile Include="Trees\ITree.cs" />
|
||||
<Compile Include="Models\ContentEditing\PublicAccess.cs" />
|
||||
<Compile Include="Models\ContentEditing\ObjectType.cs" />
|
||||
|
||||
Reference in New Issue
Block a user