Files
Umbraco-CMS/src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs
Shannon c5181607de Merge branch 'temp8' into temp8-231-send-to-publish-with-variants
# Conflicts:
#	src/Umbraco.Web/Components/NotificationsComponent.cs
#	src/Umbraco.Web/Editors/ContentController.cs
#	src/Umbraco.Web/NotificationServiceExtensions.cs
#	src/Umbraco.Web/Trees/LegacyTreeDataConverter.cs
#	src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/SendPublish.aspx.cs
#	src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
2018-11-01 14:02:43 +11:00

89 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Web.Http.Routing;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing;
using Umbraco.Web.Models.Trees;
namespace Umbraco.Web.Trees
{
/// <summary>
/// Converts the legacy tree data to the new format
/// </summary>
internal class LegacyTreeDataConverter
{
//fixme: 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(
UmbracoConfig.For.GlobalSettings().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")));
case ActionProtect actionProtect:
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/protectPage.aspx?mode=cut&nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/protect")));
}
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; }
}
}
}