diff --git a/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html b/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html deleted file mode 100644 index eea3838841..0000000000 --- a/src/Umbraco.Web.UI/umbraco/Views/common/dialogs/mediapicker.html +++ /dev/null @@ -1,92 +0,0 @@ -
- -
-
- -
-
- -
- -
- - Add - - - -
-
-
- -
- -
- -
- -
- - -
- - - - -
- -
\ No newline at end of file diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index b5a450638f..9fa1d4238d 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -119,7 +119,7 @@ namespace Umbraco.Web.Trees int iid; if (int.TryParse(id, out iid) == false) { - throw new InvalidOperationException("The Id for a content item must be an integer"); + throw new HttpResponseException(HttpStatusCode.NotFound); } var item = Services.EntityService.Get(iid, UmbracoObjectTypes.Document); if (item == null) @@ -128,7 +128,7 @@ namespace Umbraco.Web.Trees } return GetUserAllowedMenuItems( - CreateAllowedActions(), + CreateAllowedActions(item), GetUserMenuItemsForNode(item)); } @@ -137,23 +137,27 @@ namespace Umbraco.Web.Trees get { return UmbracoObjectTypes.Document; } } - protected IEnumerable CreateAllowedActions() + protected IEnumerable CreateAllowedActions(IUmbracoEntity item) { var menu = new MenuItemCollection(); menu.AddMenuItem(); menu.AddMenuItem(true); - menu.AddMenuItem(true); - menu.AddMenuItem(); + + //need to ensure some of these are converted to the legacy system - until we upgrade them all to be angularized. + menu.AddMenuItem(true).ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem(true); - menu.AddMenuItem(); - menu.AddMenuItem(true); - menu.AddMenuItem(); - menu.AddMenuItem(); - menu.AddMenuItem(); - menu.AddMenuItem(true); - menu.AddMenuItem(true); - menu.AddMenuItem(true); - menu.AddMenuItem(); + + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem(true).ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem(true).ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem(true).ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem(true).ConvertLegacyMenuItem(item, "content", "content"); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "content", "content"); menu.AddMenuItem(true); diff --git a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs index dad4c471bb..3ebe1cf497 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs @@ -67,9 +67,9 @@ namespace Umbraco.Web.Trees //First try to get a URL/title from the legacy action, // if that doesn't work, try to get the legacy confirm view Attempt - .Try(GetUrlAndTitleFromLegacyAction(currentAction, xmlTreeNode, currentSection), + .Try(GetUrlAndTitleFromLegacyAction(currentAction, xmlTreeNode.NodeID, xmlTreeNode.NodeType, xmlTreeNode.Text, currentSection), action => menuItem.LaunchDialogUrl(action.Url, action.DialogTitle)) - .IfFailed(() => GetLegacyConfirmView(currentAction, xmlTreeNode, currentSection), + .IfFailed(() => GetLegacyConfirmView(currentAction, currentSection), view => menuItem.LaunchDialogView( view, ui.GetText("defaultdialogs", "confirmdelete") + " '" + xmlTreeNode.Text + "' ?")); @@ -89,14 +89,15 @@ namespace Umbraco.Web.Trees return collection; } + + /// /// This will look at the legacy IAction's JsFunctionName and convert it to a confirmation dialog view if possible /// /// - /// /// /// - internal static Attempt GetLegacyConfirmView(IAction action, XmlTreeNode actionNode, string currentSection) + internal static Attempt GetLegacyConfirmView(IAction action, string currentSection) { if (action.JsFunctionName.IsNullOrWhiteSpace()) { @@ -118,9 +119,11 @@ namespace Umbraco.Web.Trees /// This will look at a legacy IAction's JsFunctionName and convert it to a URL if possible. /// /// - /// + /// /// - internal static Attempt GetUrlAndTitleFromLegacyAction(IAction action, XmlTreeNode actionNode, string currentSection) + /// + /// + internal static Attempt GetUrlAndTitleFromLegacyAction(IAction action, string nodeId, string nodeType, string nodeName, string currentSection) { if (action.JsFunctionName.IsNullOrWhiteSpace()) { @@ -133,80 +136,80 @@ namespace Umbraco.Web.Trees return new Attempt( true, new LegacyUrlAction( - "create.aspx?nodeId=" + actionNode.NodeID + "&nodeType=" + actionNode.NodeType + "&nodeName=" + actionNode.Text + "&rnd=" + DateTime.UtcNow.Ticks, + "create.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "create"))); case "UmbClientMgr.appActions().actionNewFolder()": return new Attempt( true, new LegacyUrlAction( - "createFolder.aspx?nodeId=" + actionNode.NodeID + "&nodeType=" + actionNode.NodeType + "&nodeName=" + actionNode.Text + "&rnd=" + DateTime.UtcNow.Ticks, + "createFolder.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "create"))); case "UmbClientMgr.appActions().actionSort()": return new Attempt( true, new LegacyUrlAction( - "dialogs/sort.aspx?id=" + actionNode.NodeID + "&nodeType=" + actionNode.NodeType + "&app=" + currentSection + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/sort.aspx?id=" + nodeId + "&nodeType=" + nodeType + "&app=" + currentSection + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "sort"))); case "UmbClientMgr.appActions().actionRights()": return new Attempt( true, new LegacyUrlAction( - "dialogs/cruds.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/cruds.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "rights"))); case "UmbClientMgr.appActions().actionProtect()": return new Attempt( true, new LegacyUrlAction( - "dialogs/protectPage.aspx?mode=cut&nodeId=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/protectPage.aspx?mode=cut&nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "protect"))); case "UmbClientMgr.appActions().actionRollback()": return new Attempt( true, new LegacyUrlAction( - "dialogs/rollback.aspx?nodeId=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/rollback.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "rollback"))); case "UmbClientMgr.appActions().actionNotify()": return new Attempt( true, new LegacyUrlAction( - "dialogs/notifications.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/notifications.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "notify"))); case "UmbClientMgr.appActions().actionPublish()": return new Attempt( true, new LegacyUrlAction( - "dialogs/publish.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/publish.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "publish"))); case "UmbClientMgr.appActions().actionToPublish()": return new Attempt( true, new LegacyUrlAction( - "dialogs/SendPublish.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/SendPublish.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "sendtopublish"))); case "UmbClientMgr.appActions().actionRePublish()": return new Attempt( true, new LegacyUrlAction( - "dialogs/republish.aspx?rnd=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/republish.aspx?rnd=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, "Republishing entire site")); case "UmbClientMgr.appActions().actionAssignDomain()": return new Attempt( true, new LegacyUrlAction( - "dialogs/assignDomain2.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/assignDomain2.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "assignDomain"))); case "UmbClientMgr.appActions().actionLiveEdit()": return new Attempt( true, new LegacyUrlAction( - "canvas.aspx?redir=/" + actionNode.NodeID + ".aspx", + "canvas.aspx?redir=/" + nodeId + ".aspx", "", ActionUrlMethod.BlankWindow)); case "UmbClientMgr.appActions().actionSendToTranslate()": return new Attempt( true, new LegacyUrlAction( - "dialogs/sendToTranslation.aspx?id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/sendToTranslation.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "sendToTranslate"))); case "UmbClientMgr.appActions().actionEmptyTranscan()": return new Attempt( @@ -224,25 +227,25 @@ namespace Umbraco.Web.Trees return new Attempt( true, new LegacyUrlAction( - "dialogs/exportDocumentType.aspx?nodeId=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/exportDocumentType.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, "")); case "UmbClientMgr.appActions().actionAudit()": return new Attempt( true, new LegacyUrlAction( - "dialogs/viewAuditTrail.aspx?nodeId=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/viewAuditTrail.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "auditTrail"))); case "UmbClientMgr.appActions().actionMove()": return new Attempt( true, new LegacyUrlAction( - "dialogs/moveOrCopy.aspx?app=" + currentSection + "&mode=cut&id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/moveOrCopy.aspx?app=" + currentSection + "&mode=cut&id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "move"))); case "UmbClientMgr.appActions().actionCopy()": return new Attempt( true, new LegacyUrlAction( - "dialogs/moveOrCopy.aspx?app=" + currentSection + "&mode=copy&id=" + actionNode.NodeID + "&rnd=" + DateTime.UtcNow.Ticks, + "dialogs/moveOrCopy.aspx?app=" + currentSection + "&mode=copy&id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, ui.GetText("actions", "copy"))); } return Attempt.False; diff --git a/src/Umbraco.Web/Trees/MediaTreeController.cs b/src/Umbraco.Web/Trees/MediaTreeController.cs index 95a39fd3c6..7eebed8181 100644 --- a/src/Umbraco.Web/Trees/MediaTreeController.cs +++ b/src/Umbraco.Web/Trees/MediaTreeController.cs @@ -1,5 +1,8 @@ -using System.Linq; +using System; +using System.Linq; +using System.Net; using System.Net.Http.Formatting; +using System.Web.Http; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services; @@ -51,9 +54,19 @@ namespace Umbraco.Web.Trees return menu; } + int iid; + if (int.TryParse(id, out iid) == false) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } + var item = Services.EntityService.Get(iid, UmbracoObjectTypes.Media); + if (item == null) + { + throw new HttpResponseException(HttpStatusCode.NotFound); + } //return a normal node menu: menu.AddMenuItem(); - menu.AddMenuItem(); + menu.AddMenuItem().ConvertLegacyMenuItem(item, "media", "media"); menu.AddMenuItem(); menu.AddMenuItem(); menu.AddMenuItem(true); diff --git a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs b/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs index a4413a255f..21700bf883 100644 --- a/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs +++ b/src/Umbraco.Web/Trees/Menu/MenuItemExtensions.cs @@ -1,4 +1,8 @@ -namespace Umbraco.Web.Trees.Menu +using Umbraco.Core; +using Umbraco.Core.Models.EntityBase; +using umbraco; + +namespace Umbraco.Web.Trees.Menu { public static class MenuItemExtensions { @@ -56,5 +60,18 @@ menuItem.AdditionalData[ActionUrlKey] = url; menuItem.AdditionalData[ActionUrlMethodKey] = url; } + + internal static void ConvertLegacyMenuItem(this MenuItem menuItem, IUmbracoEntity item, string nodeType, string currentSection) + { + //First try to get a URL/title from the legacy action, + // if that doesn't work, try to get the legacy confirm view + Attempt + .Try(LegacyTreeDataConverter.GetUrlAndTitleFromLegacyAction(menuItem.Action, item.Id.ToInvariantString(), nodeType, item.Name, currentSection), + action => menuItem.LaunchDialogUrl(action.Url, action.DialogTitle)) + .IfFailed(() => LegacyTreeDataConverter.GetLegacyConfirmView(menuItem.Action, currentSection), + view => menuItem.LaunchDialogView( + view, + ui.GetText("defaultdialogs", "confirmdelete") + " '" + item.Name + "' ?")); + } } } \ No newline at end of file