Merge remote-tracking branch 'origin/v10/dev' into v11/dev

# Conflicts:
#	src/JsonSchema/AppSettings.cs
This commit is contained in:
Bjarke Berg
2023-08-09 15:27:01 +02:00
9 changed files with 117 additions and 18 deletions

View File

@@ -0,0 +1,18 @@
using System.ComponentModel;
namespace Umbraco.Cms.Core.Configuration.Models;
/// <summary>
/// Typed configuration options for index creator settings.
/// </summary>
[UmbracoOptions(Constants.Configuration.ConfigIndexing)]
public class IndexingSettings
{
private const bool StaticExplicitlyIndexEachNestedProperty = true;
/// <summary>
/// Gets or sets a value for whether each nested property should have it's own indexed value. Requires a rebuild of indexes when changed.
/// </summary>
[DefaultValue(StaticExplicitlyIndexEachNestedProperty)]
public bool ExplicitlyIndexEachNestedProperty { get; set; } = StaticExplicitlyIndexEachNestedProperty;
}

View File

@@ -38,6 +38,7 @@ public static partial class Constants
public const string ConfigHosting = ConfigPrefix + "Hosting";
public const string ConfigImaging = ConfigPrefix + "Imaging";
public const string ConfigExamine = ConfigPrefix + "Examine";
public const string ConfigIndexing = ConfigPrefix + "Indexing";
public const string ConfigKeepAlive = ConfigPrefix + "KeepAlive";
public const string ConfigLogging = ConfigPrefix + "Logging";
public const string ConfigMemberPassword = ConfigPrefix + "Security:MemberPassword";

View File

@@ -50,6 +50,7 @@ public static partial class UmbracoBuilderExtensions
builder
.AddUmbracoOptions<ModelsBuilderSettings>()
.AddUmbracoOptions<ActiveDirectorySettings>()
.AddUmbracoOptions<IndexCreatorSettings>()
.AddUmbracoOptions<MarketplaceSettings>()
.AddUmbracoOptions<ContentSettings>()
.AddUmbracoOptions<CoreDebugSettings>()
@@ -64,7 +65,7 @@ public static partial class UmbracoBuilderExtensions
.AddUmbracoOptions<HealthChecksSettings>()
.AddUmbracoOptions<HostingSettings>()
.AddUmbracoOptions<ImagingSettings>()
.AddUmbracoOptions<IndexCreatorSettings>()
.AddUmbracoOptions<IndexingSettings>()
.AddUmbracoOptions<KeepAliveSettings>()
.AddUmbracoOptions<LoggingSettings>()
.AddUmbracoOptions<MemberPasswordConfigurationSettings>()

View File

