From 162b90194de27d3353aba0dbe53bc5bc6cc14a8b Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 3 Dec 2018 16:14:49 +1100 Subject: [PATCH] Gets sln building, removes old legacy settings, removes ascx dashboard support --- .../tools/Dashboard.config.install.xdt | 12 +- .../Configuration/Dashboard/ControlElement.cs | 25 +-- .../Dashboard/IDashboardControl.cs | 4 - src/Umbraco.Core/Manifest/ManifestBuilder.cs | 204 ------------------ .../Manifest/ManifestDashboardControl.cs | 13 ++ .../Manifest/ManifestDashboardSection.cs | 20 ++ .../Manifest/ManifestDashboardTab.cs | 20 ++ src/Umbraco.Core/Manifest/ManifestParser.cs | 37 +++- src/Umbraco.Core/Manifest/PackageManifest.cs | 6 +- .../ContentEditing/IContentAppDefinition.cs | 1 + src/Umbraco.Core/Umbraco.Core.csproj | 3 + .../DashboardSettings/Dashboard.config | 32 +-- .../DashboardSettingsTests.cs | 4 - .../src/views/common/dashboard.html | 11 +- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 8 - .../Umbraco/dashboard/UserControlProxy.aspx | 25 --- .../dashboard/UserControlProxy.aspx.cs | 40 ---- .../UserControlProxy.aspx.designer.cs | 69 ------ .../config/Dashboard.Release.config | 10 +- src/Umbraco.Web.UI/config/Dashboard.config | 12 +- .../Editors/DashboardController.cs | 12 +- src/Umbraco.Web/Editors/DashboardHelper.cs | 35 +-- src/Umbraco.Web/Editors/SectionController.cs | 15 +- .../Models/ContentEditing/DashboardControl.cs | 9 - .../Runtime/WebRuntimeComponent.cs | 2 + 25 files changed, 172 insertions(+), 457 deletions(-) delete mode 100644 src/Umbraco.Core/Manifest/ManifestBuilder.cs create mode 100644 src/Umbraco.Core/Manifest/ManifestDashboardControl.cs create mode 100644 src/Umbraco.Core/Manifest/ManifestDashboardSection.cs create mode 100644 src/Umbraco.Core/Manifest/ManifestDashboardTab.cs delete mode 100644 src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx delete mode 100644 src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.cs delete mode 100644 src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.designer.cs diff --git a/build/NuSpecs/tools/Dashboard.config.install.xdt b/build/NuSpecs/tools/Dashboard.config.install.xdt index 036beeba29..a81af8c365 100644 --- a/build/NuSpecs/tools/Dashboard.config.install.xdt +++ b/build/NuSpecs/tools/Dashboard.config.install.xdt @@ -3,7 +3,7 @@
- + views/dashboard/settings/settingsdashboardintro.html @@ -14,7 +14,7 @@ forms - + views/dashboard/forms/formsdashboardintro.html @@ -28,7 +28,7 @@
- + views/dashboard/developer/developerdashboardvideos.html @@ -47,7 +47,7 @@ - + views/dashboard/media/mediafolderbrowser.html @@ -56,7 +56,7 @@
- + views/dashboard/members/membersdashboardvideos.html @@ -92,4 +92,4 @@
- \ No newline at end of file + diff --git a/src/Umbraco.Core/Configuration/Dashboard/ControlElement.cs b/src/Umbraco.Core/Configuration/Dashboard/ControlElement.cs index 0434eea47e..0093c57778 100644 --- a/src/Umbraco.Core/Configuration/Dashboard/ControlElement.cs +++ b/src/Umbraco.Core/Configuration/Dashboard/ControlElement.cs @@ -8,25 +8,6 @@ namespace Umbraco.Core.Configuration.Dashboard internal class ControlElement : RawXmlConfigurationElement, IDashboardControl { - public bool ShowOnce - { - get - { - return RawXml.Attribute("showOnce") == null - ? false - : bool.Parse(RawXml.Attribute("showOnce").Value); - } - } - - public bool AddPanel - { - get - { - return RawXml.Attribute("addPanel") == null - ? true - : bool.Parse(RawXml.Attribute("addPanel").Value); - } - } public string PanelCaption { @@ -37,7 +18,6 @@ namespace Umbraco.Core.Configuration.Dashboard : RawXml.Attribute("panelCaption").Value; } } - public AccessElement Access { get @@ -66,9 +46,6 @@ namespace Umbraco.Core.Configuration.Dashboard } - IAccess IDashboardControl.AccessRights - { - get { return Access; } - } + IAccess IDashboardControl.AccessRights => Access; } } diff --git a/src/Umbraco.Core/Configuration/Dashboard/IDashboardControl.cs b/src/Umbraco.Core/Configuration/Dashboard/IDashboardControl.cs index 7dab542258..cdf05af1ec 100644 --- a/src/Umbraco.Core/Configuration/Dashboard/IDashboardControl.cs +++ b/src/Umbraco.Core/Configuration/Dashboard/IDashboardControl.cs @@ -2,10 +2,6 @@ { public interface IDashboardControl { - bool ShowOnce { get; } - - bool AddPanel { get; } - string PanelCaption { get; } string ControlPath { get; } diff --git a/src/Umbraco.Core/Manifest/ManifestBuilder.cs b/src/Umbraco.Core/Manifest/ManifestBuilder.cs deleted file mode 100644 index 6fc803b1f8..0000000000 --- a/src/Umbraco.Core/Manifest/ManifestBuilder.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Newtonsoft.Json; -using Umbraco.Core.Cache; -using Umbraco.Core.IO; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Core.Manifest -{ - /// - /// This reads in the manifests and stores some definitions in memory so we can look them on the server side - /// - internal class ManifestBuilder - { - private readonly IRuntimeCacheProvider _runtimeCache; - private readonly ManifestParser _parser; - - public ManifestBuilder(IRuntimeCacheProvider cache, ManifestParser parser) - { - _runtimeCache = cache; - _parser = parser; - } - - public const string GridEditorsKey = "gridEditors"; - public const string PropertyEditorsKey = "propertyEditors"; - public const string ParameterEditorsKey = "parameterEditors"; - public const string DashboardsKey = "dashboards"; - - /// - /// Returns all grid editors found in the manfifests - /// - internal IEnumerable GridEditors - { - get - { - return _runtimeCache.GetCacheItem>( - typeof (ManifestBuilder) + GridEditorsKey, - () => - { - var editors = new List(); - foreach (var manifest in _parser.GetManifests()) - { - if (manifest.GridEditors != null) - { - editors.AddRange(ManifestParser.GetGridEditors(manifest.GridEditors)); - } - - } - return editors; - }, new TimeSpan(0, 10, 0)); - } - } - - /// - /// Returns all property editors found in the manfifests - /// - internal IEnumerable PropertyEditors - { - get - { - return _runtimeCache.GetCacheItem>( - typeof(ManifestBuilder) + PropertyEditorsKey, - () => - { - var editors = new List(); - foreach (var manifest in _parser.GetManifests()) - { - if (manifest.PropertyEditors != null) - { - editors.AddRange(ManifestParser.GetPropertyEditors(manifest.PropertyEditors)); - } - - } - return editors; - }, new TimeSpan(0, 10, 0)); - } - } - - /// - /// Returns all parameter editors found in the manfifests and all property editors that are flagged to be parameter editors - /// - internal IEnumerable ParameterEditors - { - get - { - return _runtimeCache.GetCacheItem>( - typeof (ManifestBuilder) + ParameterEditorsKey, - () => - { - var editors = new List(); - foreach (var manifest in _parser.GetManifests()) - { - if (manifest.ParameterEditors != null) - { - editors.AddRange(ManifestParser.GetParameterEditors(manifest.ParameterEditors)); - } - } - return editors; - }, new TimeSpan(0, 10, 0)); - } - } - - /// - /// Returns all dashboards found in the manfifests - /// - internal IDictionary Dashboards - { - get - { - //TODO: Need to integrate the security with the manifest dashboards - - return _runtimeCache.GetCacheItem>( - typeof(ManifestBuilder) + DashboardsKey, - () => - { - var dashboards = new Dictionary(); - foreach (var manifest in _parser.GetManifests()) - { - if (manifest.Dashboards != null) - { - var converted = manifest.Dashboards.ToDictionary(x => x.Key, x => x.Value.ToObject
()); - foreach (var item in converted) - { - Section existing; - if (dashboards.TryGetValue(item.Key, out existing)) - { - foreach (var area in item.Value.Areas) - { - if (existing.Areas.Contains(area, StringComparer.InvariantCultureIgnoreCase) == false) - existing.Areas.Add(area); - } - - //merge - foreach (var tab in item.Value.Tabs) - { - Tab existingTab; - if (existing.Tabs.TryGetValue(tab.Key, out existingTab)) - { - //merge - foreach (var control in tab.Value.Controls) - { - existingTab.Controls.Add(control); - } - } - else - { - existing.Tabs[tab.Key] = tab.Value; - } - } - ; - } - else - { - dashboards[item.Key] = item.Value; - } - } - } - } - return dashboards; - }, new TimeSpan(0, 10, 0)); - } - } - - #region Internal manifest models - internal class Section - { - public Section() - { - Areas = new List(); - Tabs = new Dictionary(); - } - [JsonProperty("areas")] - public List Areas { get; set; } - [JsonProperty("tabs")] - public IDictionary Tabs { get; set; } - } - - internal class Tab - { - public Tab() - { - Controls = new List(); - Index = int.MaxValue; //default so we can check if this value has been explicitly set - } - [JsonProperty("controls")] - public List Controls { get; set; } - [JsonProperty("index")] - public int Index { get; set; } - } - - internal class Control - { - [JsonProperty("path")] - public string Path { get; set; } - [JsonProperty("caption")] - public string Caption { get; set; } - } - #endregion - - } -} diff --git a/src/Umbraco.Core/Manifest/ManifestDashboardControl.cs b/src/Umbraco.Core/Manifest/ManifestDashboardControl.cs new file mode 100644 index 0000000000..acac5e51fa --- /dev/null +++ b/src/Umbraco.Core/Manifest/ManifestDashboardControl.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace Umbraco.Core.Manifest +{ + public class ManifestDashboardControl + { + [JsonProperty("path")] + public string Path { get; set; } + + [JsonProperty("caption")] + public string Caption { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Manifest/ManifestDashboardSection.cs b/src/Umbraco.Core/Manifest/ManifestDashboardSection.cs new file mode 100644 index 0000000000..e8586c366b --- /dev/null +++ b/src/Umbraco.Core/Manifest/ManifestDashboardSection.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Umbraco.Core.Manifest +{ + public class ManifestDashboardSection + { + public ManifestDashboardSection() + { + Areas = new List(); + Tabs = new Dictionary(); + } + + [JsonProperty("areas")] + public List Areas { get; set; } + + [JsonProperty("tabs")] + public IDictionary Tabs { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Manifest/ManifestDashboardTab.cs b/src/Umbraco.Core/Manifest/ManifestDashboardTab.cs new file mode 100644 index 0000000000..970b1ead89 --- /dev/null +++ b/src/Umbraco.Core/Manifest/ManifestDashboardTab.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Umbraco.Core.Manifest +{ + public class ManifestDashboardTab + { + public ManifestDashboardTab() + { + Controls = new List(); + Index = int.MaxValue; //default so we can check if this value has been explicitly set + } + + [JsonProperty("controls")] + public List Controls { get; set; } + + [JsonProperty("index")] + public int Index { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index 9cba13ea3c..878ecc0b42 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -100,6 +100,7 @@ namespace Umbraco.Core.Manifest var parameterEditors = new List(); var gridEditors = new List(); var contentApps = new List(); + var dashboards = new Dictionary(); foreach (var manifest in manifests) { @@ -109,6 +110,35 @@ namespace Umbraco.Core.Manifest if (manifest.ParameterEditors != null) parameterEditors.AddRange(manifest.ParameterEditors); if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors); if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps); + if (manifest.Dashboards != null) + { + foreach (var item in manifest.Dashboards) + { + if (dashboards.TryGetValue(item.Key, out var existing)) + { + foreach (var area in item.Value.Areas) + if (existing.Areas.Contains(area, StringComparer.InvariantCultureIgnoreCase) == false) + existing.Areas.Add(area); + + //merge + foreach (var tab in item.Value.Tabs) + { + if (existing.Tabs.TryGetValue(tab.Key, out var existingTab)) + { + //merge + foreach (var control in tab.Value.Controls) + { + existingTab.Controls.Add(control); + } + } + else + existing.Tabs[tab.Key] = tab.Value; + } + } + else + dashboards[item.Key] = item.Value; + } + } } return new PackageManifest @@ -118,7 +148,8 @@ namespace Umbraco.Core.Manifest PropertyEditors = propertyEditors.ToArray(), ParameterEditors = parameterEditors.ToArray(), GridEditors = gridEditors.ToArray(), - ContentApps = contentApps.ToArray() + ContentApps = contentApps.ToArray(), + Dashboards = dashboards }; } @@ -151,6 +182,7 @@ namespace Umbraco.Core.Manifest var manifest = JsonConvert.DeserializeObject(text, new DataEditorConverter(_logger), new ValueValidatorConverter(_validators), + //TODO: DO i need a dashboard one? new ContentAppDefinitionConverter()); // scripts and stylesheets are raw string, must process here @@ -165,6 +197,8 @@ namespace Umbraco.Core.Manifest if (ppEditors.Count > 0) manifest.ParameterEditors = manifest.ParameterEditors.Union(ppEditors).ToArray(); + //TODO: Do we need to deal with dashboards or are they auto parsed? + return manifest; } @@ -173,5 +207,6 @@ namespace Umbraco.Core.Manifest { return JsonConvert.DeserializeObject>(text); } + } } diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs index 67bc21a3c4..92c5f89a9c 100644 --- a/src/Umbraco.Core/Manifest/PackageManifest.cs +++ b/src/Umbraco.Core/Manifest/PackageManifest.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.PropertyEditors; @@ -32,6 +33,9 @@ namespace Umbraco.Core.Manifest /// /// The dictionary of dashboards /// - public IDictionary Dashboards { get; set; } + [JsonProperty("dashboards")] + public IReadOnlyDictionary Dashboards { get; set; } = new Dictionary(); + + } } diff --git a/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs b/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs index 2d30fc6ba9..af83c5a2f5 100644 --- a/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs +++ b/src/Umbraco.Core/Models/ContentEditing/IContentAppDefinition.cs @@ -3,6 +3,7 @@ using Umbraco.Core.Models.Membership; namespace Umbraco.Core.Models.ContentEditing { + /// /// Represents a content app definition. /// diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index e46fca3c99..1f21de646d 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -335,6 +335,9 @@ + + + diff --git a/src/Umbraco.Tests/Configurations/DashboardSettings/Dashboard.config b/src/Umbraco.Tests/Configurations/DashboardSettings/Dashboard.config index 4040412603..4c86355a1b 100644 --- a/src/Umbraco.Tests/Configurations/DashboardSettings/Dashboard.config +++ b/src/Umbraco.Tests/Configurations/DashboardSettings/Dashboard.config @@ -6,10 +6,10 @@ settings - + views/dashboard/settings/settingsdashboardintro.html - + views/dashboard/settings/settingsdashboardvideos.html @@ -23,10 +23,10 @@ developer - + views/dashboard/developer/developerdashboardintro.html - + views/dashboard/developer/developerdashboardvideos.html @@ -37,7 +37,7 @@ media - + views/dashboard/media/mediafolderbrowser.html @@ -45,13 +45,13 @@ admin - + views/dashboard/media/mediadashboardintro.html - + views/dashboard/media/desktopmediauploader.html - + views/dashboard/media/mediadashboardvideos.html @@ -70,25 +70,25 @@ admin - + views/dashboard/default/startupdashboardintro.html - + views/dashboard/default/startupdashboardkits.html editor writer - + views/dashboard/default/startupdashboardvideos.html - dashboard/latestEdits.ascx + dashboard/latestEdits.ascx - + views/dashboard/changepassword.html @@ -100,13 +100,13 @@ member - + views/dashboard/members/membersdashboardintro.html - + members/membersearch.ascx - + views/dashboard/members/membersdashboardvideos.html diff --git a/src/Umbraco.Tests/Configurations/DashboardSettings/DashboardSettingsTests.cs b/src/Umbraco.Tests/Configurations/DashboardSettings/DashboardSettingsTests.cs index 862dfb3dc2..f1892bdaf4 100644 --- a/src/Umbraco.Tests/Configurations/DashboardSettings/DashboardSettingsTests.cs +++ b/src/Umbraco.Tests/Configurations/DashboardSettings/DashboardSettingsTests.cs @@ -101,14 +101,10 @@ namespace Umbraco.Tests.Configurations.DashboardSettings [Test] public void Test_Control() { - Assert.AreEqual(true, SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(0).ShowOnce); - Assert.AreEqual(true, SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(0).AddPanel); Assert.AreEqual("hello", SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(0).PanelCaption); Assert.AreEqual("views/dashboard/settings/settingsdashboardintro.html", SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(0).ControlPath); - Assert.AreEqual(false, SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(1).ShowOnce); - Assert.AreEqual(false, SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(1).AddPanel); Assert.AreEqual("", SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(1).PanelCaption); Assert.AreEqual("views/dashboard/settings/settingsdashboardvideos.html", SettingsSection.Sections.ElementAt(0).Tabs.ElementAt(0).Controls.ElementAt(1).ControlPath); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html b/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html index 4cc5eba4a0..6453963670 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dashboard.html @@ -18,18 +18,13 @@ -
+
-
+

{{property.caption}}

-
-

{{property.caption}}

- -
-
@@ -40,4 +35,4 @@ -
\ No newline at end of file +
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index c108cffcf4..b87bcb2b23 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -151,13 +151,6 @@ create.aspx - - UserControlProxy.aspx - ASPXCodeBehind - - - UserControlProxy.aspx - editMacro.aspx ASPXCodeBehind @@ -236,7 +229,6 @@ - diff --git a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx b/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx deleted file mode 100644 index ac59074de3..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx +++ /dev/null @@ -1,25 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserControlProxy.aspx.cs" Inherits="Umbraco.Web.UI.Umbraco.Dashboard.UserControlProxy" %> -<%@ Register TagPrefix="umb" Namespace="ClientDependency.Core.Controls" Assembly="ClientDependency.Core" %> -<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web.UI.JavaScript" Assembly="umbraco" %> - - - - - - - - - - - - - - - -
-
- -
-
- - diff --git a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.cs b/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.cs deleted file mode 100644 index 40caff36c8..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Web.UI; -using Umbraco.Core.IO; - - -namespace Umbraco.Web.UI.Umbraco.Dashboard -{ - public partial class UserControlProxy : Pages.UmbracoEnsuredPage - { - protected void Page_Load(object sender, EventArgs e) - { - - } - - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - - var path = Request.QueryString["ctrl"]; - if (string.IsNullOrEmpty(path) == false) - { - path = IOHelper.FindFile(path); - - try - { - var c = LoadControl(path); - container.Controls.Add(c); - } - catch (Exception ee) - { - container.Controls.Add( - new LiteralControl( - "

Could not load control: '" + path + - "'.
Error message: " + - ee.ToString() + "

")); - } - } - } - } -} diff --git a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.designer.cs b/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.designer.cs deleted file mode 100644 index 5bfa6983d1..0000000000 --- a/src/Umbraco.Web.UI/Umbraco/dashboard/UserControlProxy.aspx.designer.cs +++ /dev/null @@ -1,69 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Web.UI.Umbraco.Dashboard { - - - public partial class UserControlProxy { - - /// - /// ClientLoader control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Umbraco.Web.UI.JavaScript.UmbracoClientDependencyLoader ClientLoader; - - /// - /// CssInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.CssInclude CssInclude1; - - /// - /// JsInclude1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude1; - - /// - /// JsInclude4 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::ClientDependency.Core.Controls.JsInclude JsInclude4; - - /// - /// form1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// - /// container control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder container; - } -} diff --git a/src/Umbraco.Web.UI/config/Dashboard.Release.config b/src/Umbraco.Web.UI/config/Dashboard.Release.config index 0a39395213..0e929e12bc 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.Release.config +++ b/src/Umbraco.Web.UI/config/Dashboard.Release.config @@ -6,7 +6,7 @@ settings - + views/dashboard/settings/settingsdashboardintro.html @@ -27,7 +27,7 @@ forms - + views/dashboard/forms/formsdashboardintro.html @@ -44,7 +44,7 @@ media - + views/dashboard/media/mediafolderbrowser.html @@ -63,7 +63,7 @@ admin - + views/dashboard/default/startupdashboardintro.html @@ -75,7 +75,7 @@ member - + views/dashboard/members/membersdashboardvideos.html diff --git a/src/Umbraco.Web.UI/config/Dashboard.config b/src/Umbraco.Web.UI/config/Dashboard.config index fab6fa6ea3..460a81e10b 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.config +++ b/src/Umbraco.Web.UI/config/Dashboard.config @@ -5,7 +5,7 @@ settings - + views/dashboard/settings/settingsdashboardintro.html @@ -25,7 +25,7 @@ forms - + views/dashboard/forms/formsdashboardintro.html @@ -35,7 +35,7 @@ media - + views/dashboard/media/mediafolderbrowser.html @@ -45,7 +45,7 @@ forms - + views/dashboard/forms/formsdashboardintro.html @@ -61,7 +61,7 @@ admin - + views/dashboard/default/startupdashboardintro.html @@ -71,7 +71,7 @@ member - + views/dashboard/members/membersdashboardvideos.html diff --git a/src/Umbraco.Web/Editors/DashboardController.cs b/src/Umbraco.Web/Editors/DashboardController.cs index 6b5e1490ae..bc7a45d93b 100644 --- a/src/Umbraco.Web/Editors/DashboardController.cs +++ b/src/Umbraco.Web/Editors/DashboardController.cs @@ -3,8 +3,6 @@ using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; -using System.Linq; -using Umbraco.Core.IO; using Newtonsoft.Json.Linq; using System.Threading.Tasks; using System.Net.Http; @@ -27,6 +25,13 @@ namespace Umbraco.Web.Editors [WebApi.UmbracoAuthorize] public class DashboardController : UmbracoApiController { + private readonly DashboardHelper _dashboardHelper; + + public DashboardController(DashboardHelper dashboardHelper) + { + _dashboardHelper = dashboardHelper; + } + //we have just one instance of HttpClient shared for the entire application private static readonly HttpClient HttpClient = new HttpClient(); //we have baseurl as a param to make previewing easier, so we can test with a dev domain from client side @@ -119,8 +124,7 @@ namespace Umbraco.Web.Editors [ValidateAngularAntiForgeryToken] public IEnumerable> GetDashboard(string section) { - var dashboardHelper = new DashboardHelper(ApplicationContext); - return dashboardHelper.GetDashboard(section, Security.CurrentUser); + return _dashboardHelper.GetDashboard(section, Security.CurrentUser); } } } diff --git a/src/Umbraco.Web/Editors/DashboardHelper.cs b/src/Umbraco.Web/Editors/DashboardHelper.cs index fb6136d18b..f128c5b6a6 100644 --- a/src/Umbraco.Web/Editors/DashboardHelper.cs +++ b/src/Umbraco.Web/Editors/DashboardHelper.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Newtonsoft.Json.Linq; using Umbraco.Core; -using Umbraco.Core.Configuration; +using Umbraco.Core.Cache; +using Umbraco.Core.Configuration.Dashboard; using Umbraco.Core.IO; using Umbraco.Core.Manifest; using Umbraco.Core.Models.Membership; @@ -13,14 +13,17 @@ using Umbraco.Web.Models.ContentEditing; namespace Umbraco.Web.Editors { - internal class DashboardHelper + public class DashboardHelper { - private readonly ApplicationContext _appContext; + private readonly ISectionService _sectionService; + private readonly IDashboardSection _dashboardSection; + private readonly ManifestParser _manifestParser; - public DashboardHelper(ApplicationContext appContext) + public DashboardHelper(ISectionService sectionService, IDashboardSection dashboardSection, ManifestParser manifestParser) { - if (appContext == null) throw new ArgumentNullException("appContext"); - _appContext = appContext; + _sectionService = sectionService ?? throw new ArgumentNullException(nameof(sectionService)); + _dashboardSection = dashboardSection; + _manifestParser = manifestParser; } /// @@ -31,7 +34,7 @@ namespace Umbraco.Web.Editors public IDictionary>> GetDashboards(IUser currentUser) { var result = new Dictionary>>(); - foreach (var section in _appContext.Services.SectionService.GetSections()) + foreach (var section in _sectionService.GetSections()) { result[section.Alias] = GetDashboard(section.Alias, currentUser); } @@ -87,24 +90,24 @@ namespace Umbraco.Web.Editors //disable packages section dashboard if (section == "packages") return tabs; - foreach (var dashboardSection in UmbracoConfig.For.DashboardSettings().Sections.Where(x => x.Areas.Contains(section))) + foreach (var dashboardSection in _dashboardSection.Sections.Where(x => x.Areas.Contains(section))) { //we need to validate access to this section - if (DashboardSecurity.AuthorizeAccess(dashboardSection, currentUser, _appContext.Services.SectionService) == false) + if (DashboardSecurity.AuthorizeAccess(dashboardSection, currentUser, _sectionService) == false) continue; //User is authorized foreach (var tab in dashboardSection.Tabs) { //we need to validate access to this tab - if (DashboardSecurity.AuthorizeAccess(tab, currentUser, _appContext.Services.SectionService) == false) + if (DashboardSecurity.AuthorizeAccess(tab, currentUser, _sectionService) == false) continue; var dashboardControls = new List(); foreach (var control in tab.Controls) { - if (DashboardSecurity.AuthorizeAccess(control, currentUser, _appContext.Services.SectionService) == false) + if (DashboardSecurity.AuthorizeAccess(control, currentUser, _sectionService) == false) continue; var dashboardControl = new DashboardControl(); @@ -112,7 +115,7 @@ namespace Umbraco.Web.Editors dashboardControl.Caption = control.PanelCaption; dashboardControl.Path = IOHelper.FindFile(controlPath); if (controlPath.ToLowerInvariant().EndsWith(".ascx".ToLowerInvariant())) - dashboardControl.ServerSide = true; + throw new NotSupportedException("Legacy UserControl (.ascx) dashboards are no longer supported"); dashboardControls.Add(dashboardControl); } @@ -138,13 +141,11 @@ namespace Umbraco.Web.Editors //TODO: Need to integrate the security with the manifest dashboards var appPlugins = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)); - var parser = new ManifestParser(appPlugins, _appContext.ApplicationCache.RuntimeCache); - var builder = new ManifestBuilder(_appContext.ApplicationCache.RuntimeCache, parser); var tabs = new List>(); var i = startTabId; - foreach (var sectionDashboard in builder.Dashboards.Where(x => x.Value.Areas.InvariantContains(section))) + foreach (var sectionDashboard in _manifestParser.Manifest.Dashboards.Where(x => x.Value.Areas.InvariantContains(section))) { foreach (var tab in sectionDashboard.Value.Tabs) { @@ -157,7 +158,7 @@ namespace Umbraco.Web.Editors dashboardControl.Caption = control.Caption; dashboardControl.Path = IOHelper.FindFile(controlPath); if (controlPath.ToLowerInvariant().EndsWith(".ascx".ToLowerInvariant())) - dashboardControl.ServerSide = true; + throw new NotSupportedException("Legacy UserControl (.ascx) dashboards are no longer supported"); dashboardControls.Add(dashboardControl); } diff --git a/src/Umbraco.Web/Editors/SectionController.cs b/src/Umbraco.Web/Editors/SectionController.cs index 0be5823218..b7db641946 100644 --- a/src/Umbraco.Web/Editors/SectionController.cs +++ b/src/Umbraco.Web/Editors/SectionController.cs @@ -17,17 +17,20 @@ namespace Umbraco.Web.Editors [PluginController("UmbracoApi")] public class SectionController : UmbracoAuthorizedJsonController { + private readonly DashboardHelper _dashboardHelper; + + public SectionController(DashboardHelper dashboardHelper) + { + _dashboardHelper = dashboardHelper; + } + public IEnumerable
GetSections() { var sections = Services.SectionService.GetAllowedSections(Security.GetUserId().ResultOr(0)); var sectionModels = sections.Select(Mapper.Map).ToArray(); - - //Check if there are empty dashboards or dashboards that will end up empty based on the current user's access - //and add the meta data about them - var dashboardHelper = new DashboardHelper(ApplicationContext); - + // this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that // since tree's by nature are controllers and require request contextual data - and then we have to // remember to inject properties - nasty indeed @@ -36,7 +39,7 @@ namespace Umbraco.Web.Editors Current.Container.InjectProperties(appTreeController); appTreeController.ControllerContext = ControllerContext; - var dashboards = dashboardHelper.GetDashboards(Security.CurrentUser); + var dashboards = _dashboardHelper.GetDashboards(Security.CurrentUser); //now we can add metadata for each section so that the UI knows if there's actually anything at all to render for //a dashboard for a given section, then the UI can deal with it accordingly (i.e. redirect to the first tree) foreach (var section in sectionModels) diff --git a/src/Umbraco.Web/Models/ContentEditing/DashboardControl.cs b/src/Umbraco.Web/Models/ContentEditing/DashboardControl.cs index d51084fb16..aad6bf2d64 100644 --- a/src/Umbraco.Web/Models/ContentEditing/DashboardControl.cs +++ b/src/Umbraco.Web/Models/ContentEditing/DashboardControl.cs @@ -10,15 +10,6 @@ namespace Umbraco.Web.Models.ContentEditing [DataContract(Name = "control", Namespace = "")] public class DashboardControl { - [DataMember(Name = "showOnce")] - public bool ShowOnce { get; set; } - - [DataMember(Name = "addPanel")] - public bool AddPanel { get; set; } - - [DataMember(Name = "serverSide")] - public bool ServerSide { get; set; } - [DataMember(Name = "path")] public string Path { get; set; } diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs index 10b1e22eed..6ed9599af4 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs @@ -208,6 +208,8 @@ namespace Umbraco.Web.Runtime .Append() .Append() .Append(); + + composition.Container.RegisterSingleton(); } internal void Initialize(