Fixes tests and merging issues, simplifies TabsAndPropertiesResolver since it doesn't need umbracocontext, only the MemberTabsAndPropertiesResolver one does
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
{
|
||||
internal class ContentElement : UmbracoConfigurationElement, IContentSection
|
||||
{
|
||||
private const string DefaultPreviewBadge = @"<a id=""umbracoPreviewBadge"" style=""z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;"" href=""{0}/endPreview.aspx?redir={1}""><span style=""display:none;"">In Preview Mode - click to end</span></a>";
|
||||
private const string DefaultPreviewBadge = @"<a id=""umbracoPreviewBadge"" style=""z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;"" href=""#"" OnClick=""javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'""><span style=""display:none;"">In Preview Mode - click to end</span></a>";
|
||||
|
||||
[ConfigurationProperty("imaging")]
|
||||
internal ContentImagingElement Imaging => (ContentImagingElement) this["imaging"];
|
||||
|
||||
@@ -16,28 +16,28 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void EmailAddress()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.NotificationEmailAddress == "robot@umbraco.dk");
|
||||
Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk");
|
||||
}
|
||||
[Test]
|
||||
public virtual void DisableHtmlEmail()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == true);
|
||||
Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public virtual void Can_Set_Multiple()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 3);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == "default");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1047);
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3);
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).Culture == "en-US");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath == "$site/error [@name = 'error']");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey);
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).Culture == "en-UK");
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey == new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK");
|
||||
Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
|
||||
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey);
|
||||
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void ScriptFolderPath()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ScriptFolderPath == "/scripts");
|
||||
Assert.AreEqual(SettingsSection.Content.ScriptFolderPath, "/scripts");
|
||||
}
|
||||
[Test]
|
||||
public void ScriptFileTypes()
|
||||
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void DisableScriptEditor()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ScriptEditorDisable == false);
|
||||
Assert.AreEqual(SettingsSection.Content.ScriptEditorDisable, false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -71,80 +71,79 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public virtual void ImageAutoFillProperties()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 2);
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias == "umbracoFile2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias == "umbracoWidth2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias == "umbracoHeight2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias == "umbracoBytes2");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias == "umbracoExtension2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2);
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
|
||||
Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UploadAllowDirectories()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories == true);
|
||||
Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories);
|
||||
}
|
||||
[Test]
|
||||
public void DefaultDocumentTypeProperty()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.DefaultDocumentTypeProperty == "Textstring");
|
||||
Assert.AreEqual(SettingsSection.Content.DefaultDocumentTypeProperty, "Textstring");
|
||||
}
|
||||
[Test]
|
||||
public void GlobalPreviewStorageEnabled()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.GlobalPreviewStorageEnabled == false);
|
||||
Assert.IsFalse(SettingsSection.Content.GlobalPreviewStorageEnabled);
|
||||
}
|
||||
[Test]
|
||||
public void CloneXmlContent()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.CloneXmlContent == true);
|
||||
Assert.IsTrue(SettingsSection.Content.CloneXmlContent);
|
||||
}
|
||||
[Test]
|
||||
public void EnsureUniqueNaming()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming == true);
|
||||
Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void ForceSafeAliases()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ForceSafeAliases == true);
|
||||
Assert.IsTrue(SettingsSection.Content.ForceSafeAliases);
|
||||
}
|
||||
[Test]
|
||||
public void XmlCacheEnabled()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled == true);
|
||||
Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled);
|
||||
}
|
||||
[Test]
|
||||
public void ContinouslyUpdateXmlDiskCache()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache == true);
|
||||
Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache);
|
||||
}
|
||||
[Test]
|
||||
public virtual void XmlContentCheckForDiskChanges()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges == true);
|
||||
Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges);
|
||||
}
|
||||
[Test]
|
||||
public void EnableSplashWhileLoading()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.EnableSplashWhileLoading == false);
|
||||
Assert.IsFalse(SettingsSection.Content.EnableSplashWhileLoading);
|
||||
}
|
||||
[Test]
|
||||
public void PropertyContextHelpOption()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.PropertyContextHelpOption == "text");
|
||||
Assert.AreEqual(SettingsSection.Content.PropertyContextHelpOption, "text");
|
||||
}
|
||||
[Test]
|
||||
public void PreviewBadge()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.PreviewBadge == @"<a id=""umbracoPreviewBadge"" style=""z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;"" href=""{0}/endPreview.aspx?redir={2}""><span style=""display:none;"">In Preview Mode - click to end</span></a>");
|
||||
Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"<a id=""umbracoPreviewBadge"" style=""z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;"" href=""#"" OnClick=""javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'""><span style=""display:none;"">In Preview Mode - click to end</span></a>");
|
||||
}
|
||||
[Test]
|
||||
public void ResolveUrlsFromTextString()
|
||||
@@ -154,7 +153,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
[Test]
|
||||
public void MacroErrors()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.MacroErrorBehaviour == MacroErrorBehaviour.Inline);
|
||||
Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -75,7 +75,10 @@
|
||||
|
||||
<ForceSafeAliases>true</ForceSafeAliases>
|
||||
|
||||
<PreviewBadge><![CDATA[<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;" href="{0}/endPreview.aspx?redir={2}"><span style="display:none;">In Preview Mode - click to end</span></a>]]></PreviewBadge>
|
||||
<PreviewBadge>
|
||||
<![CDATA[
|
||||
<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'"><span style="display:none;">In Preview Mode - click to end</span></a>
|
||||
]]></PreviewBadge>
|
||||
|
||||
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
|
||||
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
|
||||
|
||||
@@ -38,6 +38,7 @@ using Umbraco.Tests.Testing.Objects.Accessors;
|
||||
using Umbraco.Web.Composing.CompositionRoots;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Current = Umbraco.Core.Composing.Current;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.Testing
|
||||
{
|
||||
@@ -136,6 +137,7 @@ namespace Umbraco.Tests.Testing
|
||||
ComposeApplication(Options.WithApplication);
|
||||
|
||||
// etc
|
||||
ComposeWeb();
|
||||
ComposeWtf();
|
||||
|
||||
// not sure really
|
||||
@@ -172,11 +174,22 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterSingleton(f => new ProfilingLogger(f.GetInstance<ILogger>(), f.GetInstance<IProfiler>()));
|
||||
}
|
||||
|
||||
protected virtual void ComposeWtf()
|
||||
protected virtual void ComposeWeb()
|
||||
{
|
||||
//TODO: Should we 'just' register the WebRuntimeComponent?
|
||||
|
||||
// imported from TestWithSettingsBase
|
||||
// which was inherited by TestWithApplicationBase so pretty much used everywhere
|
||||
Umbraco.Web.Composing.Current.UmbracoContextAccessor = new TestUmbracoContextAccessor();
|
||||
Container.Register(_ => Umbraco.Web.Composing.Current.UmbracoContextAccessor);
|
||||
Container.RegisterSingleton<PublishedRouter>();
|
||||
Container.RegisterCollectionBuilder<ContentFinderCollectionBuilder>();
|
||||
Container.Register<IContentLastChanceFinder, TestLastChanceFinder>();
|
||||
Container.Register<IVariationContextAccessor, TestVariationContextAccessor>();
|
||||
}
|
||||
|
||||
protected virtual void ComposeWtf()
|
||||
{
|
||||
|
||||
// what else?
|
||||
var runtimeStateMock = new Mock<IRuntimeState>();
|
||||
@@ -270,6 +283,7 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterSingleton(factory => globalSettings);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.Content);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.Templates);
|
||||
Container.RegisterSingleton(factory => umbracoSettings.WebRouting);
|
||||
Container.Register(factory => new MediaFileSystem(Mock.Of<IFileSystem>()));
|
||||
Container.RegisterSingleton<IExamineManager>(factory => ExamineManager.Instance);
|
||||
|
||||
@@ -322,6 +336,8 @@ namespace Umbraco.Tests.Testing
|
||||
Container.RegisterCollectionBuilder<DataEditorCollectionBuilder>();
|
||||
Container.RegisterSingleton<PropertyEditorCollection>();
|
||||
Container.RegisterSingleton<ParameterEditorCollection>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
|
||||
<!-- The html injected into a (x)html page if Umbraco is running in preview mode -->
|
||||
<PreviewBadge>
|
||||
<![CDATA[<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;z-index: 9999999;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={2}'"><span style="display:none;">In Preview Mode - click to end</span></a>]]></PreviewBadge>
|
||||
<![CDATA[
|
||||
<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'"><span style="display:none;">In Preview Mode - click to end</span></a>
|
||||
]]></PreviewBadge>
|
||||
|
||||
<!-- How Umbraco should handle errors during macro execution. Can be one of the following values:
|
||||
- inline - show an inline error within the macro but allow the page to continue rendering. Historial Umbraco behaviour.
|
||||
|
||||
@@ -75,7 +75,8 @@
|
||||
|
||||
<!-- The html injected into a (x)html page if Umbraco is running in preview mode -->
|
||||
<PreviewBadge>
|
||||
<![CDATA[<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{1}/preview/previewModeBadge.png') no-repeat;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={2}'"><span style="display:none;">In Preview Mode - click to end</span></a>
|
||||
<![CDATA[
|
||||
<a id="umbracoPreviewBadge" style="z-index:99999; position: absolute; top: 0; right: 0; border: 0; width: 149px; height: 149px; background: url('{0}/assets/img/preview-mode-badge.png') no-repeat;" href="#" OnClick="javascript:window.top.location.href = '{0}/endPreview.aspx?redir={1}'"><span style="display:none;">In Preview Mode - click to end</span></a>
|
||||
]]></PreviewBadge>
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
using AutoMapper;
|
||||
@@ -28,7 +29,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public MemberTabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IMemberService memberService, IUserService userService)
|
||||
: base(umbracoContextAccessor, localizedTextService)
|
||||
: base(localizedTextService)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_localizedTextService = localizedTextService ?? throw new System.ArgumentNullException(nameof(localizedTextService));
|
||||
@@ -37,7 +38,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
}
|
||||
|
||||
public MemberTabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IEnumerable<string> ignoreProperties, IMemberService memberService, IUserService userService)
|
||||
: base(umbracoContextAccessor, localizedTextService, ignoreProperties)
|
||||
: base(localizedTextService, ignoreProperties)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_localizedTextService = localizedTextService ?? throw new System.ArgumentNullException(nameof(localizedTextService));
|
||||
@@ -169,24 +170,25 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <summary>
|
||||
/// Overridden to assign the IsSensitive property values
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
protected override List<ContentPropertyDisplay> MapProperties(UmbracoContext umbracoContext, IContentBase content, List<Property> properties, ResolutionContext context)
|
||||
protected override List<ContentPropertyDisplay> MapProperties(IContentBase content, List<Property> properties, ResolutionContext context)
|
||||
{
|
||||
var result = base.MapProperties(umbracoContext, content, properties, context);
|
||||
var result = base.MapProperties(content, properties, context);
|
||||
var member = (IMember)content;
|
||||
var memberType = member.ContentType;
|
||||
|
||||
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
|
||||
|
||||
//now update the IsSensitive value
|
||||
foreach (var prop in result)
|
||||
{
|
||||
//check if this property is flagged as sensitive
|
||||
var isSensitiveProperty = memberType.IsSensitiveProperty(prop.Alias);
|
||||
//check permissions for viewing sensitive data
|
||||
if (isSensitiveProperty && umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false)
|
||||
if (isSensitiveProperty && (umbracoContext == null || umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false))
|
||||
{
|
||||
//mark this property as sensitive
|
||||
prop.IsSensitive = true;
|
||||
|
||||
@@ -164,7 +164,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <summary>
|
||||
/// Maps properties on to the generic properties tab
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="tabs"></param>
|
||||
/// <param name="context"></param>
|
||||
@@ -172,14 +171,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// The generic properties tab is responsible for
|
||||
/// setting up the properties such as Created date, updated date, template selected, etc...
|
||||
/// </remarks>
|
||||
protected virtual void MapGenericProperties(UmbracoContext umbracoContext, IContentBase content, List<Tab<ContentPropertyDisplay>> tabs, ResolutionContext context)
|
||||
protected virtual void MapGenericProperties(IContentBase content, List<Tab<ContentPropertyDisplay>> tabs, ResolutionContext context)
|
||||
{
|
||||
// add the generic properties tab, for properties that don't belong to a tab
|
||||
// get the properties, map and translate them, then add the tab
|
||||
var noGroupProperties = content.GetNonGroupedProperties()
|
||||
.Where(x => IgnoreProperties.Contains(x.Alias) == false) // skip ignored
|
||||
.ToList();
|
||||
var genericproperties = MapProperties(umbracoContext, content, noGroupProperties, context);
|
||||
var genericproperties = MapProperties(content, noGroupProperties, context);
|
||||
|
||||
tabs.Add(new Tab<ContentPropertyDisplay>
|
||||
{
|
||||
@@ -225,12 +224,11 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// <summary>
|
||||
/// Maps a list of <see cref="Property"/> to a list of <see cref="ContentPropertyDisplay"/>
|
||||
/// </summary>
|
||||
/// <param name="umbracoContext"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual List<ContentPropertyDisplay> MapProperties(UmbracoContext umbracoContext, IContentBase content, List<Property> properties, ResolutionContext context)
|
||||
protected virtual List<ContentPropertyDisplay> MapProperties(IContentBase content, List<Property> properties, ResolutionContext context)
|
||||
{
|
||||
//we need to map this way to pass the context through, I don't like it but we'll see what AutoMapper says: https://github.com/AutoMapper/AutoMapper/issues/2588
|
||||
var result = context.Mapper.Map<IEnumerable<Property>, IEnumerable<ContentPropertyDisplay>>(
|
||||
@@ -250,25 +248,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
internal class TabsAndPropertiesResolver<TSource, TDestination> : TabsAndPropertiesResolver, IValueResolver<TSource, TDestination, IEnumerable<Tab<ContentPropertyDisplay>>>
|
||||
where TSource : IContentBase
|
||||
{
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
|
||||
public TabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService)
|
||||
public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService)
|
||||
: base(localizedTextService)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
}
|
||||
|
||||
public TabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IEnumerable<string> ignoreProperties)
|
||||
public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService, IEnumerable<string> ignoreProperties)
|
||||
: base(localizedTextService, ignoreProperties)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
}
|
||||
|
||||
public virtual IEnumerable<Tab<ContentPropertyDisplay>> Resolve(TSource source, TDestination destination, IEnumerable<Tab<ContentPropertyDisplay>> destMember, ResolutionContext context)
|
||||
{
|
||||
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
|
||||
if (umbracoContext == null) throw new InvalidOperationException("Cannot resolve value without an UmbracoContext available");
|
||||
|
||||
var tabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
|
||||
// add the tabs, for properties that belong to a tab
|
||||
@@ -293,7 +284,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
continue;
|
||||
|
||||
//map the properties
|
||||
var mappedProperties = MapProperties(umbracoContext, source, properties, context);
|
||||
var mappedProperties = MapProperties(source, properties, context);
|
||||
|
||||
// add the tab
|
||||
// we need to pick an identifier... there is no "right" way...
|
||||
@@ -311,7 +302,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
});
|
||||
}
|
||||
|
||||
MapGenericProperties(umbracoContext, source, tabs, context);
|
||||
MapGenericProperties(source, tabs, context);
|
||||
|
||||
// activate the first tab, if any
|
||||
if (tabs.Count > 0)
|
||||
|
||||
Reference in New Issue
Block a user