Skip to content

Commit 02a20b1

Browse files
Merge branch 'release/13.3.1' into v13/dev
# Conflicts: # version.json
2 parents e7b9f0d + 9e7d8d4 commit 02a20b1

File tree

4 files changed

+69
-3
lines changed

4 files changed

+69
-3
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ stages:
148148
jobs:
149149
- job:
150150
displayName: Release to pre-release/nightly MyGet feed
151+
pool:
152+
vmImage: 'windows-latest'
151153
steps:
152154
- checkout: none
153155
- task: DownloadPipelineArtifact@2
@@ -173,6 +175,8 @@ stages:
173175
jobs:
174176
- job:
175177
displayName: Release to public NuGet feed
178+
pool:
179+
vmImage: 'windows-latest'
176180
steps:
177181
- checkout: none
178182
- task: DownloadPipelineArtifact@2

src/Umbraco.Deploy.Contrib/Migrators/DocTypeGridEditorPropertyTypeMigrator.cs

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
4+
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Logging;
56
using Newtonsoft.Json;
67
using Newtonsoft.Json.Linq;
78
using Umbraco.Cms.Core;
9+
using Umbraco.Cms.Core.DependencyInjection;
810
using Umbraco.Cms.Core.Deploy;
911
using Umbraco.Cms.Core.Models;
1012
using Umbraco.Cms.Core.Models.Blocks;
1113
using Umbraco.Cms.Core.PropertyEditors;
1214
using Umbraco.Cms.Core.Serialization;
1315
using Umbraco.Cms.Core.Services;
1416
using Umbraco.Cms.Core.Strings;
17+
using Umbraco.Deploy.Core.Migrators;
1518
using Umbraco.Deploy.Infrastructure.Migrators;
1619
using Umbraco.Extensions;
1720

