Clean up datatype configurations for V14 (#15718)

* Clean up datatype configurations for V14

* Fix merge

* Remove ParameterEditorCollection + revert accidental changes to core project file
This commit is contained in:
Kenn Jacobsen
2024-02-15 12:36:23 +01:00
committed by GitHub
parent ec1ba6031f
commit cc082e191c
211 changed files with 414 additions and 7824 deletions

View File

@@ -25,19 +25,9 @@ public class ContentPropertyDisplay : ContentPropertyBasic
[DataMember(Name = "description")]
public string? Description { get; set; }
[DataMember(Name = "view", IsRequired = true)]
[Required(AllowEmptyStrings = false)]
public string? View { get; set; }
[DataMember(Name = "config")]
public IDictionary<string, object>? Config { get; set; }
[DataMember(Name = "hideLabel")]
public bool HideLabel { get; set; }
[DataMember(Name = "labelOnTop")]
public bool? LabelOnTop { get; set; }
[DataMember(Name = "validation")]
public PropertyTypeValidation Validation { get; set; }

View File

@@ -16,10 +16,6 @@ public class DataTypeBasic : EntityBasic
[ReadOnly(true)]
public bool IsSystemDataType { get; set; }
[DataMember(Name = "group")]
[ReadOnly(true)]
public string? Group { get; set; }
[DataMember(Name = "hasPrevalues")]
[ReadOnly(true)]
public bool HasPrevalues { get; set; }

View File

@@ -8,30 +8,6 @@ namespace Umbraco.Cms.Core.Models.ContentEditing;
[DataContract(Name = "preValue", Namespace = "")]
public class DataTypeConfigurationFieldDisplay : DataTypeConfigurationFieldSave
{
/// <summary>
/// The name to display for this pre-value field
/// </summary>
[DataMember(Name = "label", IsRequired = true)]
public string? Name { get; set; }
/// <summary>
/// The description to display for this pre-value field
/// </summary>
[DataMember(Name = "description")]
public string? Description { get; set; }
/// <summary>
/// Specifies whether to hide the label for the pre-value
/// </summary>
[DataMember(Name = "hideLabel")]
public bool HideLabel { get; set; }
/// <summary>
/// The view to render for the field
/// </summary>
[DataMember(Name = "view", IsRequired = true)]
public string? View { get; set; }
/// <summary>
/// This allows for custom configuration to be injected into the pre-value editor
/// </summary>

View File

@@ -10,10 +10,4 @@ public class PropertyEditorBasic
{
[DataMember(Name = "alias")]
public string? Alias { get; set; }
[DataMember(Name = "name")]
public string? Name { get; set; }
[DataMember(Name = "icon")]
public string? Icon { get; set; }
}

View File

@@ -53,10 +53,6 @@ public class PropertyTypeBasic
[ReadOnly(true)]
public string? DataTypeName { get; set; }
[DataMember(Name = "dataTypeIcon")]
[ReadOnly(true)]
public string? DataTypeIcon { get; set; }
// SD: Is this really needed ?
[DataMember(Name = "groupId")]
public int GroupId { get; set; }

View File

@@ -11,11 +11,6 @@ namespace Umbraco.Cms.Core.Models;
/// <remarks>This is the base interface for parameter and property value editors.</remarks>
public interface IDataValueEditor
{
/// <summary>
/// Gets the editor view.
/// </summary>
string? View { get; }
/// <summary>
/// Gets the type of the value.
/// </summary>
@@ -27,11 +22,6 @@ public interface IDataValueEditor
/// </summary>
bool IsReadOnly { get; }
/// <summary>
/// Gets a value indicating whether to display the associated label.
/// </summary>
bool HideLabel { get; }
/// <summary>
/// Gets a value indicating whether the IDataValueEditor supports readonly mode
/// </summary>

View File

@@ -44,15 +44,10 @@ internal class ContentPropertyDisplayMapper : ContentPropertyBasicMapper<Content
// - could configuration also determines ValueType, everywhere?
// - does it make any sense to use a IDataValueEditor without configuring it?
// configure the editor for display with configuration
IDataValueEditor? valEditor = dest.PropertyEditor?.GetValueEditor(dataType?.ConfigurationObject);
// set the display properties after mapping
dest.Alias = originalProp.Alias;
dest.Description = originalProp.PropertyType?.Description;
dest.Label = originalProp.PropertyType?.Name;
dest.HideLabel = valEditor?.HideLabel ?? false;
dest.LabelOnTop = originalProp.PropertyType?.LabelOnTop;
// Set variation, the frontend needs this to determine if the content varies by segment
dest.Variations = originalProp.PropertyType?.Variations ?? ContentVariation.Nothing;
@@ -63,21 +58,13 @@ internal class ContentPropertyDisplayMapper : ContentPropertyBasicMapper<Content
dest.Validation.Pattern = originalProp.PropertyType?.ValidationRegExp;
dest.Validation.PatternMessage = originalProp.PropertyType?.ValidationRegExpMessage;
if (dest.PropertyEditor == null)
{
// display.Config = PreValueCollection.AsDictionary(preVals);
// if there is no property editor it means that it is a legacy data type
// we cannot support editing with that so we'll just render the readonly value view.
dest.View = "views/propertyeditors/readonlyvalue/readonlyvalue.html";
}
else
if (dest.PropertyEditor != null)
{
// let the property editor format the pre-values
if (dataType != null)
{
dest.Config = dest.PropertyEditor.GetConfigurationEditor().ToValueEditor(dataType.ConfigurationData);
}
dest.View = valEditor?.View;
}
// Translate

View File

@@ -50,32 +50,23 @@ public class DataTypeMapDefinition : IMapDefinition
private static void Map(IDataEditor source, PropertyEditorBasic target, MapperContext context)
{
target.Alias = source.Alias;
target.Icon = source.Icon;
target.Name = source.Name;
}
// Umbraco.Code.MapAll -Value
private static void Map(ConfigurationField source, DataTypeConfigurationFieldDisplay target, MapperContext context)
{
target.Config = source.Config;
target.Description = source.Description;
target.HideLabel = source.HideLabel;
target.Key = source.Key;
target.Name = source.Name;
target.View = source.View;
}
// Umbraco.Code.MapAll -Udi -HasPrevalues -IsSystemDataType -Id -Trashed -Key
// Umbraco.Code.MapAll -ParentId -Path
// Umbraco.Code.MapAll -ParentId -Path -Icon -Name
private static void Map(IDataEditor source, DataTypeBasic target, MapperContext context)
{
target.Alias = source.Alias;
target.Group = source.Group;
target.Icon = source.Icon;
target.Name = source.Name;
}
// Umbraco.Code.MapAll -HasPrevalues
// Umbraco.Code.MapAll -HasPrevalues -Icon
private void Map(IDataType source, DataTypeBasic target, MapperContext context)
{
target.Id = source.Id;
@@ -93,11 +84,9 @@ public class DataTypeMapDefinition : IMapDefinition
}
target.Alias = editor.Alias;
target.Group = editor.Group;
target.Icon = editor.Icon;
}
// Umbraco.Code.MapAll -HasPrevalues
// Umbraco.Code.MapAll -HasPrevalues -Icon
private void Map(IDataType source, DataTypeDisplay target, MapperContext context)
{
target.AvailableEditors = MapAvailableEditors(source, context);
@@ -118,8 +107,6 @@ public class DataTypeMapDefinition : IMapDefinition
}
target.Alias = editor.Alias;
target.Group = editor.Group;
target.Icon = editor.Icon;
}
// Umbraco.Code.MapAll -CreateDate -DeleteDate -UpdateDate
@@ -139,7 +126,7 @@ public class DataTypeMapDefinition : IMapDefinition
IOrderedEnumerable<IDataEditor> properties = _propertyEditors
.Where(x => !x.IsDeprecated || _contentSettings.ShowDeprecatedPropertyEditors ||
source.EditorAlias == x.Alias)
.OrderBy(x => x.Name);
.OrderBy(x => x.Alias);
return context.MapEnumerable<IDataEditor, PropertyEditorBasic>(properties).WhereNotNull();
}

