diff --git a/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs b/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs index 36a417e957..1c05da8906 100644 --- a/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs +++ b/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Umbraco.Core; using Umbraco.Core.Composing; @@ -9,8 +10,22 @@ namespace Umbraco.Web.Dashboards { public class DashboardCollectionBuilder : WeightedCollectionBuilderBase { + private Dictionary _customWeights = new Dictionary(); + protected override DashboardCollectionBuilder This => this; + /// + /// Changes the default weight of a dashboard + /// + /// The type of dashboard + /// The new dashboard weight + /// + public DashboardCollectionBuilder SetWeight(int weight) where T : IDashboard + { + _customWeights[typeof(T)] = weight; + return this; + } + protected override IEnumerable CreateItems(IFactory factory) { // get the manifest parser just-in-time - injecting it in the ctor would mean that @@ -32,6 +47,12 @@ namespace Umbraco.Web.Dashboards private int GetWeight(IDashboard dashboard) { + var typeOfDashboard = dashboard.GetType(); + if(_customWeights.ContainsKey(typeOfDashboard)) + { + return _customWeights[typeOfDashboard]; + } + switch (dashboard) { case ManifestDashboard manifestDashboardDefinition: