Skip to content

Commit

Permalink
Merge pull request #64 from umbraco/v14/bugfix/fix-migrators
Browse files Browse the repository at this point in the history
v14: Fix commented out migrators
  • Loading branch information
ronaldbarendse authored May 29, 2024
2 parents 7774bea + 2738eb6 commit 61ef925
Show file tree
Hide file tree
Showing 16 changed files with 475 additions and 496 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
//using System.Collections.Generic;
//using Umbraco.Cms.Core;
//using Umbraco.Cms.Core.PropertyEditors;
//using Umbraco.Cms.Core.Semver;
//using Umbraco.Cms.Core.Serialization;
//using Umbraco.Deploy.Infrastructure.Artifacts;
//using Umbraco.Deploy.Infrastructure.Migrators;
using System.Collections.Generic;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Semver;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Deploy.Infrastructure.Artifacts;
using Umbraco.Deploy.Infrastructure.Migrators;

//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

///// <summary>
///// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="Constants.PropertyEditors.Aliases.CheckBoxList" /> editor configuration from Umbraco 7 to <see cref="ValueListConfiguration" />.
///// </summary>
//public class CheckBoxListDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<ValueListConfiguration>
//{
// /// <summary>
// /// Initializes a new instance of the <see cref="CheckBoxListDataTypeArtifactMigrator" /> class.
// /// </summary>
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
// public CheckBoxListDataTypeArtifactMigrator(IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
// : base(Constants.PropertyEditors.Aliases.CheckBoxList, configurationEditorJsonSerializer)
// => MaxVersion = new SemVersion(3, 0, 0);
/// <summary>
/// Migrates the <see cref="DataTypeArtifact" /> to replace the <see cref="Constants.PropertyEditors.Aliases.CheckBoxList" /> editor configuration from Umbraco 7 to <see cref="ValueListConfiguration" />.
/// </summary>
public class CheckBoxListDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<ValueListConfiguration>
{
/// <summary>
/// Initializes a new instance of the <see cref="CheckBoxListDataTypeArtifactMigrator" /> class.
/// </summary>
/// <param name="propertyEditors">The property editors.</param>
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
public CheckBoxListDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
: base(Constants.PropertyEditors.Aliases.CheckBoxList, propertyEditors, configurationEditorJsonSerializer)
=> MaxVersion = new SemVersion(3, 0, 0);

// /// <inheritdoc />
// protected override ValueListConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
// {
// var toConfiguration = new ValueListConfiguration();
/// <inheritdoc />
protected override ValueListConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
{
var toConfiguration = new ValueListConfiguration();

// foreach (var (key, value) in fromConfiguration)
// {
// if (int.TryParse(key, out var id) && value is not null)
// {
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
// {
// Id = id,
// Value = value.ToString()
// });
// }
// }
foreach (var (key, value) in fromConfiguration)
{
if (int.TryParse(key, out _) && value is string itemValue)
{
toConfiguration.Items.Add(itemValue);
}
}

// return toConfiguration;
// }

// /// <inheritdoc />
// protected override ValueListConfiguration? GetDefaultConfiguration()
// => new ValueListConfiguration();
//}
return toConfiguration;
}
}
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
//using System.Collections.Generic;
//using Umbraco.Cms.Core;
//using Umbraco.Cms.Core.PropertyEditors;
//using Umbraco.Cms.Core.Semver;
//using Umbraco.Cms.Core.Serialization;
//using Umbraco.Deploy.Infrastructure.Artifacts;
//using Umbraco.Deploy.Infrastructure.Migrators;
using System.Collections.Generic;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Semver;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Deploy.Infrastructure.Artifacts;
using Umbraco.Deploy.Infrastructure.Migrators;

//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

