diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tour.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tour.service.js index a1cb579433..28ac7f6485 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tour.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tour.service.js @@ -212,6 +212,9 @@ throw "Tour " + tour.alias + " is missing tour steps"; } + if (tour.requiredSections.length === 0) { + throw "Tour " + tour.alias + " is missing the required sections"; + } } /** @@ -275,4 +278,4 @@ angular.module("umbraco.services").factory("tourService", tourService); -})(); \ No newline at end of file +})(); diff --git a/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json b/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json index 36350b5d18..f2bf531ab4 100644 --- a/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json +++ b/src/Umbraco.Web.UI/config/BackOfficeTours/getting-started.json @@ -5,6 +5,15 @@ "group": "Getting Started", "groupOrder": 100, "allowDisable": true, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "Welcome to Umbraco - The Friendly CMS", @@ -25,7 +34,6 @@ "content": "Each area in Umbraco is called a Section. Right now you are in the Content section, when you want to go to another section simply click on the appropriate icon in the main menu and you'll be there in no time.", "backdropOpacity": 0.6 }, - { "element": "#tree", "elementPreventClick": true, @@ -88,6 +96,15 @@ "alias": "umbIntroCreateDocType", "group": "Getting Started", "groupOrder": 100, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "Create your first Document Type", @@ -203,6 +220,15 @@ "alias": "umbIntroCreateContent", "group": "Getting Started", "groupOrder": 100, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "Creating your first content node", @@ -253,6 +279,15 @@ "alias": "umbIntroRenderInTemplate", "group": "Getting Started", "groupOrder": 100, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "Render your content in a template", @@ -299,6 +334,15 @@ "alias": "umbIntroViewHomePage", "group": "Getting Started", "groupOrder": 100, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "View your Umbraco site", @@ -339,6 +383,15 @@ "alias": "umbIntroMediaSection", "group": "Getting Started", "groupOrder": 100, + "requiredSections": [ + "content", + "media", + "settings", + "developer", + "users", + "member", + "forms" + ], "steps": [ { "title": "How to use the media library", diff --git a/src/Umbraco.Web/Editors/TourController.cs b/src/Umbraco.Web/Editors/TourController.cs index 152879bf5a..da16659cfe 100644 --- a/src/Umbraco.Web/Editors/TourController.cs +++ b/src/Umbraco.Web/Editors/TourController.cs @@ -7,8 +7,6 @@ using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Web.Models; using Umbraco.Web.Mvc; -using Umbraco.Web.WebApi.Filters; -using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { @@ -23,7 +21,7 @@ namespace Umbraco.Web.Editors return result; var filters = TourFilterResolver.Current.Filters.ToList(); - + //get all filters that will be applied to all tour aliases var aliasOnlyFilters = filters.Where(x => x.PluginName == null && x.TourFileName == null).ToList(); @@ -64,8 +62,28 @@ namespace Umbraco.Web.Editors } } } + //Get all allowed sections for the current user + var allowedSections = UmbracoContext.Current.Security.CurrentUser.AllowedSections.ToList(); - return result.OrderBy(x => x.FileName, StringComparer.InvariantCultureIgnoreCase); + var toursToBeRemoved = new List(); + + //Checking to see if the user has access to the required tour sections, else we remove the tour + foreach (var backOfficeTourFile in result) + { + foreach (var tour in backOfficeTourFile.Tours) + { + foreach (var toursRequiredSection in tour.RequiredSections) + { + if (allowedSections.Contains(toursRequiredSection) == false) + { + toursToBeRemoved.Add(backOfficeTourFile); + break; + } + } + } + } + + return result.Except(toursToBeRemoved).OrderBy(x => x.FileName, StringComparer.InvariantCultureIgnoreCase); } private void TryParseTourFile(string tourFile, @@ -79,7 +97,7 @@ namespace Umbraco.Web.Editors //get the filters specific to this file var fileFilters = filters.Where(x => x.TourFileName != null && x.TourFileName.IsMatch(fileName)).ToList(); - + //If there is any filter applied to match the file only (no tour alias) then ignore the file entirely var isFileFiltered = fileFilters.Any(x => x.TourAlias == null); if (isFileFiltered) return; @@ -117,4 +135,4 @@ namespace Umbraco.Web.Editors } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/Models/BackOfficeTour.cs b/src/Umbraco.Web/Models/BackOfficeTour.cs index a973a92429..78a4cd1897 100644 --- a/src/Umbraco.Web/Models/BackOfficeTour.cs +++ b/src/Umbraco.Web/Models/BackOfficeTour.cs @@ -1,4 +1,5 @@ -using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Runtime.Serialization; namespace Umbraco.Web.Models { @@ -18,6 +19,8 @@ namespace Umbraco.Web.Models public int GroupOrder { get; set; } [DataMember(Name = "allowDisable")] public bool AllowDisable { get; set; } + [DataMember(Name = "requiredSections")] + public List RequiredSections { get; set; } [DataMember(Name = "steps")] public BackOfficeTourStep[] Steps { get; set; } }