View File

@@ -1,86 +0,0 @@
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Models.Mapping;
public class MacroMapDefinition : IMapDefinition
{
private readonly ILogger<MacroMapDefinition> _logger;
private readonly ParameterEditorCollection _parameterEditors;
public MacroMapDefinition(ParameterEditorCollection parameterEditors, ILogger<MacroMapDefinition> logger)
{
_parameterEditors = parameterEditors;
_logger = logger;
}
public void DefineMaps(IUmbracoMapper mapper)
{
mapper.Define<IMacro, EntityBasic>((source, context) => new EntityBasic(), Map);
mapper.Define<IMacro, MacroDisplay>((source, context) => new MacroDisplay(), Map);
mapper.Define<IMacro, IEnumerable<MacroParameter>>((source, context) =>
context.MapEnumerable<IMacroProperty, MacroParameter>(source.Properties.Values).WhereNotNull());
mapper.Define<IMacroProperty, MacroParameter>((source, context) => new MacroParameter(), Map);
}
// Umbraco.Code.MapAll -Trashed -AdditionalData
private static void Map(IMacro source, EntityBasic target, MapperContext context)
{
target.Alias = source.Alias;
target.Icon = Constants.Icons.Macro;
target.Id = source.Id;
target.Key = source.Key;
target.Name = source.Name;
target.ParentId = -1;
target.Path = "-1," + source.Id;
target.Udi = Udi.Create(Constants.UdiEntityType.Macro, source.Key);
}
private void Map(IMacro source, MacroDisplay target, MapperContext context)
{
target.Alias = source.Alias;
target.Icon = Constants.Icons.Macro;
target.Id = source.Id;
target.Key = source.Key;
target.Name = source.Name;
target.ParentId = -1;
target.Path = "-1," + source.Id;
target.Udi = Udi.Create(Constants.UdiEntityType.Macro, source.Key);
target.CacheByPage = source.CacheByPage;
target.CacheByUser = source.CacheByMember;
target.CachePeriod = source.CacheDuration;
target.UseInEditor = source.UseInEditor;
target.RenderInEditor = !source.DontRender;
target.View = source.MacroSource;
}
// Umbraco.Code.MapAll -Value
private void Map(IMacroProperty source, MacroParameter target, MapperContext context)
{
target.Alias = source.Alias;
target.Name = source.Name;
target.SortOrder = source.SortOrder;
// map the view and the config
// we need to show the deprecated ones for backwards compatibility
IDataEditor? paramEditor = _parameterEditors[source.EditorAlias]; // TODO: include/filter deprecated?!
if (paramEditor == null)
{
// we'll just map this to a text box
paramEditor = _parameterEditors[Constants.PropertyEditors.Aliases.TextBox];
_logger.LogWarning(
"Could not resolve a parameter editor with alias {PropertyEditorAlias}, a textbox will be rendered in it's place",
source.EditorAlias);
}
target.View = paramEditor?.GetValueEditor().View;
// sets the parameter configuration to be the default configuration editor's configuration,
// ie configurationEditor.DefaultConfigurationObject, prepared for the value editor
IConfigurationEditor? configurationEditor = paramEditor?.GetConfigurationEditor();
target.Configuration = configurationEditor?.FromConfigurationEditor(configurationEditor.DefaultConfiguration);
}
}

