Set default tree group for core trees (#11801)

Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>
This commit is contained in:
Bjarne Fyrstenborg
2022-01-12 12:35:48 +01:00
committed by GitHub
parent d5ba5be096
commit eb4acba081
2 changed files with 14 additions and 2 deletions

View File

@@ -430,10 +430,16 @@ namespace Umbraco.Extensions
where T : Attribute
{
if (type == null) return Enumerable.Empty<T>();
return type.GetCustomAttributes(typeof (T), inherited).OfType<T>();
return type.GetCustomAttributes(typeof(T), inherited).OfType<T>();
}
/// <summary>
public static bool HasCustomAttribute<T>(this Type type, bool inherit)
where T : Attribute
{
return type.GetCustomAttribute<T>(inherit) != null;
}
/// <summary>
/// Tries to return a value based on a property name for an object but ignores case sensitivity
/// </summary>
/// <param name="type"></param>

View File

@@ -48,6 +48,12 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
var attribute = controllerType.GetCustomAttribute<TreeAttribute>(false);
if (attribute == null) return;
bool isCoreTree = controllerType.HasCustomAttribute<CoreTreeAttribute>(false);
// Use section as tree group if core tree, so it isn't grouped by empty key and thus end up in "Third Party" tree group if adding custom tree nodes in other groups, e.g. "Settings" tree group.
attribute.TreeGroup = attribute.TreeGroup ?? (isCoreTree ? attribute.SectionAlias : attribute.TreeGroup);
var tree = new Tree(attribute.SortOrder, attribute.SectionAlias, attribute.TreeGroup, attribute.TreeAlias, attribute.TreeTitle, attribute.TreeUse, controllerType, attribute.IsSingleNodeTree);
_trees.Add(tree);
}