From 5baaefbbea7d47dda5b0a4a97e1abfd12e155ff3 Mon Sep 17 00:00:00 2001 From: Ed Parry Date: Mon, 11 Jun 2018 21:29:19 +0100 Subject: [PATCH 1/3] Added a new method to update the context menu for content items in the recycle bin --- .../Trees/ContentTreeController.cs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index ea644f5dc8fe..c0a22ffae0b0 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Net; -using System.Net.Http; using System.Net.Http.Formatting; using System.Web.Http; using Umbraco.Core; @@ -15,10 +13,7 @@ using Umbraco.Web.WebApi.Filters; using umbraco; using umbraco.BusinessLogic.Actions; -using umbraco.businesslogic; using umbraco.businesslogic.Actions; -using umbraco.cms.businesslogic.web; -using umbraco.interfaces; using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Search; using Constants = Umbraco.Core.Constants; @@ -174,16 +169,13 @@ protected override MenuItemCollection PerformGetMenuForNode(string id, FormDataC return menu; } - var nodeMenu = GetAllNodeMenuItems(item); - var allowedMenuItems = GetAllowedUserMenuItemsForNode(item); - - FilterUserAllowedMenuItems(nodeMenu, allowedMenuItems); - - //if the media item is in the recycle bin, don't have a default menu, just show the regular menu + var nodeMenu = GetAllNodeMenuItems(item); + + //if the content node is in the recycle bin, don't have a default menu, just show the regular menu if (item.Path.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Contains(RecycleBinId.ToInvariantString())) { nodeMenu.DefaultMenuAlias = null; - nodeMenu.Items.Insert(2, new MenuItem(ActionRestore.Instance, ui.Text("actions", ActionRestore.Instance.Alias))); + nodeMenu = GetNodeMenuItemsForDeletedContent(item); } else { @@ -191,6 +183,8 @@ protected override MenuItemCollection PerformGetMenuForNode(string id, FormDataC nodeMenu.DefaultMenuAlias = ActionNew.Instance.Alias; } + var allowedMenuItems = GetAllowedUserMenuItemsForNode(item); + FilterUserAllowedMenuItems(nodeMenu, allowedMenuItems); return nodeMenu; } @@ -248,9 +242,24 @@ protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item) return menu; } + protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity item) + { + var menu = new MenuItemCollection(); + menu.Items.Add(ui.Text("actions", ActionRestore.Instance.Alias)); + menu.Items.Add(ui.Text("actions", ActionDelete.Instance.Alias)); + + menu.Items.Add(ui.Text("actions", ActionSort.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content"); + menu.Items.Add(ui.Text("actions", ActionRollback.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content"); + menu.Items.Add(ui.Text("actions", ActionAudit.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content"); + + menu.Items.Add(ui.Text("actions", ActionRefresh.Instance.Alias), true); + + return menu; + } + public IEnumerable Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null) { return _treeSearcher.ExamineSearch(Umbraco, query, UmbracoEntityTypes.Document, pageSize, pageIndex, out totalFound, searchFrom); } } -} \ No newline at end of file +} From 3b5e55fa1d8a825ac667b3c280f1b3980be166af Mon Sep 17 00:00:00 2001 From: Ed Parry Date: Mon, 11 Jun 2018 21:49:27 +0100 Subject: [PATCH 2/3] Added comment to new method. --- src/Umbraco.Web/Trees/ContentTreeController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index c0a22ffae0b0..f34ab208c96d 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -242,6 +242,11 @@ protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item) return menu; } + /// + /// Returns a collection of all menu items that can be on a deleted (in recycle bin) content node + /// + /// + /// protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity item) { var menu = new MenuItemCollection(); From fd2af1e6dbf079f7f47fcca76e2b8574db5ced7c Mon Sep 17 00:00:00 2001 From: Ed Parry Date: Wed, 13 Jun 2018 20:17:31 +0100 Subject: [PATCH 3/3] Removed sort, rollback and the audit trail. --- src/Umbraco.Web/Trees/ContentTreeController.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index f34ab208c96d..29b300cb626d 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -253,10 +253,6 @@ protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity it menu.Items.Add(ui.Text("actions", ActionRestore.Instance.Alias)); menu.Items.Add(ui.Text("actions", ActionDelete.Instance.Alias)); - menu.Items.Add(ui.Text("actions", ActionSort.Instance.Alias), true).ConvertLegacyMenuItem(item, "content", "content"); - menu.Items.Add(ui.Text("actions", ActionRollback.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content"); - menu.Items.Add(ui.Text("actions", ActionAudit.Instance.Alias)).ConvertLegacyMenuItem(item, "content", "content"); - menu.Items.Add(ui.Text("actions", ActionRefresh.Instance.Alias), true); return menu;