Refactored the ManifestContentAppDefinition to have a factory and a seperate data class.

This commit is contained in:
Bjarke Berg
2018-12-06 10:02:23 +01:00
parent f26353a34e
commit aee6156a09
18 changed files with 212 additions and 158 deletions

View File

@@ -5,15 +5,17 @@ using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.Membership;
namespace Umbraco.Web.ContentApps
{
public class ContentAppDefinitionCollection : BuilderCollectionBase<IContentAppDefinition>
public class ContentAppDefinitionCollection : BuilderCollectionBase<IContentAppFactory>
{
private readonly ILogger _logger;
private readonly IContentAppFactory _factory;
public ContentAppDefinitionCollection(IEnumerable<IContentAppDefinition> items, ILogger logger)
public ContentAppDefinitionCollection(IEnumerable<IContentAppFactory> items, ILogger logger)
: base(items)
{
_logger = logger;
@@ -32,7 +34,10 @@ namespace Umbraco.Web.ContentApps
public IEnumerable<ContentApp> GetContentAppsFor(object o, IEnumerable<IReadOnlyUserGroup> userGroups=null)
{
var roles = GetCurrentUserGroups();
var apps = this.Select(x => x.GetContentAppFor(o, roles)).WhereNotNull().OrderBy(x => x.Weight).ToList();
var apps = Enumerable.Empty<ContentApp>();// this.Select(x => x.GetContentAppFor(o, roles)).WhereNotNull().OrderBy(x => x.Weight).ToList();
var aliases = new HashSet<string>();
List<string> dups = null;

View File

@@ -5,14 +5,16 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Services;
namespace Umbraco.Web.ContentApps
{
public class ContentAppDefinitionCollectionBuilder : OrderedCollectionBuilderBase<ContentAppDefinitionCollectionBuilder, ContentAppDefinitionCollection, IContentAppDefinition>
public class ContentAppDefinitionCollectionBuilder : OrderedCollectionBuilderBase<ContentAppDefinitionCollectionBuilder, ContentAppDefinitionCollection, IContentAppFactory>
{
public ContentAppDefinitionCollectionBuilder(IServiceContainer container)
: base(container)
{ }
{
}
protected override ContentAppDefinitionCollectionBuilder This => this;
@@ -25,14 +27,14 @@ namespace Umbraco.Web.ContentApps
return new ContentAppDefinitionCollection(CreateItems(), logger);
}
protected override IEnumerable<IContentAppDefinition> CreateItems(params object[] args)
protected override IEnumerable<IContentAppFactory> CreateItems(params object[] args)
{
// 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
// its dependencies too, and that can create cycles or other oddities
var manifestParser = Container.GetInstance<ManifestParser>();
return base.CreateItems(args).Concat(manifestParser.Manifest.ContentApps);
return base.CreateItems(args).Concat(manifestParser.Manifest.ContentApps.Select(x=>new ManifestContentAppFactory(x)));
}
}
}

View File

@@ -6,7 +6,7 @@ using Umbraco.Core.Models.Membership;
namespace Umbraco.Web.ContentApps
{
internal class ContentEditorContentAppDefinition : IContentAppDefinition
internal class ContentEditorContentAppFactory : IContentAppFactory
{
// see note on ContentApp
private const int Weight = -100;

View File

@@ -6,7 +6,7 @@ using Umbraco.Core.Models.Membership;
namespace Umbraco.Web.ContentApps
{
public class ContentInfoContentAppDefinition : IContentAppDefinition
public class ContentInfoContentAppFactory : IContentAppFactory
{
// see note on ContentApp
private const int Weight = +100;

View File

@@ -9,7 +9,7 @@ using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.ContentApps
{
internal class ListViewContentAppDefinition : IContentAppDefinition
internal class ListViewContentAppFactory : IContentAppFactory
{
// see note on ContentApp
private const int Weight = -666;
@@ -17,7 +17,7 @@ namespace Umbraco.Web.ContentApps
private readonly IDataTypeService _dataTypeService;
private readonly PropertyEditorCollection _propertyEditors;
public ListViewContentAppDefinition(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditors)
public ListViewContentAppFactory(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditors)
{
_dataTypeService = dataTypeService;
_propertyEditors = propertyEditors;

View File

@@ -234,7 +234,7 @@ namespace Umbraco.Web.Editors
public ContentItemDisplay GetRecycleBin()
{
var apps = new List<ContentApp>();
apps.Add(ListViewContentAppDefinition.CreateContentApp(Services.DataTypeService, _propertyEditors, "recycleBin", "content", Core.Constants.DataTypes.DefaultMembersListView));
apps.Add(ListViewContentAppFactory.CreateContentApp(Services.DataTypeService, _propertyEditors, "recycleBin", "content", Core.Constants.DataTypes.DefaultMembersListView));
apps[0].Active = true;
var display = new ContentItemDisplay
{

View File

@@ -99,7 +99,7 @@ namespace Umbraco.Web.Editors
public MediaItemDisplay GetRecycleBin()
{
var apps = new List<ContentApp>();
apps.Add(ListViewContentAppDefinition.CreateContentApp(Services.DataTypeService, _propertyEditors, "recycleBin", "media", Core.Constants.DataTypes.DefaultMediaListView));
apps.Add(ListViewContentAppFactory.CreateContentApp(Services.DataTypeService, _propertyEditors, "recycleBin", "media", Core.Constants.DataTypes.DefaultMediaListView));
apps[0].Active = true;
var display = new MediaItemDisplay
{

View File

@@ -139,7 +139,7 @@ namespace Umbraco.Web.Editors
var name = foundType != null ? foundType.Name : listName;
var apps = new List<ContentApp>();
apps.Add(ListViewContentAppDefinition.CreateContentApp(Services.DataTypeService, _propertyEditors, listName, "member", Core.Constants.DataTypes.DefaultMembersListView));
apps.Add(ListViewContentAppFactory.CreateContentApp(Services.DataTypeService, _propertyEditors, listName, "member", Core.Constants.DataTypes.DefaultMembersListView));
apps[0].Active = true;
var display = new MemberListDisplay

View File

@@ -207,9 +207,9 @@ namespace Umbraco.Web.Runtime
// register known content apps
composition.Container.RegisterCollectionBuilder<ContentAppDefinitionCollectionBuilder>()
.Append<ListViewContentAppDefinition>()
.Append<ContentEditorContentAppDefinition>()
.Append<ContentInfoContentAppDefinition>();
.Append<ListViewContentAppFactory>()
.Append<ContentEditorContentAppFactory>()
.Append<ContentInfoContentAppFactory>();
}
internal void Initialize(

View File

@@ -110,6 +110,7 @@
<Compile Include="Cache\ContentCacheRefresher.cs" />
<Compile Include="Cache\UserGroupCacheRefresher.cs" />
<Compile Include="Components\BackOfficeUserAuditEventsComponent.cs" />
<Compile Include="ContentApps\ListViewContentAppFactory.cs" />
<Compile Include="Editors\BackOfficePreviewModel.cs" />
<Compile Include="Logging\WebProfiler.cs" />
<Compile Include="Logging\WebProfilerComponent.cs" />
@@ -155,9 +156,8 @@
<Compile Include="Models\Mapping\MappingOperationOptionsExtensions.cs" />
<Compile Include="ContentApps\ContentAppDefinitionCollection.cs" />
<Compile Include="ContentApps\ContentAppDefinitionCollectionBuilder.cs" />
<Compile Include="ContentApps\ContentEditorContentAppDefinition.cs" />
<Compile Include="ContentApps\ContentInfoContentAppDefinition.cs" />
<Compile Include="ContentApps\ListViewContentAppDefinition.cs" />
<Compile Include="ContentApps\ContentEditorContentAppFactory.cs" />
<Compile Include="ContentApps\ContentInfoContentAppFactory.cs" />
<Compile Include="Models\Mapping\ScheduledPublishDateResolver.cs" />
<Compile Include="Security\ActiveDirectoryBackOfficeUserPasswordChecker.cs" />
<Compile Include="Security\BackOfficeClaimsIdentityFactory.cs" />