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:
Kenn Jacobsen
2024-09-30 07:01:18 +02:00
committed by GitHub
parent 1fa132fb5f
commit 1be503e71f
91 changed files with 6765 additions and 1037 deletions

View File

@@ -61,6 +61,9 @@ public class JsonBlockValueConverter : JsonConverter<BlockValue>
case nameof(BlockValue.Layout):
DeserializeAndSetLayout(ref reader, options, typeToConvert, blockValue);
break;
case nameof(BlockValue.Expose):
blockValue.Expose = DeserializeBlockVariation(ref reader, options, typeToConvert, nameof(BlockValue.Expose));
break;
}
}
}
@@ -84,6 +87,9 @@ public class JsonBlockValueConverter : JsonConverter<BlockValue>
JsonSerializer.Serialize(writer, value.SettingsData, options);
}
writer.WritePropertyName(nameof(BlockValue.Expose).ToFirstLowerInvariant());
JsonSerializer.Serialize(writer, value.Expose, options);
Type layoutItemType = GetLayoutItemType(value.GetType());
writer.WriteStartObject(nameof(BlockValue.Layout));
@@ -115,7 +121,13 @@ public class JsonBlockValueConverter : JsonConverter<BlockValue>
}
private List<BlockItemData> DeserializeBlockItemData(ref Utf8JsonReader reader, JsonSerializerOptions options, Type typeToConvert, string propertyName)
=> JsonSerializer.Deserialize<List<BlockItemData>>(ref reader, options)
=> DeserializeListOf<BlockItemData>(ref reader, options, typeToConvert, propertyName);
private List<BlockItemVariation> DeserializeBlockVariation(ref Utf8JsonReader reader, JsonSerializerOptions options, Type typeToConvert, string propertyName)
=> DeserializeListOf<BlockItemVariation>(ref reader, options, typeToConvert, propertyName);
private List<T> DeserializeListOf<T>(ref Utf8JsonReader reader, JsonSerializerOptions options, Type typeToConvert, string propertyName)
=> JsonSerializer.Deserialize<List<T>>(ref reader, options)
?? throw new JsonException($"Unable to deserialize {propertyName} from type: {typeToConvert.FullName}.");
private void DeserializeAndSetLayout(ref Utf8JsonReader reader, JsonSerializerOptions options, Type typeToConvert, BlockValue blockValue)
@@ -167,12 +179,12 @@ public class JsonBlockValueConverter : JsonConverter<BlockValue>
}
// did we encounter the concrete block value?
if (blockEditorAlias == blockValue.PropertyEditorAlias)
if (blockValue.SupportsBlockLayoutAlias(blockEditorAlias))
{
// yes, deserialize the block layout items as their concrete type (list of layoutItemType)
var layoutItems = JsonSerializer.Deserialize(ref reader, layoutItemsType, options);
blockValue.Layout[blockEditorAlias] = layoutItems as IEnumerable<IBlockLayoutItem>
?? throw new JsonException($"Could not deserialize block editor layout items as type: {layoutItemType.FullName} while attempting to deserialize layout items for block editor alias: {blockEditorAlias} for type: {typeToConvert.FullName}.");
blockValue.Layout[blockValue.PropertyEditorAlias] = layoutItems as IEnumerable<IBlockLayoutItem>
?? throw new JsonException($"Could not deserialize block editor layout items as type: {layoutItemType.FullName} while attempting to deserialize layout items for block editor alias: {blockEditorAlias} for type: {typeToConvert.FullName}.");
}
else
{