Skip to content
Merged
12 changes: 12 additions & 0 deletions src/Umbraco.Core/Constants-DataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public static class DataTypes
public const int LabelDateTime = -94;
public const int LabelTime = -98;
public const int LabelDecimal = -99;
public const int LabelBytes = -104;
public const int LabelPixels = -105;

public const int Textarea = -89;
public const int Textbox = -88;
Expand Down Expand Up @@ -225,6 +227,16 @@ public static class Guids
/// </summary>
public const string LabelDecimal = "8f1ef1e1-9de4-40d3-a072-6673f631ca64";

/// <summary>
/// Guid for Label as bytes
/// </summary>
public const string LabelBytes = "ba5bdbe6-ab3e-46a8-82b3-2c45f10bc47f";

/// <summary>
/// Guid for Label as pixels
/// </summary>
public const string LabelPixels = "5eb57825-e15e-4fc7-8e37-fca65cdafbde";

/// <summary>
/// Guid for Content Picker
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@
InsertDataTypeNodeDto(Constants.DataTypes.LabelTime, 38, Constants.DataTypes.Guids.LabelTime, "Label (time)");
InsertDataTypeNodeDto(Constants.DataTypes.LabelDecimal, 39, Constants.DataTypes.Guids.LabelDecimal,
"Label (decimal)");
InsertDataTypeNodeDto(Constants.DataTypes.LabelBytes, 40, Constants.DataTypes.Guids.LabelBytes,
"Label (bytes)");
InsertDataTypeNodeDto(Constants.DataTypes.LabelPixels, 41, Constants.DataTypes.Guids.LabelPixels,
"Label (pixels)");

