Update IContentTypeBase to use group names as property groups (no parent/level 1) for backwards compatibility

This commit is contained in:
Ronald Barendse
2021-06-17 10:05:21 +02:00
parent 70403cf8b0
commit 0e63edb375
2 changed files with 7 additions and 8 deletions

View File

@@ -348,7 +348,7 @@ namespace Umbraco.Core.Models
// get new group, if required, and ensure it exists
var newPropertyGroup = propertyGroupName == null
? null
: PropertyGroups.FirstOrDefault(x => x.Name == propertyGroupName);
: PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1);
if (propertyGroupName != null && newPropertyGroup == null) return false;
// get old group
@@ -403,11 +403,11 @@ namespace Umbraco.Core.Models
public void RemovePropertyGroup(string propertyGroupName)
{
// if no group exists with that name, do nothing
var group = PropertyGroups[propertyGroupName];
var group = PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1);
if (group == null) return;
// first remove the group
PropertyGroups.RemoveItem(propertyGroupName);
PropertyGroups.Remove(group);
// Then re-assign the group's properties to no group
foreach (var property in group.PropertyTypes)

View File

@@ -218,7 +218,7 @@ namespace Umbraco.Core.Models
private PropertyGroup AddAndReturnPropertyGroup(string name)
{
// ensure we don't have it already
if (PropertyGroups.Any(x => x.Name == name))
if (PropertyGroups.Any(x => x.Name.InvariantEquals(name) && x.ParentKey == null && x.Level == 1))
return null;
// create the new group
@@ -227,7 +227,7 @@ namespace Umbraco.Core.Models
// check if it is inherited - there might be more than 1 but we want the 1st, to
// reuse its sort order - if there are more than 1 and they have different sort
// orders... there isn't much we can do anyways
var inheritGroup = CompositionPropertyGroups.FirstOrDefault(x => x.Name == name);
var inheritGroup = CompositionPropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(name) && x.ParentKey == null && x.Level == 1);
if (inheritGroup == null)
{
// no, just local, set sort order
@@ -260,9 +260,8 @@ namespace Umbraco.Core.Models
return false;
// get and ensure a group local to this content type
var group = PropertyGroups.Contains(propertyGroupName)
? PropertyGroups[propertyGroupName]
: AddAndReturnPropertyGroup(propertyGroupName);
var group = PropertyGroups.FirstOrDefault(x => x.Name.InvariantEquals(propertyGroupName) && x.ParentKey == null && x.Level == 1)
??AddAndReturnPropertyGroup(propertyGroupName);
if (group == null)
return false;