Block level variance (#17120)
* Block level variance - initial commit * Remove TODOs * Only convert RTEs with blocks * Fix JSON paths for block level property validation * Rename Properties to Values * Correct the JSON path of block level validation errors * Make it possible to skip content migration + ensure backwards compat for the new block format * Partial culture variance publishing at property level * UDI to key conversion for block editors - draft, WIP, do NOT merge 😄 (#16970) * Convert block UDIs to GUIDs * Fix merge * Fix merge issues * Rework nested layout item key parsing for backwards compatibility * Clean-up * Reverse block layout item key calculation * Review * Use IOptions to skip content migrations * Remove "published" from data editor feature naming, as it can be used in other contexts too * Parallel migration * Don't use deprecated constructor * Ensure that layout follows structure for partial publishing * Block Grid element level variance + tests (incl. refactor of element level variation tests) * Rollback unintended changes to Program.cs * Fix bad casing * Minor formatting * RTE element level variance + tests * Remove obsoleted constructors * Use Umbraco.RichText instead of Umbraco.TinyMCE as layout alias for blocks in the RTE * Fix bad merge * Temporary fix for new cache in integration tests * Add EditorAlias to block level properties * Remove the unintended PropertyEditorAlias output for block values * Add EditorAlias to Datatype Item model * Update OpenApi.json * Introduce "expose" for blocks * Strict (explicit) handling for Expose * Improve handling of document and element level variance changes * Refactor variance alignment for published rendering * Block UDI to Key conversion should also register as a conversion * Convert newly added RTE unit test to new RTE blocks format * Minor review changes * Run memory intensive tests on Linux only * Add tests proving that AllowEditInvariantFromNonDefault has effect for block level variance too * Fix the Platform annotations * Removed Platform annotations for tests. * Fix merge * Obsolete old PublishCulture extension * More fixing bad merge --------- Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
|
||||
@@ -287,21 +290,22 @@ public static class ContentRepositoryExtensions
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Please use the overload that accepts all parameters. Will be removed in V16.")]
|
||||
public static bool PublishCulture(this IContent content, CultureImpact? impact)
|
||||
=> PublishCulture(content, impact, DateTime.Now, StaticServiceProvider.Instance.GetRequiredService<PropertyEditorCollection>());
|
||||
|
||||
/// <summary>
|
||||
/// Sets the publishing values for names and properties.
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="impact"></param>
|
||||
/// <param name="publishTime"></param>
|
||||
/// <param name="propertyEditorCollection"></param>
|
||||
/// <returns>
|
||||
/// A value indicating whether it was possible to publish the names and values for the specified
|
||||
/// culture(s). The method may fail if required names are not set, but it does NOT validate property data
|
||||
/// </returns>
|
||||
///
|
||||
public static bool PublishCulture(this IContent content, CultureImpact? impact)
|
||||
{
|
||||
return PublishCulture(content, impact, DateTime.Now);
|
||||
}
|
||||
public static bool PublishCulture(this IContent content, CultureImpact? impact, DateTime publishTime)
|
||||
public static bool PublishCulture(this IContent content, CultureImpact? impact, DateTime publishTime, PropertyEditorCollection propertyEditorCollection)
|
||||
{
|
||||
if (impact == null)
|
||||
{
|
||||
@@ -356,13 +360,13 @@ public static class ContentRepositoryExtensions
|
||||
foreach (IProperty property in content.Properties)
|
||||
{
|
||||
// for the specified culture (null or all or specific)
|
||||
property.PublishValues(impact.Culture);
|
||||
PublishPropertyValues(content, property, impact.Culture, propertyEditorCollection);
|
||||
|
||||
// maybe the specified culture did not impact the invariant culture, so PublishValues
|
||||
// above would skip it, yet it *also* impacts invariant properties
|
||||
if (impact.ImpactsAlsoInvariantProperties && (property.PropertyType.VariesByCulture() is false || impact.ImpactsOnlyDefaultCulture))
|
||||
{
|
||||
property.PublishValues(null);
|
||||
PublishPropertyValues(content, property, null, propertyEditorCollection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +374,22 @@ public static class ContentRepositoryExtensions
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void PublishPropertyValues(IContent content, IProperty property, string? culture, PropertyEditorCollection propertyEditorCollection)
|
||||
{
|
||||
// if the content varies by culture, let data editor opt-in to perform partial property publishing (per culture)
|
||||
if (content.ContentType.VariesByCulture()
|
||||
&& propertyEditorCollection.TryGet(property.PropertyType.PropertyEditorAlias, out IDataEditor? dataEditor)
|
||||
&& dataEditor.CanMergePartialPropertyValues(property.PropertyType))
|
||||
{
|
||||
// perform partial publishing for the current culture
|
||||
property.PublishPartialValues(dataEditor, culture);
|
||||
return;
|
||||
}
|
||||
|
||||
// for the specified culture (null or all or specific)
|
||||
property.PublishValues(culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns false if the culture is already unpublished
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user