Removes IActions that shouldn't be IActions
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Umbraco.Web.Actions
|
||||
internal T GetAction<T>()
|
||||
where T : IAction
|
||||
{
|
||||
return this.OfType<T>().SingleOrDefault();
|
||||
return this.OfType<T>().FirstOrDefault();
|
||||
}
|
||||
|
||||
internal IEnumerable<IAction> GetByLetters(IEnumerable<string> letters)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using LightInject;
|
||||
using Umbraco.Core.Composing;
|
||||
@@ -14,5 +15,17 @@ namespace Umbraco.Web.Actions
|
||||
{ }
|
||||
|
||||
protected override ActionCollectionBuilder This => this;
|
||||
|
||||
protected override IEnumerable<IAction> CreateItems(params object[] args)
|
||||
{
|
||||
var items = base.CreateItems(args).ToList();
|
||||
//validate the items, no actions should exist that do not either expose notifications or permissions
|
||||
var invalid = items.Where(x => !x.CanBePermissionAssigned && !x.ShowInNotifier).ToList();
|
||||
if (invalid.Count > 0)
|
||||
{
|
||||
throw new InvalidOperationException($"Invalid actions '{string.Join(", ", invalid.Select(x => x.Alias))}'. All {typeof(IAction)} implementations must be true for either {nameof(IAction.CanBePermissionAssigned)} or {nameof(IAction.ShowInNotifier)}");
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//fixme: not needed, remove this
|
||||
public class ActionEmptyTranscan : IAction
|
||||
{
|
||||
public char Letter => 'N';
|
||||
public string Alias => "emptyRecycleBin";
|
||||
public string Category => null;
|
||||
public string Icon => "trash";
|
||||
public bool ShowInNotifier => false;
|
||||
public bool CanBePermissionAssigned => false;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//fixme: not needed, remove this
|
||||
public class ActionExport : IAction
|
||||
{
|
||||
public char Letter => '9';
|
||||
public string Alias => "export";
|
||||
public string Category => null;
|
||||
public string Icon => "download-alt";
|
||||
public bool ShowInNotifier => false;
|
||||
public bool CanBePermissionAssigned => false;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//fixme: not needed, remove this
|
||||
public class ActionImport : IAction
|
||||
{
|
||||
public char Letter => '8';
|
||||
public string Alias => "importDocumentType";
|
||||
public string Category => null;
|
||||
public string Icon => "page-up";
|
||||
public bool ShowInNotifier => false;
|
||||
public bool CanBePermissionAssigned => false;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//fixme: not needed, remove this
|
||||
public class ActionNotify : IAction
|
||||
{
|
||||
public char Letter => 'T';
|
||||
public string Alias => "notify";
|
||||
public string Category => null;
|
||||
public string Icon => "megaphone";
|
||||
public bool ShowInNotifier => false;
|
||||
public bool CanBePermissionAssigned => false;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
//fixme: not needed, remove this
|
||||
public class ActionRePublish : IAction
|
||||
{
|
||||
public char Letter => 'B';
|
||||
public string Alias => "republish";
|
||||
public string Category => null;
|
||||
public string Icon => "globe";
|
||||
public bool ShowInNotifier => false;
|
||||
public bool CanBePermissionAssigned => false;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
|
||||
namespace Umbraco.Web.Actions
|
||||
{
|
||||
///// <summary>
|
||||
///// This action is invoked when a node reloads its children
|
||||
///// Concerns only the tree itself and thus you should not handle
|
||||
///// this action from without umbraco.
|
||||
///// </summary>
|
||||
//public class ActionRefresh : IAction
|
||||
//{
|
||||
// public static string ActionAlias => "refreshNode";
|
||||
|
||||
// public char Letter => 'L';
|
||||
// public string Alias => ActionAlias;
|
||||
// public string Icon => "refresh";
|
||||
// public bool ShowInNotifier => false;
|
||||
// public bool CanBePermissionAssigned => false;
|
||||
// public string Category => null;
|
||||
//}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Models.Trees
|
||||
{
|
||||
@@ -28,9 +29,17 @@ namespace Umbraco.Web.Models.Trees
|
||||
/// </summary>
|
||||
public virtual string AngularServiceMethodName { get; } = null;
|
||||
|
||||
[SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")]
|
||||
protected ActionMenuItem()
|
||||
: base()
|
||||
protected ActionMenuItem(string alias, string name) : base(alias, name)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
protected ActionMenuItem(string alias, ILocalizedTextService textService) : base(alias, textService)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
//add the current type to the metadata
|
||||
if (AngularServiceMethodName.IsNullOrWhiteSpace())
|
||||
|
||||
@@ -11,17 +11,16 @@ namespace Umbraco.Web.Models.Trees
|
||||
public override string AngularServiceName => "umbracoMenuActions";
|
||||
|
||||
public CreateChildEntity(string name, bool seperatorBefore = false)
|
||||
: base(ActionNew.ActionAlias, name)
|
||||
{
|
||||
Alias = ActionNew.ActionAlias;
|
||||
Icon = "add"; Name = name;
|
||||
SeperatorBefore = seperatorBefore;
|
||||
}
|
||||
|
||||
public CreateChildEntity(ILocalizedTextService textService, bool seperatorBefore = false)
|
||||
: base(ActionNew.ActionAlias, textService)
|
||||
{
|
||||
Alias = ActionNew.ActionAlias;
|
||||
Icon = "add";
|
||||
Name = textService.Localize($"actions/{Alias}");
|
||||
SeperatorBefore = seperatorBefore;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Umbraco.Web.Models.Trees
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Models.Trees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the export member menu item
|
||||
@@ -6,5 +8,10 @@
|
||||
public sealed class ExportMember : ActionMenuItem
|
||||
{
|
||||
public override string AngularServiceName => "umbracoMenuActions";
|
||||
|
||||
public ExportMember(ILocalizedTextService textService) : base("export", textService)
|
||||
{
|
||||
Icon = "download-alt";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@ namespace Umbraco.Web.Models.Trees
|
||||
Name = name;
|
||||
}
|
||||
|
||||
|
||||
public MenuItem(string alias, ILocalizedTextService textService)
|
||||
: this()
|
||||
{
|
||||
Alias = alias;
|
||||
Name = textService.Localize($"actions/{Alias}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a menu item based on an <see cref="IAction"/> definition
|
||||
/// </summary>
|
||||
|
||||
@@ -38,28 +38,6 @@ namespace Umbraco.Web.Models.Trees
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item based on an <see cref="IAction"/>
|
||||
/// </summary>
|
||||
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public MenuItem Add<T>(string name)
|
||||
where T : IAction
|
||||
{
|
||||
return Add<T>(name, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item based on an <see cref="IAction"/>
|
||||
/// </summary>
|
||||
/// <param name="textService">The <see cref="ILocalizedTextService"/> used to localize the action name based on it's alias</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public MenuItem Add<T>(ILocalizedTextService textService)
|
||||
where T : IAction
|
||||
{
|
||||
return Add<T>(textService, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a menu item with a dictionary which is merged to the AdditionalData bag
|
||||
/// </summary>
|
||||
|
||||
@@ -11,18 +11,16 @@ namespace Umbraco.Web.Models.Trees
|
||||
public override string AngularServiceName => "umbracoMenuActions";
|
||||
|
||||
public RefreshNode(string name, bool seperatorBefore = false)
|
||||
: base("refreshNode", name)
|
||||
{
|
||||
Alias = "refreshNode";
|
||||
Icon = "refresh";
|
||||
Name = name;
|
||||
SeperatorBefore = seperatorBefore;
|
||||
}
|
||||
|
||||
public RefreshNode(ILocalizedTextService textService, bool seperatorBefore = false)
|
||||
: base("refreshNode", textService)
|
||||
{
|
||||
Alias = "refreshNode";
|
||||
Icon = "refresh";
|
||||
Name = textService.Localize($"actions/{Alias}");
|
||||
SeperatorBefore = seperatorBefore;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,8 +240,12 @@ namespace Umbraco.Web.Trees
|
||||
AddActionNode<ActionAssignDomain>(item, menu);
|
||||
AddActionNode<ActionRights>(item, menu);
|
||||
AddActionNode<ActionProtect>(item, menu, true, true);
|
||||
|
||||
AddActionNode<ActionNotify>(item, menu, true);
|
||||
|
||||
menu.Items.Add(new MenuItem("notify", Services.TextService)
|
||||
{
|
||||
Icon = "megaphone",
|
||||
SeperatorBefore = true
|
||||
});
|
||||
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
|
||||
@@ -349,7 +349,10 @@ namespace Umbraco.Web.Trees
|
||||
if (RecycleBinId.ToInvariantString() == id)
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
menu.Items.Add<ActionEmptyTranscan>(Services.TextService.Localize("actions/emptyTrashcan"));
|
||||
menu.Items.Add(new MenuItem("emptyRecycleBin", Services.TextService)
|
||||
{
|
||||
Icon = "trash"
|
||||
});
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
return menu;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,11 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
// root actions
|
||||
menu.Items.Add<ActionNew>(Services.TextService);
|
||||
menu.Items.Add<ActionImport>(Services.TextService, true);
|
||||
menu.Items.Add(new MenuItem("importDocumentType", Services.TextService)
|
||||
{
|
||||
Icon = "page-up",
|
||||
SeperatorBefore = true
|
||||
});
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
return menu;
|
||||
@@ -123,7 +127,11 @@ namespace Umbraco.Web.Trees
|
||||
menu.Items.Add<ActionMove>(Services.TextService, true);
|
||||
}
|
||||
menu.Items.Add<ActionCopy>(Services.TextService);
|
||||
menu.Items.Add<ActionExport>(Services.TextService, true);
|
||||
menu.Items.Add(new MenuItem("export", Services.TextService)
|
||||
{
|
||||
Icon = "download-alt",
|
||||
SeperatorBefore = true
|
||||
});
|
||||
menu.Items.Add<ActionDelete>(Services.TextService, true);
|
||||
if (enableInheritedDocumentTypes)
|
||||
menu.Items.Add(new RefreshNode(Services.TextService, true));
|
||||
|
||||
@@ -185,12 +185,7 @@ namespace Umbraco.Web.Trees
|
||||
|
||||
if (Security.CurrentUser.HasAccessToSensitiveData())
|
||||
{
|
||||
menu.Items.Add(new ExportMember
|
||||
{
|
||||
Name = Services.TextService.Localize("actions/export"),
|
||||
Icon = "download-alt",
|
||||
Alias = "export"
|
||||
});
|
||||
menu.Items.Add(new ExportMember(Services.TextService));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -538,16 +538,10 @@
|
||||
<Compile Include="Actions\ActionCopy.cs" />
|
||||
<Compile Include="Actions\ActionCreateBlueprintFromContent.cs" />
|
||||
<Compile Include="Actions\ActionDelete.cs" />
|
||||
<Compile Include="Actions\ActionEmptyTranscan.cs" />
|
||||
<Compile Include="Actions\ActionExport.cs" />
|
||||
<Compile Include="Actions\ActionImport.cs" />
|
||||
<Compile Include="Actions\ActionMove.cs" />
|
||||
<Compile Include="Actions\ActionNew.cs" />
|
||||
<Compile Include="Actions\ActionNotify.cs" />
|
||||
<Compile Include="Actions\ActionProtect.cs" />
|
||||
<Compile Include="Actions\ActionPublish.cs" />
|
||||
<Compile Include="Actions\ActionRefresh.cs" />
|
||||
<Compile Include="Actions\ActionRePublish.cs" />
|
||||
<Compile Include="Actions\ActionRestore.cs" />
|
||||
<Compile Include="Actions\ActionRights.cs" />
|
||||
<Compile Include="Actions\ActionRollback.cs" />
|
||||
|
||||
Reference in New Issue
Block a user