Fixes: U4-3309 Dashboards cannot have multiple area elements
This commit is contained in:
32
src/Umbraco.Core/Configuration/Dashboard/AreaCollection.cs
Normal file
32
src/Umbraco.Core/Configuration/Dashboard/AreaCollection.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
internal class AreaCollection : ConfigurationElementCollection, IEnumerable<IArea>
|
||||
{
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new AreaElement();
|
||||
}
|
||||
|
||||
protected override object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((AreaElement) element).Value;
|
||||
}
|
||||
|
||||
IEnumerator<IArea> IEnumerable<IArea>.GetEnumerator()
|
||||
{
|
||||
for (var i = 0; i < Count; i++)
|
||||
{
|
||||
yield return BaseGet(i) as IArea;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/Umbraco.Core/Configuration/Dashboard/AreaElement.cs
Normal file
12
src/Umbraco.Core/Configuration/Dashboard/AreaElement.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
internal class AreaElement : InnerTextConfigurationElement<string>, IArea
|
||||
{
|
||||
string IArea.AreaName
|
||||
{
|
||||
get { return Value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,14 @@
|
||||
|
||||
namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
internal class AreasElement : ConfigurationElement, IArea
|
||||
internal class AreasElement : ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("area", IsRequired = true)]
|
||||
public InnerTextConfigurationElement<string> AreaName
|
||||
[ConfigurationCollection(typeof(SectionCollection), AddItemName = "area")]
|
||||
[ConfigurationProperty("", IsDefaultCollection = true)]
|
||||
public AreaCollection AreaCollection
|
||||
{
|
||||
get { return (InnerTextConfigurationElement<string>)this["area"]; }
|
||||
}
|
||||
|
||||
string IArea.AreaName
|
||||
{
|
||||
get { return AreaName; }
|
||||
get { return (AreaCollection)base[""]; }
|
||||
set { base[""] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
string Alias { get; }
|
||||
|
||||
string Area { get; }
|
||||
IEnumerable<string> Areas { get; }
|
||||
|
||||
IEnumerable<IDashboardTab> Tabs { get; }
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace Umbraco.Core.Configuration.Dashboard
|
||||
}
|
||||
|
||||
[ConfigurationProperty("areas", IsRequired = true)]
|
||||
public AreasElement Area
|
||||
public AreasElement Areas
|
||||
{
|
||||
get { return (AreasElement)this["areas"]; }
|
||||
}
|
||||
@@ -35,10 +36,10 @@ namespace Umbraco.Core.Configuration.Dashboard
|
||||
{
|
||||
get { return TabCollection; }
|
||||
}
|
||||
|
||||
string ISection.Area
|
||||
|
||||
IEnumerable<string> ISection.Areas
|
||||
{
|
||||
get { return Area.AreaName; }
|
||||
get { return Areas.AreaCollection.Cast<AreaElement>().Select(x => x.Value); }
|
||||
}
|
||||
|
||||
IAccess ISection.AccessRights
|
||||
|
||||
@@ -159,6 +159,8 @@
|
||||
<Compile Include="Configuration\Dashboard\AccessElement.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AccessItem.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AccessType.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AreaCollection.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AreaElement.cs" />
|
||||
<Compile Include="Configuration\Dashboard\AreasElement.cs" />
|
||||
<Compile Include="Configuration\Dashboard\ControlCollection.cs" />
|
||||
<Compile Include="Configuration\Dashboard\ControlElement.cs" />
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
|
||||
<section alias="StartupMemberDashboardSection">
|
||||
<areas>
|
||||
<area>default</area>
|
||||
<area>member</area>
|
||||
</areas>
|
||||
<tab caption="Get Started">
|
||||
|
||||
@@ -41,11 +41,12 @@ namespace Umbraco.Tests.Configurations.DashboardSettings
|
||||
[Test]
|
||||
public void Test_Section_Area()
|
||||
{
|
||||
Assert.AreEqual("settings", SettingsSection.Sections.ElementAt(0).Area);
|
||||
Assert.AreEqual("developer", SettingsSection.Sections.ElementAt(1).Area);
|
||||
Assert.AreEqual("media", SettingsSection.Sections.ElementAt(2).Area);
|
||||
Assert.AreEqual("content", SettingsSection.Sections.ElementAt(3).Area);
|
||||
Assert.AreEqual("member", SettingsSection.Sections.ElementAt(4).Area);
|
||||
Assert.AreEqual("settings", SettingsSection.Sections.ElementAt(0).Areas.First());
|
||||
Assert.AreEqual("developer", SettingsSection.Sections.ElementAt(1).Areas.First());
|
||||
Assert.AreEqual("media", SettingsSection.Sections.ElementAt(2).Areas.First());
|
||||
Assert.AreEqual("content", SettingsSection.Sections.ElementAt(3).Areas.First());
|
||||
Assert.AreEqual("default", SettingsSection.Sections.ElementAt(4).Areas.First());
|
||||
Assert.AreEqual("member", SettingsSection.Sections.ElementAt(4).Areas.Last());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Web.Editors
|
||||
var tabs = new List<Tab<DashboardControl>>();
|
||||
|
||||
var dashboardSection = UmbracoConfig.For.DashboardSettings()
|
||||
.Sections.FirstOrDefault(x => x.Area.InvariantEquals(section));
|
||||
.Sections.FirstOrDefault(x => x.Areas.Contains(section));
|
||||
|
||||
//if we cannot find it for whatever reason just return an empty one.
|
||||
if (dashboardSection == null)
|
||||
|
||||
Reference in New Issue
Block a user