View File

@@ -151,8 +151,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
prop.IsSensitive = true;
// mark this property as readonly so that it does not post any data
prop.Readonly = true;
// replace this editor with a sensitive value
prop.View = "sensitivevalue";
// clear the value
prop.Value = null;
}
@@ -180,7 +178,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Value = member.Username
};
prop.View = "textbox";
prop.Validation.Mandatory = true;
return prop;
}
@@ -224,7 +221,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email",
Label = _localizedTextService.Localize("general","email"),
Value = member.Email,
View = "email",
Validation = { Mandatory = true }
},
new()
@@ -236,7 +232,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
// TODO: why ignoreCase, what are we doing here?!
{ "newPassword", member.GetAdditionalDataValueIgnoreCase("NewPassword", null) }
},
View = "changepassword",
Config = GetPasswordConfig(member) // Initialize the dictionary with the configuration from the default membership provider
},
new()
@@ -244,7 +239,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup",
Label = _localizedTextService.Localize("content","membergroup"),
Value = GetMemberGroupValue(member.Username),
View = "membergroups",
Config = new Dictionary<string, object>
{
{ "IsRequired", true }
@@ -257,7 +251,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}failedPasswordAttempts",
Label = _localizedTextService.Localize("user", "failedPasswordAttempts"),
Value = member.FailedPasswordAttempts,
View = "readonlyvalue",
IsSensitive = true,
},
@@ -266,7 +259,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}approved",
Label = _localizedTextService.Localize("user", "stateApproved"),
Value = member.IsApproved,
View = "boolean",
IsSensitive = true,
Readonly = false,
},
@@ -276,7 +268,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lockedOut",
Label = _localizedTextService.Localize("user", "stateLockedOut"),
Value = member.IsLockedOut,
View = "boolean",
IsSensitive = true,
Readonly = !member.IsLockedOut, // IMember.IsLockedOut can't be set to true, so make it readonly when that's the case (you can only unlock)
},
@@ -287,7 +278,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}twoFactorEnabled",
Label = _localizedTextService.Localize("member", "2fa"),
Value = isTwoFactorEnabled,
View = "boolean",
IsSensitive = true,
Readonly = !isTwoFactorEnabled, // The value can't be set to true, so make it readonly when that's the case (you can only disable)
},
@@ -297,7 +287,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLockoutDate",
Label = _localizedTextService.Localize("user", "lastLockoutDate"),
Value = member.LastLockoutDate?.ToString(),
View = "readonlyvalue",
IsSensitive = true,
},
@@ -306,7 +295,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLoginDate",
Label = _localizedTextService.Localize("user", "lastLogin"),
Value = member.LastLoginDate?.ToString(),
View = "readonlyvalue",
IsSensitive = true,
},
@@ -315,7 +303,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastPasswordChangeDate",
Label = _localizedTextService.Localize("user", "lastPasswordChangeDate"),
Value = member.LastPasswordChangeDate?.ToString(),
View = "readonlyvalue",
IsSensitive = true,
},
};
@@ -328,7 +315,6 @@ public class MemberTabsAndPropertiesMapper : TabsAndPropertiesMapper<IMember>
if (property.IsSensitive)
{
property.Value = null;
property.View = "sensitivevalue";
property.Readonly = true;
}
}

View File

@@ -272,7 +272,6 @@ public class PropertyTypeGroupMapper<TPropertyType>
PatternMessage = p.ValidationRegExpMessage,
},
Label = p.Name,
View = propertyEditor?.GetValueEditor().View,
Config = config,
// Value = "",
@@ -281,7 +280,6 @@ public class PropertyTypeGroupMapper<TPropertyType>
DataTypeId = p.DataTypeId,
DataTypeKey = p.DataTypeKey,
DataTypeName = dataType?.Name,
DataTypeIcon = propertyEditor?.Icon,
SortOrder = p.SortOrder,
ContentTypeId = contentType.Id,
ContentTypeName = contentType.Name,