Skip to content

Commit 61ef925

Browse files
Merge pull request #64 from umbraco/v14/bugfix/fix-migrators
v14: Fix commented out migrators
2 parents 7774bea + 2738eb6 commit 61ef925

16 files changed

+475
-496
lines changed
Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
1-
//using System.Collections.Generic;
2-
//using Umbraco.Cms.Core;
3-
//using Umbraco.Cms.Core.PropertyEditors;
4-
//using Umbraco.Cms.Core.Semver;
5-
//using Umbraco.Cms.Core.Serialization;
6-
//using Umbraco.Deploy.Infrastructure.Artifacts;
7-
//using Umbraco.Deploy.Infrastructure.Migrators;
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core;
3+
using Umbraco.Cms.Core.PropertyEditors;
4+
using Umbraco.Cms.Core.Semver;
5+
using Umbraco.Cms.Core.Serialization;
6+
using Umbraco.Deploy.Infrastructure.Artifacts;
7+
using Umbraco.Deploy.Infrastructure.Migrators;
88

9-
//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
9+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
1010

11-
///// <summary>
12-
///// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="Constants.PropertyEditors.Aliases.CheckBoxList" /> editor configuration from Umbraco 7 to <see cref="ValueListConfiguration" />.
13-
///// </summary>
14-
//public class CheckBoxListDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<ValueListConfiguration>
15-
//{
16-
// /// <summary>
17-
// /// Initializes a new instance of the <see cref="CheckBoxListDataTypeArtifactMigrator" /> class.
18-
// /// </summary>
19-
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
20-
// public CheckBoxListDataTypeArtifactMigrator(IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
21-
// : base(Constants.PropertyEditors.Aliases.CheckBoxList, configurationEditorJsonSerializer)
22-
// => MaxVersion = new SemVersion(3, 0, 0);
11+
/// <summary>
12+
/// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="Constants.PropertyEditors.Aliases.CheckBoxList" /> editor configuration from Umbraco 7 to <see cref="ValueListConfiguration" />.
13+
/// </summary>
14+
public class CheckBoxListDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<ValueListConfiguration>
15+
{
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="CheckBoxListDataTypeArtifactMigrator" /> class.
18+
/// </summary>
19+
/// <param name="propertyEditors">The property editors.</param>
20+
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
21+
public CheckBoxListDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
22+
: base(Constants.PropertyEditors.Aliases.CheckBoxList, propertyEditors, configurationEditorJsonSerializer)
23+
=> MaxVersion = new SemVersion(3, 0, 0);
2324

24-
// /// <inheritdoc />
25-
// protected override ValueListConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
26-
// {
27-
// var toConfiguration = new ValueListConfiguration();
25+
/// <inheritdoc />
26+
protected override ValueListConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
27+
{
28+
var toConfiguration = new ValueListConfiguration();
2829

29-
// foreach (var (key, value) in fromConfiguration)
30-
// {
31-
// if (int.TryParse(key, out var id) && value is not null)
32-
// {
33-
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
34-
// {
35-
// Id = id,
36-
// Value = value.ToString()
37-
// });
38-
// }
39-
// }
30+
foreach (var (key, value) in fromConfiguration)
31+
{
32+
if (int.TryParse(key, out _) && value is string itemValue)
33+
{
34+
toConfiguration.Items.Add(itemValue);
35+
}
36+
}
4037

41-
// return toConfiguration;
42-
// }
43-
44-
// /// <inheritdoc />
45-
// protected override ValueListConfiguration? GetDefaultConfiguration()
46-
// => new ValueListConfiguration();
47-
//}
38+
return toConfiguration;
39+
}
40+
}
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
//using System.Collections.Generic;
2-
//using Umbraco.Cms.Core;
3-
//using Umbraco.Cms.Core.PropertyEditors;
4-
//using Umbraco.Cms.Core.Semver;
5-
//using Umbraco.Cms.Core.Serialization;
6-
//using Umbraco.Deploy.Infrastructure.Artifacts;
7-
//using Umbraco.Deploy.Infrastructure.Migrators;
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core;
3+
using Umbraco.Cms.Core.PropertyEditors;
4+
using Umbraco.Cms.Core.Semver;
5+
using Umbraco.Cms.Core.Serialization;
6+
using Umbraco.Deploy.Infrastructure.Artifacts;
7+
using Umbraco.Deploy.Infrastructure.Migrators;
88