ConditionalInsert(
Constants.Configuration.NamedOptions.InstallDefaultData.DataTypes,
Expand Down Expand Up @@ -1454,59 +1458,59 @@
{
Id = 7,
UniqueId = new Guid("A68D453B-1F62-44F4-9F71-0B6BBD43C355"),
DataTypeId = Constants.DataTypes.LabelInt,
DataTypeId = Constants.DataTypes.LabelPixels,
ContentTypeId = 1032,
PropertyTypeGroupId = 3,
Alias = Constants.Conventions.Media.Width,
Name = "Width",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in pixels",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false,
new PropertyTypeDto
{
Id = 8,
UniqueId = new Guid("854087F6-648B-40ED-BC98-B8A9789E80B9"),
DataTypeId = Constants.DataTypes.LabelInt,
DataTypeId = Constants.DataTypes.LabelPixels,
ContentTypeId = 1032,
PropertyTypeGroupId = 3,
Alias = Constants.Conventions.Media.Height,
Name = "Height",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in pixels",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false,
new PropertyTypeDto
{
Id = 9,
UniqueId = new Guid("BD4C5ACE-26E3-4A8B-AF1A-E8206A35FA07"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1032,
PropertyTypeGroupId = 3,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
_database.Insert(Constants.DatabaseSchema.Tables.PropertyType, "id", false,
new PropertyTypeDto
{
Id = 10,
UniqueId = new Guid("F7786FE8-724A-4ED0-B244-72546DB32A92"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1032,
PropertyTypeGroupId = 3,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand Down Expand Up @@ -1538,11 +1542,11 @@
{
Id = 25,
UniqueId = new Guid("3531C0A3-4E0A-4324-A621-B9D3822B071F"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1033,
PropertyTypeGroupId = 4,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand All @@ -1554,15 +1558,15 @@
{
Id = 26,
UniqueId = new Guid("F9527050-59BC-43E4-8FA8-1658D1319FF5"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1033,
PropertyTypeGroupId = 4,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
}
Expand Down Expand Up @@ -1590,11 +1594,11 @@
{
Id = 41,
UniqueId = new Guid("EDD2B3FD-1E57-4E57-935E-096DEFCCDC9B"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1034,
PropertyTypeGroupId = 52,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand All @@ -1606,15 +1610,15 @@
{
Id = 42,
UniqueId = new Guid("180EEECF-1F00-409E-8234-BBA967E08B0A"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1034,
PropertyTypeGroupId = 52,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
}
Expand Down Expand Up @@ -1642,11 +1646,11 @@
{
Id = 44,
UniqueId = new Guid("1BEE433F-A21A-4031-8E03-AF01BB8D2DE9"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1035,
PropertyTypeGroupId = 53,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand All @@ -1658,15 +1662,15 @@
{
Id = 45,
UniqueId = new Guid("3CBF538A-29AB-4317-A9EB-BBCDF1A54260"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1035,
PropertyTypeGroupId = 53,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
}
Expand Down Expand Up @@ -1694,11 +1698,11 @@
{
Id = 47,
UniqueId = new Guid("EF1B4AF7-36DE-45EB-8C18-A2DE07319227"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1036,
PropertyTypeGroupId = 54,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand All @@ -1710,15 +1714,15 @@
{
Id = 48,
UniqueId = new Guid("AAB7D00C-7209-4337-BE3F-A4421C8D79A0"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1036,
PropertyTypeGroupId = 54,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
}
Expand Down Expand Up @@ -1746,11 +1750,11 @@
{
Id = 50,
UniqueId = new Guid("0F25A89E-2EB7-49BC-A7B4-759A7E4C69F2"),
DataTypeId = -92,
DataTypeId = Constants.DataTypes.LabelString,
ContentTypeId = 1037,
PropertyTypeGroupId = 55,
Alias = Constants.Conventions.Media.Extension,
Name = "Type",
Name = "File extension",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Expand All @@ -1762,15 +1766,15 @@
{
Id = 51,
UniqueId = new Guid("09A07AFF-861D-4769-A2B0-C165EBD43D39"),
DataTypeId = Constants.DataTypes.LabelBigint,
DataTypeId = Constants.DataTypes.LabelBytes,
ContentTypeId = 1037,
PropertyTypeGroupId = 55,
Alias = Constants.Conventions.Media.Bytes,
Name = "Size",
Name = "File size",
SortOrder = 0,
Mandatory = false,
ValidationRegExp = null,
Description = "in bytes",
Description = null,
Variations = (byte)ContentVariation.Nothing,
});
}
Expand Down Expand Up @@ -1995,6 +1999,10 @@
"Umb.PropertyEditorUi.Label", "Decimal", "{\"umbracoDataValueType\":\"DECIMAL\"}");
InsertDataTypeDto(Constants.DataTypes.LabelTime, Constants.PropertyEditors.Aliases.Label,
"Umb.PropertyEditorUi.Label", "Date", "{\"umbracoDataValueType\":\"TIME\"}");
InsertDataTypeDto(Constants.DataTypes.LabelBytes, Constants.PropertyEditors.Aliases.Label,
"Umb.PropertyEditorUi.Label", "Nvarchar", "{\"umbracoDataValueType\":\"BIGINT\", \"labelTemplate\":\"{=value | bytes}\"}");
InsertDataTypeDto(Constants.DataTypes.LabelPixels, Constants.PropertyEditors.Aliases.Label,
"Umb.PropertyEditorUi.Label", "Integer", "{\"umbracoDataValueType\":\"INT\", \"labelTemplate\":\"{=value}px\"}");

Check warning on line 2005 in src/Umbraco.Infrastructure/Migrations/Install/DatabaseDataCreator.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

CreateDataTypeData already has high cyclomatic complexity, and now it increases in Lines of Code from 348 to 352. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

if (_database.Exists<NodeDto>(Constants.DataTypes.DateTime))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ protected virtual void DefinePlan()

// To 16.3.0
To<V_16_3_0.AddRichTextEditorCapabilities>("{A917FCBC-C378-4A08-A36C-220C581A6581}");
To<V_16_3_0.MigrateMediaTypeLabelProperties>("{FB7073AF-DFAF-4AC1-800D-91F9BD5B5238}");
}
}
Loading