diff --git a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js index 32bb9b084c..058a8366ae 100644 --- a/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js +++ b/src/Umbraco.Web.UI.Client/src/common/mocks/umbraco.servervariables.js @@ -20,6 +20,7 @@ Umbraco.Sys.ServerVariables = { }, umbracoSettings: { "umbracoPath": "/umbraco", + "appPluginsPath" : "/App_Plugins", "imageFileTypes": "jpeg,jpg,gif,bmp,png,tiff,tif" }, isDebuggingEnabled: true diff --git a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js index b039134ff8..eca8f70576 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js @@ -364,7 +364,17 @@ angular.module('umbraco.services') //by convention we will look into the /views/{treetype}/{action}.html // for example: /views/content/create.html - templateUrl = "views/" + treeService.getTreeAlias(args.node) + "/" + args.action.alias + ".html"; + //we will also check for a 'packageName' in metaData, if it exists, we'll look by convention in that folder + // for example: /App_Plugins/{mypackage}/umbraco/{treetype}/create.html + + if (args.action.metaData["packageName"]) { + + templateUrl = Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath + + "/umbraco/views/" + treeService.getTreeAlias(args.node) + "/" + args.action.alias + ".html"; + } + else { + templateUrl = "views/" + treeService.getTreeAlias(args.node) + "/" + args.action.alias + ".html"; + } iframe = false; } diff --git a/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs b/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs index 8655af9b11..78a9085b7f 100644 --- a/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs +++ b/src/Umbraco.Web.UI/App_Plugins/MyPackage/Trees/LegacyTestTree.cs @@ -10,31 +10,32 @@ using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.UI.App_Plugins.MyPackage.Trees { - //[Tree(Constants.Applications.Settings, "myTree", "My Tree")] - //[PluginController("MyPackage")] - //public class MyCustomTree : TreeController - //{ - // protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) - // { - // if (id == Constants.System.Root.ToInvariantString()) - // { - // var tree = new TreeNodeCollection - // { - // CreateTreeNode("1", queryStrings, "My Node 1"), - // CreateTreeNode("2", queryStrings, "My Node 2"), - // CreateTreeNode("3", queryStrings, "My Node 3") - // }; - // return tree; - // } - // throw new NotSupportedException(); - // } + [Tree(Constants.Applications.Settings, "myTree", "My Tree")] + [PluginController("MyPackage")] + public class MyCustomTreeController : TreeController + { + protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings) + { + if (id == Constants.System.Root.ToInvariantString()) + { + var tree = new TreeNodeCollection + { + CreateTreeNode("1", queryStrings, "My Node 1"), + CreateTreeNode("2", queryStrings, "My Node 2"), + CreateTreeNode("3", queryStrings, "My Node 3") + }; + return tree; + } + throw new NotSupportedException(); + } - // protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) - // { - // var menu = new MenuItemCollection(); - // menu.AddMenuItem(new MenuItem("create", "Create")); - // } - //} + protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) + { + var menu = new MenuItemCollection("MyPackage"); + menu.AddMenuItem(new MenuItem("create", "Create")); + return menu; + } + } public class LegacyTestTree : BaseTree { diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config index 46a523ce38..acafac91f1 100644 --- a/src/Umbraco.Web.UI/config/trees.config +++ b/src/Umbraco.Web.UI/config/trees.config @@ -39,4 +39,5 @@ + \ No newline at end of file diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index a8a5dc2a63..641d809ca7 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using System.Web.Mvc; using Umbraco.Core.Configuration; +using Umbraco.Core.IO; using Umbraco.Core.Manifest; using Umbraco.Core; using Umbraco.Web.Mvc; @@ -79,6 +80,7 @@ namespace Umbraco.Web.Editors "umbracoSettings", new Dictionary { {"umbracoPath", GlobalSettings.Path}, + {"appPluginsPath", IOHelper.ResolveUrl(SystemDirectories.AppPlugins).TrimEnd('/')}, {"imageFileTypes", string.Join(",",UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes)}, } diff --git a/src/Umbraco.Web/Mvc/PluginViewEngine.cs b/src/Umbraco.Web/Mvc/PluginViewEngine.cs index fe39978b6e..96f393920e 100644 --- a/src/Umbraco.Web/Mvc/PluginViewEngine.cs +++ b/src/Umbraco.Web/Mvc/PluginViewEngine.cs @@ -7,7 +7,7 @@ using Umbraco.Core.IO; namespace Umbraco.Web.Mvc { /// - /// A view engine to look into the App_Plugins/Packages folder for views for packaged controllers + /// A view engine to look into the App_Plugins folder for views for packaged controllers /// public class PluginViewEngine : FixedRazorViewEngine { diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs b/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs index 626a7f9f20..4c99a255c7 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs +++ b/src/Umbraco.Web/Trees/Menu/MenuItemCollection.cs @@ -12,6 +12,7 @@ namespace Umbraco.Web.Trees.Menu [DataContract(Name = "menuItems", Namespace = "")] public class MenuItemCollection { + private readonly string _packageFolderName; private readonly List _menuItems; public MenuItemCollection() @@ -24,6 +25,18 @@ namespace Umbraco.Web.Trees.Menu _menuItems = new List(items); } + public MenuItemCollection(string packageFolderName) + : this() + { + _packageFolderName = packageFolderName; + } + + public MenuItemCollection(string packageFolderName, IEnumerable items) + { + _packageFolderName = packageFolderName; + _menuItems = new List(items); + } + /// /// Sets the default menu item alias to be shown when the menu is launched - this is optional and if not set then the menu will just be shown normally. /// @@ -50,7 +63,7 @@ namespace Umbraco.Web.Trees.Menu DetectLegacyActionMenu(action.GetType(), item); - _menuItems.Add(item); + AddItemToCollection(item); return item; } @@ -68,7 +81,7 @@ namespace Umbraco.Web.Trees.Menu /// public void AddMenuItem(MenuItem item) { - _menuItems.Add(item); + AddItemToCollection(item); } /// @@ -96,7 +109,7 @@ namespace Umbraco.Web.Trees.Menu Action = item.Action }; - _menuItems.Add(customMenuItem); + AddItemToCollection(customMenuItem); return customMenuItem; } @@ -139,7 +152,7 @@ namespace Umbraco.Web.Trees.Menu var item = CreateMenuItem(name, hasSeparator, additionalData); if (item != null) { - _menuItems.Add(item); + AddItemToCollection(item); return item; } return null; @@ -211,5 +224,18 @@ namespace Umbraco.Web.Trees.Menu } } + /// + /// This handles adding a menu item to the internal collection and will configure it accordingly + /// + /// + private void AddItemToCollection(MenuItem menuItem) + { + if (_packageFolderName.IsNullOrWhiteSpace() == false) + { + menuItem.SetPackageFolder(_packageFolderName); + } + _menuItems.Add(menuItem); + } + } } \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs b/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs index fadae7b1b3..019b42ab19 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs +++ b/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs @@ -6,6 +6,11 @@ namespace Umbraco.Web.Trees.Menu { public static class MenuItemExtensions { + /// + /// Used as a key for the AdditionalData to specify which package folder the menu launcher should look in for views + /// + internal const string PackageName = "packageName"; + /// /// Used as a key for the AdditionalData to specify a specific dialog title instead of the menu title /// @@ -16,7 +21,10 @@ namespace Umbraco.Web.Trees.Menu /// internal const string ActionUrlKey = "actionUrl"; - + //TODO: some action's want to launch a new window like live editing, we support this in the menu item's metadata with + // a key called: "actionUrlMethod" which can be set to either: Dialog, BlankWindow. Normally this is always set to Dialog + // if a URL is specified in the "actionUrl" metadata. For now I'm not going to implement launching in a blank window, + // though would be v-easy, just not sure we want to ever support that? internal const string ActionUrlMethodKey = "actionUrlMethod"; /// @@ -24,6 +32,16 @@ namespace Umbraco.Web.Trees.Menu /// internal const string ActionViewKey = "actionView"; + /// + /// Sets the package folder to look for views in + /// + /// + /// + internal static void SetPackageFolder(this MenuItem menuItem, string packageFolder) + { + menuItem.AdditionalData[PackageName] = packageFolder; + } + /// /// Sets the menu item to display a dialog based on an angular view path ///