9-
//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
9+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
1010

11-
///// <summary>
12-
///// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.ColorPicker" /> and the configuration from Umbraco 7 to <see cref="ColorPickerConfiguration" />.
13-
///// </summary>
14-
//public class ColorPickerAliasDataTypeArtifactMigrator : ReplaceDataTypeArtifactMigratorBase<ColorPickerConfiguration>
15-
//{
16-
// private const string FromEditorAlias = "Umbraco.ColorPickerAlias";
17-
// private const string TrueValue = "1";
11+
/// <summary>
12+
/// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.ColorPicker" /> and the configuration from Umbraco 7 to <see cref="ColorPickerConfiguration" />.
13+
/// </summary>
14+
public class ColorPickerAliasDataTypeArtifactMigrator : ReplaceDataTypeArtifactMigratorBase<ColorPickerConfiguration>
15+
{
16+
private const string FromEditorAlias = "Umbraco.ColorPickerAlias";
17+
private const string TrueValue = "1";
1818

19-
// /// <summary>
20-
// /// Initializes a new instance of the <see cref="ColorPickerAliasDataTypeArtifactMigrator" /> class.
21-
// /// </summary>
22-
// /// <param name="propertyEditors">The property editors.</param>
23-
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
24-
// public ColorPickerAliasDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
25-
// : base(FromEditorAlias, Constants.PropertyEditors.Aliases.ColorPicker, propertyEditors, configurationEditorJsonSerializer)
26-
// => MaxVersion = new SemVersion(3, 0, 0);
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="ColorPickerAliasDataTypeArtifactMigrator" /> class.
21+
/// </summary>
22+
/// <param name="propertyEditors">The property editors.</param>
23+
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
24+
public ColorPickerAliasDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
25+
: base(FromEditorAlias, Constants.PropertyEditors.Aliases.ColorPicker, propertyEditors, configurationEditorJsonSerializer)
26+
=> MaxVersion = new SemVersion(3, 0, 0);
2727

28-
// /// <inheritdoc />
29-
// protected override ColorPickerConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
30-
// {
31-
// var toConfiguration = new ColorPickerConfiguration();
28+
/// <inheritdoc />
29+
protected override ColorPickerConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
30+
{
31+
var toConfiguration = new ColorPickerConfiguration();
3232

33-
// foreach (var (key, value) in fromConfiguration)
34-
// {
35-
// if (key == "useLabel")
36-
// {
37-
// toConfiguration.UseLabel = TrueValue.Equals(value);
38-
// }
39-
// else if (int.TryParse(key, out var id) && value is not null)
40-
// {
41-
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
42-
// {
43-
// Id = id,
44-
// Value = value.ToString()
45-
// });
46-
// }
47-
// }
33+
foreach (var (key, value) in fromConfiguration)
34+
{
35+
if (key == "useLabel")
36+
{
37+
toConfiguration.UseLabel = TrueValue.Equals(value);
38+
}
39+
else if (int.TryParse(key, out _) && value is string itemValue)
40+
{
41+
toConfiguration.Items.Add(new ColorPickerConfiguration.ColorPickerItem()
42+
{
43+
Label = itemValue,
44+
Value = itemValue,
45+
});
46+
}
47+
}
4848

49-
// return toConfiguration;
50-
// }
51-
//}
49+
return toConfiguration;
50+
}
51+
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
//using Umbraco.Cms.Core;
2-
//using Umbraco.Cms.Core.PropertyEditors;
3-
//using Umbraco.Cms.Core.Serialization;
4-
//using Umbraco.Deploy.Infrastructure.Artifacts;
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.PropertyEditors;
3+
using Umbraco.Cms.Core.Serialization;
4+
using Umbraco.Deploy.Infrastructure.Artifacts;
55

6-
//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
6+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
77

8-
///// <summary>
9-
///// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> and the configuration from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
10-
///// </summary>
11-
//public class DropDownDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
12-
//{
13-
// private const string FromEditorAlias = "Umbraco.DropDown";
8+
/// <summary>
9+
/// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> and the configuration from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
10+
/// </summary>
11+
public class DropDownDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
12+
{
13+
private const string FromEditorAlias = "Umbraco.DropDown";
1414

15-
// /// <inheritdoc />
16-
// protected override bool Multiple => false;
15+
/// <inheritdoc />
16+
protected override bool Multiple => false;
1717

18-
// /// <summary>
19-
// /// Initializes a new instance of the <see cref="DropDownDataTypeArtifactMigrator" /> class.
20-
// /// </summary>
21-
// /// <param name="propertyEditors">The property editors.</param>
22-
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
23-
// public DropDownDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
24-
// : base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
25-
// { }
26-
//}
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="DropDownDataTypeArtifactMigrator" /> class.
20+
/// </summary>
21+
/// <param name="propertyEditors">The property editors.</param>
22+
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
23+
public DropDownDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
24+
: base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
25+
{ }
26+
}
Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
1-
//using System.Collections.Generic;
2-
//using Umbraco.Cms.Core;
3-
//using Umbraco.Cms.Core.PropertyEditors;
4-
//using Umbraco.Cms.Core.Semver;
5-
//using Umbraco.Cms.Core.Serialization;
6-
//using Umbraco.Deploy.Infrastructure.Artifacts;
7-
//using Umbraco.Deploy.Infrastructure.Migrators;
8-
9-
//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
10-
11-
///// <summary>
12-
///// Migrates the <see cref="DataTypeArtifact" /> to replace the configuration of the <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> editor from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
13-
///// </summary>
14-
//public class DropDownFlexibleDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<DropDownFlexibleConfiguration>
15-
//{
16-
// private const string TrueValue = "1";
17-
18-
// /// <summary>
19-
// /// Initializes a new instance of the <see cref="DropDownFlexibleDataTypeArtifactMigrator" /> class.
20-
// /// </summary>
21-
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
22-
// public DropDownFlexibleDataTypeArtifactMigrator(IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
23-
// : base(Constants.PropertyEditors.Aliases.DropDownListFlexible, configurationEditorJsonSerializer)
24-
// => MaxVersion = new SemVersion(3, 0, 0);
25-
26-
// /// <inheritdoc />
27-
// protected override DropDownFlexibleConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
28-
// {
29-
// var toConfiguration = new DropDownFlexibleConfiguration()
30-
// {
31-
// Multiple = true
32-
// };
33-
34-
// foreach (var (key, value) in fromConfiguration)
35-
// {
36-
// if (key == "multiple")
37-
// {
38-
// toConfiguration.Multiple = TrueValue.Equals(value);
39-
// }
40-
// else if (int.TryParse(key, out var id) && value is not null)
41-
// {
42-
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
43-
// {
44-
// Id = id,
45-
// Value = value.ToString()
46-
// });
47-
// }
48-
// }
49-
50-
// return toConfiguration;
51-
// }
52-
53-
// /// <inheritdoc />
54-
// protected override DropDownFlexibleConfiguration? GetDefaultConfiguration()
55-
// => new DropDownFlexibleConfiguration()
56-
// {
57-
// Multiple = true
58-
// };
59-
//}
1+
using System.Collections.Generic;
2+
using Umbraco.Cms.Core;
3+
using Umbraco.Cms.Core.PropertyEditors;
4+
using Umbraco.Cms.Core.Semver;
5+
using Umbraco.Cms.Core.Serialization;
6+
using Umbraco.Deploy.Infrastructure.Artifacts;
7+
using Umbraco.Deploy.Infrastructure.Migrators;
8+
9+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
10+
11+
/// <summary>
12+
/// Migrates the <see cref="DataTypeArtifact" /> to replace the configuration of the <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> editor from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
13+
/// </summary>
14+
public class DropDownFlexibleDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<DropDownFlexibleConfiguration>
15+
{
16+
private const string TrueValue = "1";
17+
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="DropDownFlexibleDataTypeArtifactMigrator" /> class.
20+
/// </summary>
21+
/// <param name="propertyEditors">The property editors.</param>
22+
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
23+
public DropDownFlexibleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
24+
: base(Constants.PropertyEditors.Aliases.DropDownListFlexible, propertyEditors, configurationEditorJsonSerializer)
25+
=> MaxVersion = new SemVersion(3, 0, 0);
26+
27+
/// <inheritdoc />
28+
protected override DropDownFlexibleConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
29+
{
30+
var toConfiguration = new DropDownFlexibleConfiguration()
31+
{
32+
Multiple = true
33+
};
34+
35+
foreach (var (key, value) in fromConfiguration)
36+
{
37+
if (key == "multiple")
38+
{
39+
toConfiguration.Multiple = TrueValue.Equals(value);
40+
}
41+
else if (int.TryParse(key, out _) && value is string itemValue)
42+
{
43+
toConfiguration.Items.Add(itemValue);
44+
}
45+
}
46+
47+
return toConfiguration;
48+
}
49+
50+
/// <inheritdoc />
51+
protected override IDictionary<string, object> GetDefaultConfiguration(IConfigurationEditor configurationEditor)
52+
{
53+
var configuration = base.GetDefaultConfiguration(configurationEditor);
54+
configuration["multiple"] = true;
55+
56+
return configuration;
57+
}
58+
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
//using Umbraco.Cms.Core;
2-
//using Umbraco.Cms.Core.PropertyEditors;
3-
//using Umbraco.Cms.Core.Serialization;
4-
//using Umbraco.Deploy.Infrastructure.Artifacts;
1+
using Umbraco.Cms.Core;
2+
using Umbraco.Cms.Core.PropertyEditors;
3+
using Umbraco.Cms.Core.Serialization;
4+
using Umbraco.Deploy.Infrastructure.Artifacts;
55

6-
//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
6+
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
77

8-
///// <summary>
9-
///// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> and the configuration from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
10-
///// </summary>
11-
//public class DropDownMultipleDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
12-
//{
13-
// private const string FromEditorAlias = "Umbraco.DropDownMultiple";
8+
/// <summary>
9+
/// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="FromEditorAlias" /> editor with <see cref="Constants.PropertyEditors.Aliases.DropDownListFlexible" /> and the configuration from Umbraco 7 to <see cref="DropDownFlexibleConfiguration" />.
10+
/// </summary>
11+
public class DropDownMultipleDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
12+
{
13+
private const string FromEditorAlias = "Umbraco.DropDownMultiple";
1414

15-
// /// <inheritdoc />
16-
// protected override bool Multiple => true;
15+
/// <inheritdoc />
16+
protected override bool Multiple => true;
1717

18-
// /// <summary>
19-
// /// Initializes a new instance of the <see cref="DropDownMultipleDataTypeArtifactMigrator" /> class.
20-
// /// </summary>
21-
// /// <param name="propertyEditors">The property editors.</param>
22-
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
23-
// public DropDownMultipleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
24-
// : base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
25-
// { }
26-
//}
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="DropDownMultipleDataTypeArtifactMigrator" /> class.
20+
/// </summary>
21+
/// <param name="propertyEditors">The property editors.</param>
22+
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
23+
public DropDownMultipleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
24+
: base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
25+
{ }
26+
}

0 commit comments

Comments
 (0)