V8: Removing legacy content tree menu items (#4278)

This commit is contained in:
Callum Whyte
2019-01-30 22:01:57 +11:00
committed by Sebastiaan Janssen
parent a331632800
commit 0cdccc1a9b
5 changed files with 24 additions and 115 deletions

View File

@@ -214,7 +214,9 @@ namespace Umbraco.Web.Trees
// set names according to variations
foreach (var entity in result)
{
EnsureName(entity, cultureVal);
}
return result;
}
@@ -235,7 +237,8 @@ namespace Umbraco.Web.Trees
AddActionNode<ActionSort>(item, menu, true);
AddActionNode<ActionAssignDomain>(item, menu, opensDialog: true);
AddActionNode<ActionRights>(item, menu, opensDialog: true);
AddActionNode<ActionProtect>(item, menu, true, convert: true, opensDialog: true);
AddActionNode<ActionProtect>(item, menu, true, opensDialog: true);
if (EmailSender.CanSendRequiredEmail)
{
menu.Items.Add(new MenuItem("notify", Services.TextService)
@@ -267,7 +270,6 @@ namespace Umbraco.Web.Trees
return menu;
}
/// <summary>
/// set name according to variations
@@ -279,12 +281,17 @@ namespace Umbraco.Web.Trees
if (culture == null)
{
if (string.IsNullOrWhiteSpace(entity.Name))
{
entity.Name = "[[" + entity.Id + "]]";
}
return;
}
if (!(entity is IDocumentEntitySlim docEntity))
{
throw new InvalidOperationException($"Cannot render a tree node for a culture when the entity isn't {typeof(IDocumentEntitySlim)}, instead it is {entity.GetType()}");
}
// we are getting the tree for a given culture,
// for those items that DO support cultures, we need to get the proper name, IF it exists
@@ -304,16 +311,15 @@ namespace Umbraco.Web.Trees
}
if (string.IsNullOrWhiteSpace(entity.Name))
{
entity.Name = "[[" + entity.Id + "]]";
}
}
// TODO: Remove the need for converting to legacy
private void AddActionNode<TAction>(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool convert = false, bool opensDialog = false)
private void AddActionNode<TAction>(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool opensDialog = false)
where TAction : IAction
{
var menuItem = menu.Items.Add<TAction>(Services.TextService.Localize("actions", _actions.GetAction<TAction>().Alias), hasSeparator);
if (convert) menuItem.ConvertLegacyMenuItem(item, "content", "content");
menuItem.OpensDialog = opensDialog;
var menuItem = menu.Items.Add<TAction>(Services.TextService.Localize("actions", _actions.GetAction<TAction>().Alias), hasSeparator, opensDialog);
}
public IEnumerable<SearchResultEntity> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)

View File

@@ -1,76 +0,0 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Trees
{
/// <summary>
/// Converts the legacy tree data to the new format
/// </summary>
internal class LegacyTreeDataConverter
{
// TODO: remove this whole class when everything is angularized
/// <summary>
/// This will look at the legacy IAction's JsFunctionName and convert it to a confirmation dialog view if possible
/// </summary>
/// <param name="action"></param>
/// <returns></returns>
internal static Attempt<string> GetLegacyConfirmView(IAction action)
{
switch (action)
{
case ActionDelete actionDelete:
return Attempt.Succeed(
Current.Configs.Global().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html");
}
return Attempt<string>.Fail();
}
/// <summary>
/// This will look at a legacy IAction's JsFunctionName and convert it to a URL if possible.
/// </summary>
/// <param name="action"></param>
/// <param name="nodeName"></param>
/// <param name="currentSection"></param>
/// <param name="nodeId"></param>
/// <param name="nodeType"></param>
internal static Attempt<LegacyUrlAction> GetUrlAndTitleFromLegacyAction(IAction action, string nodeId, string nodeType, string nodeName, string currentSection)
{
switch (action)
{
case ActionNew actionNew:
return Attempt.Succeed(
new LegacyUrlAction(
"create.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/create")));
}
return Attempt<LegacyUrlAction>.Fail();
}
internal class LegacyUrlAction
{
public LegacyUrlAction(string url, string dialogTitle)
: this(url, dialogTitle, ActionUrlMethod.Dialog)
{
}
public LegacyUrlAction(string url, string dialogTitle, ActionUrlMethod actionMethod)
{
Url = url;
ActionMethod = actionMethod;
DialogTitle = dialogTitle;
}
public string Url { get; private set; }
public ActionUrlMethod ActionMethod { get; private set; }
public string DialogTitle { get; private set; }
}
}
}