AB3649 - Moved Manifest stuff
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
{
|
||||
@@ -65,11 +63,7 @@ namespace Umbraco.Core.Manifest
|
||||
/// Gets or sets the view for rendering the content app.
|
||||
/// </summary>
|
||||
[DataMember(Name = "view")]
|
||||
public string View
|
||||
{
|
||||
get => _view;
|
||||
set => _view = Current.IOHelper.ResolveVirtualUrl(value);
|
||||
}
|
||||
public string View { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of 'show' conditions for the content app.
|
||||
@@ -0,0 +1,9 @@
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
public class ManifestValueValidatorCollectionBuilder : LazyCollectionBuilderBase<ManifestValueValidatorCollectionBuilder, ManifestValueValidatorCollection, IManifestValueValidator>
|
||||
{
|
||||
protected override ManifestValueValidatorCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <summary>
|
||||
/// A validator that validates that the value is a valid decimal
|
||||
/// </summary>
|
||||
internal sealed class DecimalValidator : IManifestValueValidator
|
||||
public sealed class DecimalValidator : IManifestValueValidator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ValidationName => "Decimal";
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <summary>
|
||||
/// A validator that validates an email address
|
||||
/// </summary>
|
||||
internal sealed class EmailValidator : IManifestValueValidator
|
||||
public sealed class EmailValidator : IManifestValueValidator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ValidationName => "Email";
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <summary>
|
||||
/// A validator that validates that the value is a valid integer
|
||||
/// </summary>
|
||||
internal sealed class IntegerValidator : IManifestValueValidator
|
||||
public sealed class IntegerValidator : IManifestValueValidator
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ValidationName => "Integer";
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.6.0" />
|
||||
<PackageReference Include="System.Runtime.Caching" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -31,10 +32,12 @@ namespace Umbraco.Core.Manifest
|
||||
public class ManifestContentAppFactory : IContentAppFactory
|
||||
{
|
||||
private readonly ManifestContentAppDefinition _definition;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
|
||||
public ManifestContentAppFactory(ManifestContentAppDefinition definition)
|
||||
public ManifestContentAppFactory(ManifestContentAppDefinition definition, IIOHelper ioHelper)
|
||||
{
|
||||
_definition = definition;
|
||||
_ioHelper = ioHelper;
|
||||
}
|
||||
|
||||
private ContentApp _app;
|
||||
@@ -132,7 +135,7 @@ namespace Umbraco.Core.Manifest
|
||||
Alias = _definition.Alias,
|
||||
Name = _definition.Name,
|
||||
Icon = _definition.Icon,
|
||||
View = _definition.View,
|
||||
View = _ioHelper.ResolveVirtualUrl(_definition.View),
|
||||
Weight = _definition.Weight
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -22,6 +21,7 @@ namespace Umbraco.Core.Manifest
|
||||
|
||||
private readonly IAppPolicyCache _cache;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly ManifestValueValidatorCollection _validators;
|
||||
private readonly ManifestFilterCollection _filters;
|
||||
|
||||
@@ -30,28 +30,31 @@ namespace Umbraco.Core.Manifest
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManifestParser"/> class.
|
||||
/// </summary>
|
||||
public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, ILogger logger)
|
||||
: this(appCaches, validators, filters, "~/App_Plugins", logger)
|
||||
public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, ILogger logger, IIOHelper ioHelper)
|
||||
: this(appCaches, validators, filters, "~/App_Plugins", logger, ioHelper)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManifestParser"/> class.
|
||||
/// </summary>
|
||||
private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, string path, ILogger logger)
|
||||
private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, string path, ILogger logger, IIOHelper ioHelper)
|
||||
{
|
||||
if (appCaches == null) throw new ArgumentNullException(nameof(appCaches));
|
||||
_cache = appCaches.RuntimeCache;
|
||||
_ioHelper = ioHelper;
|
||||
_validators = validators ?? throw new ArgumentNullException(nameof(validators));
|
||||
_filters = filters ?? throw new ArgumentNullException(nameof(filters));
|
||||
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullOrEmptyException(nameof(path));
|
||||
|
||||
Path = path;
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get => _path;
|
||||
set => _path = value.StartsWith("~/") ? Current.IOHelper.MapPath(value) : value;
|
||||
set => _path = value.StartsWith("~/") ? _ioHelper.MapPath(value) : value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,9 +169,9 @@ namespace Umbraco.Core.Manifest
|
||||
|
||||
// scripts and stylesheets are raw string, must process here
|
||||
for (var i = 0; i < manifest.Scripts.Length; i++)
|
||||
manifest.Scripts[i] = Current.IOHelper.ResolveVirtualUrl(manifest.Scripts[i]);
|
||||
manifest.Scripts[i] = _ioHelper.ResolveVirtualUrl(manifest.Scripts[i]);
|
||||
for (var i = 0; i < manifest.Stylesheets.Length; i++)
|
||||
manifest.Stylesheets[i] = Current.IOHelper.ResolveVirtualUrl(manifest.Stylesheets[i]);
|
||||
manifest.Stylesheets[i] = _ioHelper.ResolveVirtualUrl(manifest.Stylesheets[i]);
|
||||
|
||||
// add property editors that are also parameter editors, to the parameter editors list
|
||||
// (the manifest format is kinda legacy)
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
{
|
||||
internal class ManifestValueValidatorCollectionBuilder : LazyCollectionBuilderBase<ManifestValueValidatorCollectionBuilder, ManifestValueValidatorCollection, IManifestValueValidator>
|
||||
{
|
||||
protected override ManifestValueValidatorCollectionBuilder This => this;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <summary>
|
||||
/// A validator that validates that the value against a regular expression.
|
||||
/// </summary>
|
||||
internal sealed class RegexValidator : IValueFormatValidator, IManifestValueValidator
|
||||
public sealed class RegexValidator : IValueFormatValidator, IManifestValueValidator
|
||||
{
|
||||
private readonly ILocalizedTextService _textService;
|
||||
private string _regex;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Core.PropertyEditors.Validators
|
||||
/// <summary>
|
||||
/// A validator that validates that the value is not null or empty (if it is a string)
|
||||
/// </summary>
|
||||
internal sealed class RequiredValidator : IValueRequiredValidator, IManifestValueValidator
|
||||
public sealed class RequiredValidator : IValueRequiredValidator, IManifestValueValidator
|
||||
{
|
||||
private readonly ILocalizedTextService _textService;
|
||||
|
||||
|
||||
@@ -193,6 +193,7 @@
|
||||
<Compile Include="Manifest\IManifestFilter.cs" />
|
||||
<Compile Include="Manifest\ManifestFilterCollection.cs" />
|
||||
<Compile Include="Manifest\ManifestFilterCollectionBuilder.cs" />
|
||||
<Compile Include="Manifest\ManifestParser.cs" />
|
||||
<Compile Include="Migrations\IMigrationBuilder.cs" />
|
||||
<Compile Include="Migrations\Upgrade\Common\DeleteKeysAndIndexes.cs" />
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\DataTypes\ContentPickerPreValueMigrator.cs" />
|
||||
@@ -271,6 +272,9 @@
|
||||
<Compile Include="Models\PublishedContent\IPublishedPropertyType.cs" />
|
||||
<Compile Include="PropertyEditors\ConfigurationFieldsExtensions.cs" />
|
||||
<Compile Include="PropertyEditors\IIgnoreUserStartNodesConfig.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\DelimitedValueValidator.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\RegexValidator.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\RequiredValidator.cs" />
|
||||
<Compile Include="PublishedContentExtensions.cs" />
|
||||
<Compile Include="Models\PublishedContent\UrlMode.cs" />
|
||||
<Compile Include="Persistence\Dtos\PropertyTypeCommonDto.cs" />
|
||||
@@ -285,7 +289,6 @@
|
||||
<Compile Include="Migrations\Upgrade\V_8_0_0\RenameLabelAndRichTextPropertyEditorAliases.cs" />
|
||||
<Compile Include="PropertyEditors\IDataEditor.cs" />
|
||||
<Compile Include="PropertyEditors\IPropertyIndexValueFactory.cs" />
|
||||
<Compile Include="PropertyEditors\IValueValidator.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyValueConverterCollection.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyValueConverterCollectionBuilder.cs" />
|
||||
<Compile Include="PropertyEditors\VoidEditor.cs" />
|
||||
@@ -390,7 +393,6 @@
|
||||
<Compile Include="Logging\Viewer\MessageTemplateFilter.cs" />
|
||||
<Compile Include="Logging\Viewer\SavedLogSearch.cs" />
|
||||
<Compile Include="Manifest\DashboardAccessRuleConverter.cs" />
|
||||
<Compile Include="Manifest\ManifestContentAppDefinition.cs" />
|
||||
<Compile Include="Manifest\ManifestContentAppFactory.cs" />
|
||||
<Compile Include="Manifest\ManifestDashboard.cs" />
|
||||
<Compile Include="Migrations\MergeBuilder.cs" />
|
||||
@@ -483,9 +485,6 @@
|
||||
<Compile Include="PropertyEditors\DropDownFlexibleConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\IConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\ImageCropperConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\IManifestValueValidator.cs" />
|
||||
<Compile Include="PropertyEditors\IValueFormatValidator.cs" />
|
||||
<Compile Include="PropertyEditors\IValueRequiredValidator.cs" />
|
||||
<Compile Include="PropertyEditors\LabelConfiguration.cs" />
|
||||
<Compile Include="PropertyEditors\LabelConfigurationEditor.cs" />
|
||||
<Compile Include="PropertyEditors\LabelPropertyEditor.cs" />
|
||||
@@ -560,7 +559,6 @@
|
||||
<Compile Include="Logging\OwinLoggerFactory.cs" />
|
||||
<Compile Include="Logging\VoidProfiler.cs" />
|
||||
<Compile Include="MainDom.cs" />
|
||||
<Compile Include="Manifest\ManifestParser.cs" />
|
||||
<Compile Include="Manifest\ValueValidatorConverter.cs" />
|
||||
<Compile Include="Manifest\ManifestWatcher.cs" />
|
||||
<Compile Include="Manifest\PackageManifest.cs" />
|
||||
@@ -582,7 +580,6 @@
|
||||
<Compile Include="Models\DictionaryItem.cs" />
|
||||
<Compile Include="Models\DictionaryItemExtensions.cs" />
|
||||
<Compile Include="Models\DictionaryTranslation.cs" />
|
||||
<Compile Include="Models\EntityContainer.cs" />
|
||||
<Compile Include="Models\EntityExtensions.cs" />
|
||||
<Compile Include="Models\GridValue.cs" />
|
||||
<Compile Include="Models\Identity\BackOfficeIdentityUser.cs" />
|
||||
@@ -1002,22 +999,14 @@
|
||||
<Compile Include="Persistence\UmbracoDatabaseExtensions.cs" />
|
||||
<Compile Include="Persistence\UmbracoDatabaseFactory.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\DecimalValidator.cs" />
|
||||
<Compile Include="PropertyEditors\DefaultPropertyValueConverterAttribute.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\DelimitedValueValidator.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\EmailValidator.cs" />
|
||||
<Compile Include="PropertyEditors\GridEditor.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\IntegerValidator.cs" />
|
||||
<Compile Include="PropertyEditors\IPropertyValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\DataEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DataEditorCollection.cs" />
|
||||
<Compile Include="PropertyEditors\DataEditorCollectionBuilder.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyValueConverterBase.cs" />
|
||||
<Compile Include="PropertyEditors\DataValueEditor.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\RegexValidator.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\RequiredValidator.cs" />
|
||||
<Compile Include="PropertyEditors\ManifestValueValidatorCollection.cs" />
|
||||
<Compile Include="PropertyEditors\ManifestValueValidatorCollectionBuilder.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\CheckboxListValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\ColorPickerValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\DatePickerValueConverter.cs" />
|
||||
|
||||
@@ -6,6 +6,7 @@ using NUnit.Framework;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
namespace Umbraco.Tests.Manifest
|
||||
{
|
||||
@@ -67,7 +68,7 @@ namespace Umbraco.Tests.Manifest
|
||||
private void AssertDefinition(object source, bool expected, string[] show, IReadOnlyUserGroup[] groups)
|
||||
{
|
||||
var definition = JsonConvert.DeserializeObject<ManifestContentAppDefinition>("{" + (show.Length == 0 ? "" : " \"show\": [" + string.Join(",", show.Select(x => "\"" + x + "\"")) + "] ") + "}");
|
||||
var factory = new ManifestContentAppFactory(definition);
|
||||
var factory = new ManifestContentAppFactory(definition, Current.IOHelper);
|
||||
var app = factory.GetContentAppFor(source, groups);
|
||||
if (expected)
|
||||
Assert.IsNotNull(app);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Umbraco.Tests.Manifest
|
||||
new RequiredValidator(Mock.Of<ILocalizedTextService>()),
|
||||
new RegexValidator(Mock.Of<ILocalizedTextService>(), null)
|
||||
};
|
||||
_parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), new ManifestFilterCollection(Array.Empty<IManifestFilter>()), Mock.Of<ILogger>());
|
||||
_parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), new ManifestFilterCollection(Array.Empty<IManifestFilter>()), Mock.Of<ILogger>(), Current.IOHelper);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Core.Models.ContentEditing;
|
||||
@@ -28,7 +29,7 @@ namespace Umbraco.Web.ContentApps
|
||||
// its dependencies too, and that can create cycles or other oddities
|
||||
var manifestParser = factory.GetInstance<ManifestParser>();
|
||||
|
||||
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x)));
|
||||
return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x, Current.IOHelper)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user