Skip to content

Commit 879434b

Browse files
Migrate prevalues of legacy dropdown editors
1 parent 4740f22 commit 879434b

6 files changed

+108
-2
lines changed

src/Umbraco.Deploy.Contrib/Extensions/PropertyTypeMigratorCollectionBuilderExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public static PropertyTypeMigratorCollectionBuilder AddLegacyMigrators(this Prop
1515
=> propertyTypeMigratorCollectionBuilder
1616
// Pre-values to a single value or JSON array
1717
.Append<CheckBoxListPropertyTypeMigrator>()
18+
.Append<DropDownPropertyTypeMigrator>()
1819
.Append<DropDownListFlexiblePropertyTypeMigrator>()
20+
.Append<DropdownlistMultiplePublishKeysPropertyTypeMigrator>()
21+
.Append<DropdownlistPublishingKeysPropertyTypeMigrator>()
22+
.Append<DropDownMultiplePropertyTypeMigrator>()
1923
.Append<RadioButtonListPropertyTypeMigrator>();
2024
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.Serialization;
3+
4+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
5+
6+
/// <summary>
7+
/// Migrates the property value from the legacy <see cref="FromEditorAlias" /> editor containing prevalues (seperated by <see cref="PrevaluePropertyTypeMigratorBase.Delimiter" />) from Umbraco 7 to a JSON array.
8+
/// </summary>
9+
public sealed class DropDownMultiplePropertyTypeMigrator : PrevaluePropertyTypeMigratorBase
10+
{
11+
private const string FromEditorAlias = "Umbraco.DropDownMultiple";
12+
13+
/// <inheritdoc />
14+
protected override bool Multiple => true;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="DropDownMultiplePropertyTypeMigrator" /> class.
18+
/// </summary>
19+
/// <param name="jsonSerializer">The JSON serializer.</param>
20+
public DropDownMultiplePropertyTypeMigrator(IJsonSerializer jsonSerializer)
21+
: base(FromEditorAlias, Constants.PropertyEditors.Aliases.DropDownListFlexible, jsonSerializer)
22+
{ }
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.Serialization;
3+
4+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
5+
6+
/// <summary>
7+
/// Migrates the property value from the legacy <see cref="FromEditorAlias" /> editor containing prevalues (seperated by <see cref="PrevaluePropertyTypeMigratorBase.Delimiter" />) from Umbraco 7 to a JSON array.
8+
/// </summary>
9+
public sealed class DropDownPropertyTypeMigrator : PrevaluePropertyTypeMigratorBase
10+
{
11+
private const string FromEditorAlias = "Umbraco.DropDown";
12+
13+
/// <inheritdoc />
14+
protected override bool Multiple => true;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="DropDownPropertyTypeMigrator" /> class.
18+
/// </summary>
19+
/// <param name="jsonSerializer">The JSON serializer.</param>
20+
public DropDownPropertyTypeMigrator(IJsonSerializer jsonSerializer)
21+
: base(FromEditorAlias, Constants.PropertyEditors.Aliases.DropDownListFlexible, jsonSerializer)
22+
{ }
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.Serialization;
3+
4+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
5+
6+
/// <summary>
7+
/// Migrates the property value from the legacy <see cref="FromEditorAlias" /> editor containing prevalues (seperated by <see cref="PrevaluePropertyTypeMigratorBase.Delimiter" />) from Umbraco 7 to a JSON array.
8+
/// </summary>
9+
public sealed class DropdownlistMultiplePublishKeysPropertyTypeMigrator : PrevaluePropertyTypeMigratorBase
10+
{
11+
private const string FromEditorAlias = "Umbraco.DropdownlistMultiplePublishKeys";
12+
13+
/// <inheritdoc />
14+
protected override bool Multiple => true;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="DropdownlistMultiplePublishKeysPropertyTypeMigrator" /> class.
18+
/// </summary>
19+
/// <param name="jsonSerializer">The JSON serializer.</param>
20+
public DropdownlistMultiplePublishKeysPropertyTypeMigrator(IJsonSerializer jsonSerializer)
21+
: base(FromEditorAlias, Constants.PropertyEditors.Aliases.DropDownListFlexible, jsonSerializer)
22+
{ }
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.Serialization;
3+
4+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
5+
6+
/// <summary>
7+
/// Migrates the property value from the legacy <see cref="FromEditorAlias" /> editor containing prevalues (seperated by <see cref="PrevaluePropertyTypeMigratorBase.Delimiter" />) from Umbraco 7 to a JSON array.
8+
/// </summary>
9+
public sealed class DropdownlistPublishingKeysPropertyTypeMigrator : PrevaluePropertyTypeMigratorBase
10+
{
11+
private const string FromEditorAlias = "Umbraco.DropdownlistPublishingKeys";
12+
13+
/// <inheritdoc />
14+
protected override bool Multiple => true;
15+
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="DropdownlistPublishingKeysPropertyTypeMigrator" /> class.
18+
/// </summary>
19+
/// <param name="jsonSerializer">The JSON serializer.</param>
20+
public DropdownlistPublishingKeysPropertyTypeMigrator(IJsonSerializer jsonSerializer)
21+
: base(FromEditorAlias, Constants.PropertyEditors.Aliases.DropDownListFlexible, jsonSerializer)
22+
{ }
23+
}

src/Umbraco.Deploy.Contrib/Migrators/Legacy/Content/PrevaluePropertyTypeMigratorBase.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,20 @@ public abstract class PrevaluePropertyTypeMigratorBase : PropertyTypeMigratorBas
2828
/// <summary>
2929
/// Initializes a new instance of the <see cref="PrevaluePropertyTypeMigratorBase" /> class.
3030
/// </summary>
31-
/// <param name="editorAlias">The editor alias.</param>
31+
/// <param name="editorAlias">The editor alias (without the prefix added by <see cref="PrevalueArtifactMigrator" />).</param>
3232
/// <param name="jsonSerializer">The JSON serializer.</param>
3333
protected PrevaluePropertyTypeMigratorBase(string editorAlias, IJsonSerializer jsonSerializer)
34-
: base(EditorAliasPrefix + editorAlias, editorAlias)
34+
: this(EditorAliasPrefix + editorAlias, editorAlias, jsonSerializer)
35+
{ }
36+
37+
/// <summary>
38+
/// Initializes a new instance of the <see cref="PrevaluePropertyTypeMigratorBase" /> class.
39+
/// </summary>
40+
/// <param name="fromEditorAlias">The editor alias to migrate from.</param>
41+
/// <param name="toEditorAlias">The editor alias to migrate to.</param>
42+
/// <param name="jsonSerializer">The JSON serializer.</param>
43+
protected PrevaluePropertyTypeMigratorBase(string fromEditorAlias, string toEditorAlias, IJsonSerializer jsonSerializer)
44+
: base(fromEditorAlias, toEditorAlias)
3545
=> _jsonSerializer = jsonSerializer;
3646

3747
/// <inheritdoc />

0 commit comments

Comments
 (0)