@@ -22,7 +25,10 @@ namespace Umbraco.Deploy.Contrib.Migrators;
2225
/// </summary>
2326
public class DocTypeGridEditorPropertyTypeMigrator : GridPropertyTypeMigrator
2427
{
28+
private readonly ILogger<GridPropertyTypeMigrator> _logger;
2529
private readonly IJsonSerializer _jsonSerializer;
30+
private readonly PropertyTypeMigratorCollection _propertyTypeMigrators;
31+
private IDictionary<string, string>? _propertyEditorAliases;
2632

2733
/// <summary>
2834
/// Initializes a new instance of the <see cref="DocTypeGridEditorPropertyTypeMigrator" /> class.
@@ -33,12 +39,49 @@ public class DocTypeGridEditorPropertyTypeMigrator : GridPropertyTypeMigrator
3339
/// <param name="shortStringHelper">The short string helper.</param>
3440
/// <param name="contentTypeService">The content type service.</param>
3541
/// <param name="mediaService">The media service.</param>
42+
[Obsolete("Use the constructor with all parameters. This will be removed in a future version.")]
3643
public DocTypeGridEditorPropertyTypeMigrator(ILogger<GridPropertyTypeMigrator> logger, IJsonSerializer jsonSerializer, IDataTypeService dataTypeService, IShortStringHelper shortStringHelper, IContentTypeService contentTypeService, IMediaService mediaService)
44+
: this(
45+
logger,
46+
jsonSerializer,
47+
dataTypeService,
48+
shortStringHelper,
49+
contentTypeService,
50+
mediaService,
51+
StaticServiceProvider.Instance.GetRequiredService<PropertyTypeMigratorCollection>())
52+
{ }
53+
54+
/// <summary>
55+
/// Initializes a new instance of the <see cref="DocTypeGridEditorPropertyTypeMigrator" /> class.
56+
/// </summary>
57+
/// <param name="logger">The logger.</param>
58+
/// <param name="jsonSerializer">The JSON serializer.</param>
59+
/// <param name="dataTypeService">The data type service.</param>
60+
/// <param name="shortStringHelper">The short string helper.</param>
61+
/// <param name="contentTypeService">The content type service.</param>
62+
/// <param name="mediaService">The media service.</param>
63+
/// <param name="propertyTypeMigrators">The property type migrators.</param>
64+
public DocTypeGridEditorPropertyTypeMigrator(ILogger<GridPropertyTypeMigrator> logger, IJsonSerializer jsonSerializer, IDataTypeService dataTypeService, IShortStringHelper shortStringHelper, IContentTypeService contentTypeService, IMediaService mediaService, PropertyTypeMigratorCollection propertyTypeMigrators)
3765
: base(logger, jsonSerializer, dataTypeService, shortStringHelper, contentTypeService, mediaService)
38-
=> _jsonSerializer = jsonSerializer;
66+
{
67+
_logger = logger;
68+
_jsonSerializer = jsonSerializer;
69+
_propertyTypeMigrators = propertyTypeMigrators;
70+
}
3971

4072
/// <inheritdoc />
73+
public override object? Migrate(IPropertyType propertyType, object? value, IDictionary<string, string> propertyEditorAliases, IContextCache contextCache)
74+
{
75+
// Workaround: store property editor aliases for use in MigrateGridControl
76+
_propertyEditorAliases = propertyEditorAliases;
77+
78+
return base.Migrate(propertyType, value, propertyEditorAliases, contextCache);
79+
}
80+
81+
/// <inheritdoc />
82+
#pragma warning disable CS0618 // Type or member is obsolete
4183
protected override BlockItemData? MigrateGridControl(GridValue.GridControl gridControl, BlockGridConfiguration configuration, IContextCache contextCache)
84+
#pragma warning restore CS0618 // Type or member is obsolete
4285
{
4386
if (TryDeserialize(gridControl.Value, out DocTypeGridEditorValue? value))
4487
{
@@ -62,11 +105,28 @@ public DocTypeGridEditorPropertyTypeMigrator(ILogger<GridPropertyTypeMigrator> l
62105
IContentType contentType = GetContentType(value.ContentTypeAlias, configuration, contextCache)
63106
?? throw new InvalidOperationException($"Migrating legacy grid failed, because content type with alias '{value.ContentTypeAlias}' could not be found (in the Block Grid configuration).");
64107

108+
var propertyValues = new Dictionary<string, object?>(value.Value.Count);
109+
110+
foreach (IPropertyType propertyType in contentType.CompositionPropertyTypes)
111+
{
112+
if (value.Value.TryGetValue(propertyType.Alias, out object? propertyValue))
113+
{
114+
if (_propertyEditorAliases is not null && _propertyTypeMigrators.TryMigrate(propertyType, propertyValue, _propertyEditorAliases, contentType.Alias, contextCache, out var migratedValue))
115+
{
116+
_logger.LogDebug("Migrated nested/recursive property {PropertyTypeAlias} on {ContentTypeAlias} to {PropertyEditorAlias}: {Value}.", propertyType.Alias, contentType.Alias, propertyType.PropertyEditorAlias, migratedValue);
117+
118+
propertyValue = migratedValue;
119+
}
120+
121+
propertyValues[propertyType.Alias] = propertyValue;
122+
}
123+
}
124+
65125
return new BlockItemData()
66126
{
67127
Udi = Udi.Create(Constants.UdiEntityType.Element, value.Id),
68128
ContentTypeKey = contentType.Key,
69-
RawPropertyValues = value.Value
129+
RawPropertyValues = propertyValues
70130
};
71131
}
72132

src/Umbraco.Deploy.Contrib/Migrators/ReplaceDocTypeGridEditorDataTypeArtifactMigrator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ protected override IEnumerable<IGridEditorConfig> GetGridEditors()
9292

9393
if (AddDefaultDocTypeGridEditor)
9494
{
95+
#pragma warning disable CS0618 // Type or member is obsolete
9596
yield return new GridEditor()
9697
{
9798
Name = "Doc Type",
@@ -100,6 +101,7 @@ protected override IEnumerable<IGridEditorConfig> GetGridEditors()
100101
Render = "/App_Plugins/DocTypeGridEditor/Render/DocTypeGridEditor.cshtml",
101102
Icon = "icon-item-arrangement",
102103
};
104+
#pragma warning restore CS0618 // Type or member is obsolete
103105
}
104106
}
105107

src/Umbraco.Deploy.Contrib/Umbraco.Deploy.Contrib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Umbraco.Cms.Web.Common" />
8+
<PackageReference Include="Umbraco.Cms.Web.Common" NoWarn="NU1901,NU1902,NU1903,NU1904" />
99
<PackageReference Include="Umbraco.Deploy.Infrastructure" />
1010
</ItemGroup>
1111
</Project>

0 commit comments

Comments
 (0)