diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index f522fb467b..49bc478461 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -548,6 +548,7 @@
HealthChecks.config
Designer
+
umbracoSettings.config
Designer
diff --git a/src/Umbraco.Web/Editors/TourController.cs b/src/Umbraco.Web/Editors/TourController.cs
index ad9b6b3430..ed1ed4c9c8 100644
--- a/src/Umbraco.Web/Editors/TourController.cs
+++ b/src/Umbraco.Web/Editors/TourController.cs
@@ -1,9 +1,13 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
+using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters;
using Constants = Umbraco.Core.Constants;
@@ -11,29 +15,46 @@ using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Editors
{
[PluginController("UmbracoApi")]
- [UmbracoApplicationAuthorize(Constants.Applications.Content)]
+ [UmbracoApplicationAuthorize(Constants.Applications.Content)]
public class TourController : UmbracoAuthorizedJsonController
{
- //TODO: Strongly type this for final release!
- public JArray GetTours()
+ public IEnumerable GetTours()
{
- //TODO: Add error checking to this for final release!
-
- var result = new JArray();
+ var tours = new List();
if (UmbracoConfig.For.UmbracoSettings().BackOffice.Tours.EnableTours == false)
- return result;
+ return tours;
- var tourFiles = Directory.GetFiles(
- Path.Combine(IOHelper.MapPath(SystemDirectories.Config), "BackOfficeTours"), "*.json")
+ var toursPath = Path.Combine(IOHelper.MapPath(SystemDirectories.Config), "BackOfficeTours");
+ if (Directory.Exists(toursPath) == false)
+ return tours;
+
+ var tourFiles = Directory.GetFiles(toursPath, "*.json")
.OrderBy(x => x, StringComparer.InvariantCultureIgnoreCase);
+ var disabledTours = TourFilterResolver.Current.DisabledTours;
+
foreach (var tourFile in tourFiles)
{
- var contents = File.ReadAllText(tourFile);
- result.Add(JArray.Parse(contents));
+ try
+ {
+ var contents = File.ReadAllText(tourFile);
+ var tourArray = JsonConvert.DeserializeObject(contents);
+ tours.Add(tourArray.Where(x =>
+ disabledTours.Contains(x.Alias, StringComparer.InvariantCultureIgnoreCase) == false).ToArray());
+ }
+ catch (IOException e)
+ {
+ Logger.Error("Error while trying to read file: " + tourFile, e);
+ throw new IOException("Error while trying to read file: " + tourFile, e);
+ }
+ catch (JsonReaderException e)
+ {
+ Logger.Error("Error while trying to parse content as tour data: " + tourFile, e);
+ throw new JsonReaderException("Error while trying to parse content as tour data: " + tourFile, e);
+ }
}
- return result;
+ return tours;
}
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Editors/TourFilterResolver.cs b/src/Umbraco.Web/Editors/TourFilterResolver.cs
new file mode 100644
index 0000000000..5eafc19b3c
--- /dev/null
+++ b/src/Umbraco.Web/Editors/TourFilterResolver.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Umbraco.Web.Editors
+{
+ //TODO: find out where this should live
+ public class TourFilterResolver
+ {
+ private static TourFilterResolver _current;
+
+ private readonly HashSet _disabledTours;
+
+ public TourFilterResolver()
+ {
+ _disabledTours = new HashSet();
+ }
+
+ public static TourFilterResolver Current
+ {
+ get { return _current ?? (_current = new TourFilterResolver()); }
+ }
+
+ public void Disable(string tour)
+ {
+ _disabledTours.Add(tour);
+ }
+
+ public IEnumerable DisabledTours
+ {
+ get { return _disabledTours.ToArray(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Models/Tour.cs b/src/Umbraco.Web/Models/Tour.cs
new file mode 100644
index 0000000000..f130ccfc24
--- /dev/null
+++ b/src/Umbraco.Web/Models/Tour.cs
@@ -0,0 +1,22 @@
+using System.Runtime.Serialization;
+
+namespace Umbraco.Web.Models
+{
+ ///
+ /// A model representing a tour.
+ ///
+ [DataContract(Name = "tour", Namespace = "")]
+ public class Tour
+ {
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+ [DataMember(Name = "alias")]
+ public string Alias { get; set; }
+ [DataMember(Name = "group")]
+ public string Group { get; set; }
+ [DataMember(Name = "groupOrder")]
+ public int GroupOrder { get; set; }
+ [DataMember(Name = "steps")]
+ public TourStep[] Steps { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Models/TourStep.cs b/src/Umbraco.Web/Models/TourStep.cs
new file mode 100644
index 0000000000..8ed75872d9
--- /dev/null
+++ b/src/Umbraco.Web/Models/TourStep.cs
@@ -0,0 +1,18 @@
+using System.Runtime.Serialization;
+
+namespace Umbraco.Web.Models
+{
+ ///
+ /// A model representing a step in a tour.
+ ///
+ [DataContract(Name = "step", Namespace = "")]
+ public class TourStep
+ {
+ [DataMember(Name = "title")]
+ public string Title { get; set; }
+ [DataMember(Name = "content")]
+ public string Content { get; set; }
+ [DataMember(Name = "type")]
+ public string Type { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 326ed3baa9..956071aa40 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -328,6 +328,7 @@
+
@@ -428,6 +429,8 @@
+
+