@@ -1,5 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.PropertyEditors;
@@ -11,13 +15,28 @@ namespace Umbraco.Cms.Core.PropertyEditors;
public abstract class JsonPropertyIndexValueFactoryBase<TSerialized> : IPropertyIndexValueFactory
{
private readonly IJsonSerializer _jsonSerializer;
private IndexingSettings _indexingSettings;
protected bool ForceExplicitlyIndexEachNestedProperty { get; set; }
/// <summary>
/// Constructor for the JsonPropertyIndexValueFactoryBase.
/// </summary>
protected JsonPropertyIndexValueFactoryBase(IJsonSerializer jsonSerializer)
protected JsonPropertyIndexValueFactoryBase(IJsonSerializer jsonSerializer, IOptionsMonitor<IndexingSettings> indexingSettings)
{
_jsonSerializer = jsonSerializer;
_indexingSettings = indexingSettings.CurrentValue;
indexingSettings.OnChange(newValue => _indexingSettings = newValue);
}
/// <summary>
/// Constructor for the JsonPropertyIndexValueFactoryBase.
/// </summary>
[Obsolete("Use non-obsolete constructor. This will be removed in Umbraco 14.")]
protected JsonPropertyIndexValueFactoryBase(IJsonSerializer jsonSerializer): this(jsonSerializer, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
}
/// <inheritdoc />
@@ -58,9 +77,14 @@ public abstract class JsonPropertyIndexValueFactoryBase<TSerialized> : IProperty
}
}
result.AddRange(HandleResume(result, property, culture, segment, published));
IEnumerable<KeyValuePair<string, IEnumerable<object?>>> summary = HandleResume(result, property, culture, segment, published);
if (_indexingSettings.ExplicitlyIndexEachNestedProperty || ForceExplicitlyIndexEachNestedProperty)
{
result.AddRange(summary);
return result;
}
return result;
return summary;
}
[Obsolete("Use method overload that has availableCultures, scheduled for removal in v14")]
@@ -68,7 +92,7 @@ public abstract class JsonPropertyIndexValueFactoryBase<TSerialized> : IProperty
=> GetIndexValues(property, culture, segment, published, Enumerable.Empty<string>());
/// <summary>
/// Method to return a list of resume of the content. By default this returns an empty list
/// Method to return a list of summary of the content. By default this returns an empty list
/// </summary>
protected virtual IEnumerable<KeyValuePair<string, IEnumerable<object?>>> HandleResume(
List<KeyValuePair<string, IEnumerable<object?>>> result,

View File

@@ -1,12 +1,27 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Web.Common.DependencyInjection;
namespace Umbraco.Cms.Core.PropertyEditors;
public class TagPropertyIndexValueFactory : JsonPropertyIndexValueFactoryBase<string[]>, ITagPropertyIndexValueFactory
{
public TagPropertyIndexValueFactory(IJsonSerializer jsonSerializer) : base(jsonSerializer)
public TagPropertyIndexValueFactory(
IJsonSerializer jsonSerializer,
IOptionsMonitor<IndexingSettings> indexingSettings)
: base(jsonSerializer, indexingSettings)
{
ForceExplicitlyIndexEachNestedProperty = true;
}
[Obsolete("Use non-obsolete constructor. This will be removed in Umbraco 14.")]
public TagPropertyIndexValueFactory(IJsonSerializer jsonSerializer)
: this(jsonSerializer, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
}
protected override IEnumerable<KeyValuePair<string, IEnumerable<object?>>> Handle(

View File

@@ -14,14 +14,14 @@ namespace Umbraco.Cms.Core.PropertyEditors;
/// </summary>
internal class BlockEditorValues
{
private readonly Lazy<Dictionary<Guid, IContentType>> _contentTypes;
private readonly BlockEditorDataConverter _dataConverter;
private readonly IContentTypeService _contentTypeService;
private readonly ILogger _logger;
public BlockEditorValues(BlockEditorDataConverter dataConverter, IContentTypeService contentTypeService, ILogger logger)
{
_contentTypes = new Lazy<Dictionary<Guid, IContentType>>(() => contentTypeService.GetAll().ToDictionary(c => c.Key));
_dataConverter = dataConverter;
_contentTypeService = contentTypeService;
_logger = logger;
}
@@ -66,11 +66,7 @@ internal class BlockEditorValues
return blockEditorData;
}
private IContentType? GetElementType(BlockItemData item)
{
_contentTypes.Value.TryGetValue(item.ContentTypeKey, out IContentType? contentType);
return contentType;
}
private IContentType? GetElementType(BlockItemData item) => _contentTypeService.Get(item.ContentTypeKey);
private bool ResolveBlockItemData(BlockItemData block, Dictionary<string, Dictionary<string, IPropertyType>> contentTypePropertyTypes)
{

View File

@@ -1,10 +1,14 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Blocks;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common.DependencyInjection;
namespace Umbraco.Cms.Core.PropertyEditors;
@@ -14,12 +18,22 @@ internal sealed class BlockValuePropertyIndexValueFactory :
{
private readonly IContentTypeService _contentTypeService;
public BlockValuePropertyIndexValueFactory(
PropertyEditorCollection propertyEditorCollection,
IContentTypeService contentTypeService,
IJsonSerializer jsonSerializer,
IOptionsMonitor<IndexingSettings> indexingSettings)
: base(propertyEditorCollection, jsonSerializer, indexingSettings)
{
_contentTypeService = contentTypeService;
}
[Obsolete("Use non-obsolete constructor. This will be removed in Umbraco 14.")]
public BlockValuePropertyIndexValueFactory(
PropertyEditorCollection propertyEditorCollection,
IContentTypeService contentTypeService,
IJsonSerializer jsonSerializer)
: base(propertyEditorCollection, jsonSerializer)
: this(propertyEditorCollection, contentTypeService, jsonSerializer, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
_contentTypeService = contentTypeService;
}

View File

@@ -1,9 +1,13 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common.DependencyInjection;
namespace Umbraco.Cms.Core.PropertyEditors;
@@ -15,11 +19,22 @@ internal sealed class NestedContentPropertyIndexValueFactory
{
private readonly IContentTypeService _contentTypeService;
public NestedContentPropertyIndexValueFactory(
PropertyEditorCollection propertyEditorCollection,
IContentTypeService contentTypeService,
IJsonSerializer jsonSerializer) : base(propertyEditorCollection, jsonSerializer)
IJsonSerializer jsonSerializer,
IOptionsMonitor<IndexingSettings> indexingSettings)
: base(propertyEditorCollection, jsonSerializer, indexingSettings)
{
_contentTypeService = contentTypeService;
}
[Obsolete("Use non-obsolete constructor. This will be removed in Umbraco 14.")]
public NestedContentPropertyIndexValueFactory(
PropertyEditorCollection propertyEditorCollection,
IContentTypeService contentTypeService,
IJsonSerializer jsonSerializer)
: this(propertyEditorCollection, contentTypeService, jsonSerializer, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
_contentTypeService = contentTypeService;
}

View File

@@ -1,7 +1,11 @@
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Infrastructure.Examine;
using Umbraco.Cms.Web.Common.DependencyInjection;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.PropertyEditors;
@@ -10,12 +14,23 @@ internal abstract class NestedPropertyIndexValueFactoryBase<TSerialized, TItem>
{
private readonly PropertyEditorCollection _propertyEditorCollection;
protected NestedPropertyIndexValueFactoryBase(
PropertyEditorCollection propertyEditorCollection,
IJsonSerializer jsonSerializer,
IOptionsMonitor<IndexingSettings> indexingSettings)
: base(jsonSerializer, indexingSettings)
{
_propertyEditorCollection = propertyEditorCollection;
}
[Obsolete("Use non-obsolete constructor. This will be removed in Umbraco 14.")]
protected NestedPropertyIndexValueFactoryBase(
PropertyEditorCollection propertyEditorCollection,
IJsonSerializer jsonSerializer)
: base(jsonSerializer)
: this(propertyEditorCollection, jsonSerializer, StaticServiceProvider.Instance.GetRequiredService<IOptionsMonitor<IndexingSettings>>())
{
_propertyEditorCollection = propertyEditorCollection;
}
[Obsolete("Use the overload that specifies availableCultures, scheduled for removal in v14")]