///// <summary>
///// 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" />.
///// </summary>
//public class ColorPickerAliasDataTypeArtifactMigrator : ReplaceDataTypeArtifactMigratorBase<ColorPickerConfiguration>
//{
// private const string FromEditorAlias = "Umbraco.ColorPickerAlias";
// private const string TrueValue = "1";
/// <summary>
/// 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" />.
/// </summary>
public class ColorPickerAliasDataTypeArtifactMigrator : ReplaceDataTypeArtifactMigratorBase<ColorPickerConfiguration>
{
private const string FromEditorAlias = "Umbraco.ColorPickerAlias";
private const string TrueValue = "1";

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

// /// <inheritdoc />
// protected override ColorPickerConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
// {
// var toConfiguration = new ColorPickerConfiguration();
/// <inheritdoc />
protected override ColorPickerConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
{
var toConfiguration = new ColorPickerConfiguration();

// foreach (var (key, value) in fromConfiguration)
// {
// if (key == "useLabel")
// {
// toConfiguration.UseLabel = TrueValue.Equals(value);
// }
// else if (int.TryParse(key, out var id) && value is not null)
// {
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
// {
// Id = id,
// Value = value.ToString()
// });
// }
// }
foreach (var (key, value) in fromConfiguration)
{
if (key == "useLabel")
{
toConfiguration.UseLabel = TrueValue.Equals(value);
}
else if (int.TryParse(key, out _) && value is string itemValue)
{
toConfiguration.Items.Add(new ColorPickerConfiguration.ColorPickerItem()
{
Label = itemValue,
Value = itemValue,
});
}
}

// return toConfiguration;
// }
//}
return toConfiguration;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
//using Umbraco.Cms.Core;
//using Umbraco.Cms.Core.PropertyEditors;
//using Umbraco.Cms.Core.Serialization;
//using Umbraco.Deploy.Infrastructure.Artifacts;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Deploy.Infrastructure.Artifacts;

//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

///// <summary>
///// 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" />.
///// </summary>
//public class DropDownDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
//{
// private const string FromEditorAlias = "Umbraco.DropDown";
/// <summary>
/// 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" />.
/// </summary>
public class DropDownDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
{
private const string FromEditorAlias = "Umbraco.DropDown";

// /// <inheritdoc />
// protected override bool Multiple => false;
/// <inheritdoc />
protected override bool Multiple => false;

// /// <summary>
// /// Initializes a new instance of the <see cref="DropDownDataTypeArtifactMigrator" /> class.
// /// </summary>
// /// <param name="propertyEditors">The property editors.</param>
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
// public DropDownDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
// : base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
// { }
//}
/// <summary>
/// Initializes a new instance of the <see cref="DropDownDataTypeArtifactMigrator" /> class.
/// </summary>
/// <param name="propertyEditors">The property editors.</param>
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
public DropDownDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
: base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
{ }
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,58 @@
//using System.Collections.Generic;
//using Umbraco.Cms.Core;
//using Umbraco.Cms.Core.PropertyEditors;
//using Umbraco.Cms.Core.Semver;
//using Umbraco.Cms.Core.Serialization;
//using Umbraco.Deploy.Infrastructure.Artifacts;
//using Umbraco.Deploy.Infrastructure.Migrators;

//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

///// <summary>
///// 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" />.
///// </summary>
//public class DropDownFlexibleDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<DropDownFlexibleConfiguration>
//{
// private const string TrueValue = "1";

// /// <summary>
// /// Initializes a new instance of the <see cref="DropDownFlexibleDataTypeArtifactMigrator" /> class.
// /// </summary>
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
// public DropDownFlexibleDataTypeArtifactMigrator(IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
// : base(Constants.PropertyEditors.Aliases.DropDownListFlexible, configurationEditorJsonSerializer)
// => MaxVersion = new SemVersion(3, 0, 0);

// /// <inheritdoc />
// protected override DropDownFlexibleConfiguration? MigrateConfiguration(IDictionary<string, object?> fromConfiguration)
// {
// var toConfiguration = new DropDownFlexibleConfiguration()
// {
// Multiple = true
// };

// foreach (var (key, value) in fromConfiguration)
// {
// if (key == "multiple")
// {
// toConfiguration.Multiple = TrueValue.Equals(value);
// }
// else if (int.TryParse(key, out var id) && value is not null)
// {
// toConfiguration.Items.Add(new ValueListConfiguration.ValueListItem()
// {
// Id = id,
// Value = value.ToString()
// });
// }
// }

// return toConfiguration;
// }

// /// <inheritdoc />
// protected override DropDownFlexibleConfiguration? GetDefaultConfiguration()
// => new DropDownFlexibleConfiguration()
// {
// Multiple = true
// };
//}
using System.Collections.Generic;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Semver;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Deploy.Infrastructure.Artifacts;
using Umbraco.Deploy.Infrastructure.Migrators;

namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

/// <summary>
/// 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" />.
/// </summary>
public class DropDownFlexibleDataTypeArtifactMigrator : DataTypeConfigurationArtifactMigratorBase<DropDownFlexibleConfiguration>
{
private const string TrueValue = "1";

/// <summary>
/// Initializes a new instance of the <see cref="DropDownFlexibleDataTypeArtifactMigrator" /> class.
/// </summary>
/// <param name="propertyEditors">The property editors.</param>
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
public DropDownFlexibleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
: base(Constants.PropertyEditors.Aliases.DropDownListFlexible, propertyEditors, configurationEditorJsonSerializer)
=> MaxVersion = new SemVersion(3, 0, 0);

/// <inheritdoc />
protected override DropDownFlexibleConfiguration? MigrateConfigurationObject(IDictionary<string, object> fromConfiguration)
{
var toConfiguration = new DropDownFlexibleConfiguration()
{
Multiple = true
};

foreach (var (key, value) in fromConfiguration)
{
if (key == "multiple")
{
toConfiguration.Multiple = TrueValue.Equals(value);
}
else if (int.TryParse(key, out _) && value is string itemValue)
{
toConfiguration.Items.Add(itemValue);
}
}

return toConfiguration;
}

/// <inheritdoc />
protected override IDictionary<string, object> GetDefaultConfiguration(IConfigurationEditor configurationEditor)
{
var configuration = base.GetDefaultConfiguration(configurationEditor);
configuration["multiple"] = true;

return configuration;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
//using Umbraco.Cms.Core;
//using Umbraco.Cms.Core.PropertyEditors;
//using Umbraco.Cms.Core.Serialization;
//using Umbraco.Deploy.Infrastructure.Artifacts;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Deploy.Infrastructure.Artifacts;

//namespace Umbraco.Deploy.Contrib.Migrators.Legacy;
namespace Umbraco.Deploy.Contrib.Migrators.Legacy;

///// <summary>
///// 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" />.
///// </summary>
//public class DropDownMultipleDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
//{
// private const string FromEditorAlias = "Umbraco.DropDownMultiple";
/// <summary>
/// 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" />.
/// </summary>
public class DropDownMultipleDataTypeArtifactMigrator : DropDownReplaceDataTypeArtifactMigratorBase
{
private const string FromEditorAlias = "Umbraco.DropDownMultiple";

// /// <inheritdoc />
// protected override bool Multiple => true;
/// <inheritdoc />
protected override bool Multiple => true;

// /// <summary>
// /// Initializes a new instance of the <see cref="DropDownMultipleDataTypeArtifactMigrator" /> class.
// /// </summary>
// /// <param name="propertyEditors">The property editors.</param>
// /// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
// public DropDownMultipleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
// : base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
// { }
//}
/// <summary>
/// Initializes a new instance of the <see cref="DropDownMultipleDataTypeArtifactMigrator" /> class.
/// </summary>
/// <param name="propertyEditors">The property editors.</param>
/// <param name="configurationEditorJsonSerializer">The configuration editor JSON serializer.</param>
public DropDownMultipleDataTypeArtifactMigrator(PropertyEditorCollection propertyEditors, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer)
: base(FromEditorAlias, propertyEditors, configurationEditorJsonSerializer)
{ }
}
Loading

0 comments on commit 61ef925

Please sign in to comment.