From 94de454264dda5ad3b16012fe2e3c82059e0cd3c Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 4 Nov 2013 17:24:25 +1100 Subject: [PATCH] Fixing unit tests --- src/Umbraco.Web/UI/LegacyDialogTask.cs | 1 + .../umbraco/create/PartialViewMacrosTasks.cs | 66 +++++++------------ .../umbraco/create/PartialViewTasks.cs | 2 +- src/umbraco.interfaces/ITask.cs | 1 + src/umbraco.interfaces/ITaskReturnUrl.cs | 3 + 5 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/Umbraco.Web/UI/LegacyDialogTask.cs b/src/Umbraco.Web/UI/LegacyDialogTask.cs index 824d753ebe..537141e30a 100644 --- a/src/Umbraco.Web/UI/LegacyDialogTask.cs +++ b/src/Umbraco.Web/UI/LegacyDialogTask.cs @@ -22,6 +22,7 @@ namespace Umbraco.Web.UI /// specific app, they'd still be able to execute code to create/delete for any ITask regardless of what app /// they have access to. /// + [Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")] public abstract class LegacyDialogTask : ITaskReturnUrl, IAssignedApp { public virtual int ParentID { get; set; } diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewMacrosTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewMacrosTasks.cs index f939ba51a9..216bcd15e9 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewMacrosTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewMacrosTasks.cs @@ -4,8 +4,10 @@ using Umbraco.Core.CodeAnnotations; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Web.Mvc; +using Umbraco.Web.UI; using umbraco.BasePages; using Umbraco.Core; +using umbraco.BusinessLogic; namespace umbraco { @@ -13,13 +15,10 @@ namespace umbraco /// The UI 'tasks' for the create dialog and delete processes /// [UmbracoWillObsolete("http://issues.umbraco.org/issue/U4-1373", "This will one day be removed when we overhaul the create process")] - public class PartialViewMacroTasks : interfaces.ITaskReturnUrl + public class PartialViewMacroTasks : LegacyDialogTask { - private string _alias; - private int _parentId; - private int _typeId; - private int _userId; - + private string _returnUrl = ""; + protected virtual string EditViewFile { get { return "Settings/Views/EditView.aspx"; } @@ -35,34 +34,11 @@ namespace umbraco get { return "MacroPartials"; } } - public int UserId + public override bool PerformSave() { - set { _userId = value; } - } - public int TypeID - { - set { _typeId = value; } - get { return _typeId; } - } - - - public string Alias - { - set { _alias = value; } - get { return _alias; } - } - - public int ParentID - { - set { _parentId = value; } - get { return _parentId; } - } - - public bool Save() - { - var pipesIndex = _alias.IndexOf("|||", System.StringComparison.Ordinal); - var template = _alias.Substring(0, pipesIndex).Trim(); - var fileName = _alias.Substring(pipesIndex + 3, _alias.Length - pipesIndex - 3) + ".cshtml"; + var pipesIndex = Alias.IndexOf("|||", System.StringComparison.Ordinal); + var template = Alias.Substring(0, pipesIndex).Trim(); + var fileName = Alias.Substring(pipesIndex + 3, Alias.Length - pipesIndex - 3) + ".cshtml"; var fullFilePath = IOHelper.MapPath(BasePath + fileName); @@ -97,27 +73,29 @@ namespace umbraco return true; } - public bool Delete() + public override string ReturnUrl { - var path = IOHelper.MapPath(BasePath + _alias.TrimStart('/')); + get { return _returnUrl; } + } + + public override string AssignedApp + { + get { return DefaultApps.developer.ToString(); } + } + + public override bool PerformDelete() + { + var path = IOHelper.MapPath(BasePath + Alias.TrimStart('/')); if (File.Exists(path)) File.Delete(path); else if (Directory.Exists(path)) Directory.Delete(path, true); - LogHelper.Info(string.Format("{0} Deleted by user {1}", _alias, UmbracoEnsuredPage.CurrentUser.Id)); + LogHelper.Info(string.Format("{0} Deleted by user {1}", Alias, User.Id)); return true; } - #region ITaskReturnUrl Members - private string _returnUrl = ""; - public string ReturnUrl - { - get { return _returnUrl; } - } - - #endregion } } \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewTasks.cs index 37983a5343..87e5abd1e8 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/PartialViewTasks.cs @@ -107,4 +107,4 @@ namespace umbraco } } -} +} diff --git a/src/umbraco.interfaces/ITask.cs b/src/umbraco.interfaces/ITask.cs index 0b50fcc541..8ea902cc39 100644 --- a/src/umbraco.interfaces/ITask.cs +++ b/src/umbraco.interfaces/ITask.cs @@ -5,6 +5,7 @@ namespace umbraco.interfaces /// /// Summary description for ITask. /// + [Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")] public interface ITask { int ParentID {set; get;} diff --git a/src/umbraco.interfaces/ITaskReturnUrl.cs b/src/umbraco.interfaces/ITaskReturnUrl.cs index 687ddd8a14..98b132689c 100644 --- a/src/umbraco.interfaces/ITaskReturnUrl.cs +++ b/src/umbraco.interfaces/ITaskReturnUrl.cs @@ -1,5 +1,8 @@ +using System; + namespace umbraco.interfaces { + [Obsolete("ITask is used for legacy webforms back office editors, change to using the v7 angular approach")] public interface ITaskReturnUrl : ITask { string ReturnUrl {get;}