Merge pull request #3479 from umbraco/temp8-IAction-cleanup

v8 IAction cleanup
This commit is contained in:
Warren Buckley
2018-10-31 14:18:38 +00:00
committed by GitHub
116 changed files with 1006 additions and 3517 deletions

View File

@@ -1,35 +0,0 @@
using System;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.CodeAnnotations
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
internal class ActionMetadataAttribute : Attribute
{
public string Category { get; }
public string Name { get; }
/// <summary>
/// Constructor used to assign a Category, since no name is assigned it will try to be translated from the language files based on the action's alias
/// </summary>
/// <param name="category"></param>
public ActionMetadataAttribute(string category)
{
if (string.IsNullOrWhiteSpace(category)) throw new ArgumentNullOrEmptyException(nameof(category));
Category = category;
}
/// <summary>
/// Constructor used to assign an explicit name and category
/// </summary>
/// <param name="category"></param>
/// <param name="name"></param>
public ActionMetadataAttribute(string category, string name)
{
if (string.IsNullOrWhiteSpace(category)) throw new ArgumentNullOrEmptyException(nameof(category));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
Category = category;
Name = name;
}
}
}

View File

@@ -143,7 +143,6 @@
<Compile Include="Cache\SingleItemsOnlyRepositoryCachePolicy.cs" /> <Compile Include="Cache\SingleItemsOnlyRepositoryCachePolicy.cs" />
<Compile Include="Cache\StaticCacheProvider.cs" /> <Compile Include="Cache\StaticCacheProvider.cs" />
<Compile Include="Cache\TypedCacheRefresherBase.cs" /> <Compile Include="Cache\TypedCacheRefresherBase.cs" />
<Compile Include="CodeAnnotations\ActionMetadataAttribute.cs" />
<Compile Include="CodeAnnotations\FriendlyNameAttribute.cs" /> <Compile Include="CodeAnnotations\FriendlyNameAttribute.cs" />
<Compile Include="CodeAnnotations\UmbracoObjectTypeAttribute.cs" /> <Compile Include="CodeAnnotations\UmbracoObjectTypeAttribute.cs" />
<Compile Include="CodeAnnotations\UmbracoUdiTypeAttribute.cs" /> <Compile Include="CodeAnnotations\UmbracoUdiTypeAttribute.cs" />

View File

@@ -1,77 +0,0 @@
using System.Linq;
using NUnit.Framework;
using Umbraco.Web;
using Umbraco.Web.UI.Pages;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Tests.Composing
{
[TestFixture]
public class ActionCollectionTests : ComposingTestBase
{
[Test]
public void ActionCollectionBuilderWorks()
{
var collectionBuilder = new ActionCollectionBuilder();
collectionBuilder.SetProducer(() => TypeLoader.GetActions());
var actions = collectionBuilder.CreateCollection();
Assert.AreEqual(2, actions.Count());
// order is unspecified, but both must be there
var hasAction1 = actions.ElementAt(0) is SingletonAction || actions.ElementAt(1) is SingletonAction;
var hasAction2 = actions.ElementAt(0) is NonSingletonAction || actions.ElementAt(1) is NonSingletonAction;
Assert.IsTrue(hasAction1);
Assert.IsTrue(hasAction2);
var singletonAction = (SingletonAction) (actions.ElementAt(0) is SingletonAction ? actions.ElementAt(0) : actions.ElementAt(1));
// ensure it is a singleton
Assert.AreSame(SingletonAction.Instance, singletonAction);
}
#region Test Objects
public class SingletonAction : IAction
{
public static SingletonAction Instance { get; } = new SingletonAction();
public char Letter => 'I';
public string JsFunctionName => $"{ClientTools.Scripts.GetAppActions}.actionAssignDomain()";
public string JsSource => null;
public string Alias => "assignDomain";
public string Icon => ".sprDomain";
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
public bool OpensDialog => true;
}
public class NonSingletonAction : IAction
{
public char Letter => 'Q';
public string JsFunctionName => $"{ClientTools.Scripts.GetAppActions}.actionAssignDomain()";
public string JsSource => null;
public string Alias => "asfasdf";
public string Icon => ".sprDomain";
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
public bool OpensDialog => true;
}
#endregion
}
}

View File

@@ -268,13 +268,6 @@ AnotherContentFinder
Assert.AreEqual(2, foundTypes1.Count()); Assert.AreEqual(2, foundTypes1.Count());
} }
[Test]
public void Resolves_Actions()
{
var actions = _typeLoader.GetActions();
Assert.AreEqual(33, actions.Count());
}
[Test] [Test]
public void GetDataEditors() public void GetDataEditors()
{ {

View File

@@ -14,7 +14,8 @@ using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement; using Umbraco.Core.Services.Implement;
using Umbraco.Tests.Testing; using Umbraco.Tests.Testing;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
namespace Umbraco.Tests.Services namespace Umbraco.Tests.Services
{ {
@@ -70,12 +71,12 @@ namespace Umbraco.Tests.Services
MockedContent.CreateSimpleContent(contentType) MockedContent.CreateSimpleContent(contentType)
}; };
ServiceContext.ContentService.Save(content); ServiceContext.ContentService.Save(content);
ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionMove.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionMove.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[2], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[2], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
// Act // Act
var permissions = userService.GetPermissions(user, content[0].Id, content[1].Id, content[2].Id).ToArray(); var permissions = userService.GetPermissions(user, content[0].Id, content[1].Id, content[2].Id).ToArray();
@@ -103,12 +104,12 @@ namespace Umbraco.Tests.Services
MockedContent.CreateSimpleContent(contentType) MockedContent.CreateSimpleContent(contentType)
}; };
ServiceContext.ContentService.Save(content); ServiceContext.ContentService.Save(content);
ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionMove.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(0), ActionMove.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content.ElementAt(1), ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(1), ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content.ElementAt(1), ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(1), ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content.ElementAt(2), ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content.ElementAt(2), ActionBrowse.ActionLetter, new int[] { userGroup.Id });
// Act // Act
var permissions = userService.GetPermissions(userGroup, false, content[0].Id, content[1].Id, content[2].Id).ToArray(); var permissions = userService.GetPermissions(userGroup, false, content[0].Id, content[1].Id, content[2].Id).ToArray();
@@ -136,11 +137,11 @@ namespace Umbraco.Tests.Services
MockedContent.CreateSimpleContent(contentType) MockedContent.CreateSimpleContent(contentType)
}; };
ServiceContext.ContentService.Save(content); ServiceContext.ContentService.Save(content);
ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionMove.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionMove.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionDelete.ActionLetter, new int[] { userGroup.Id });
// Act // Act
var permissions = userService.GetPermissions(userGroup, true, content[0].Id, content[1].Id, content[2].Id) var permissions = userService.GetPermissions(userGroup, true, content[0].Id, content[1].Id, content[2].Id)
@@ -180,12 +181,12 @@ namespace Umbraco.Tests.Services
}; };
ServiceContext.ContentService.Save(content); ServiceContext.ContentService.Save(content);
//assign permissions - we aren't assigning anything explicit for group3 and nothing explicit for content[2] /w group2 //assign permissions - we aren't assigning anything explicit for group3 and nothing explicit for content[2] /w group2
ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.Instance.Letter, new int[] { userGroup1.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.ActionLetter, new int[] { userGroup1.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionDelete.Instance.Letter, new int[] { userGroup1.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionDelete.ActionLetter, new int[] { userGroup1.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionMove.Instance.Letter, new int[] { userGroup2.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionMove.ActionLetter, new int[] { userGroup2.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.Instance.Letter, new int[] { userGroup1.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.ActionLetter, new int[] { userGroup1.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionDelete.Instance.Letter, new int[] { userGroup2.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionDelete.ActionLetter, new int[] { userGroup2.Id });
ServiceContext.ContentService.SetPermission(content[2], ActionDelete.Instance.Letter, new int[] { userGroup1.Id }); ServiceContext.ContentService.SetPermission(content[2], ActionDelete.ActionLetter, new int[] { userGroup1.Id });
// Act // Act
//we don't pass in any nodes so it will return all of them //we don't pass in any nodes so it will return all of them
@@ -249,12 +250,12 @@ namespace Umbraco.Tests.Services
MockedContent.CreateSimpleContent(contentType) MockedContent.CreateSimpleContent(contentType)
}; };
ServiceContext.ContentService.Save(content); ServiceContext.ContentService.Save(content);
ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[0], ActionMove.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[0], ActionMove.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[1], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[1], ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(content[2], ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(content[2], ActionDelete.ActionLetter, new int[] { userGroup.Id });
// Act // Act
//we don't pass in any nodes so it will return all of them //we don't pass in any nodes so it will return all of them
@@ -412,11 +413,11 @@ namespace Umbraco.Tests.Services
var child2 = MockedContent.CreateSimpleContent(contentType, "child2", child1); var child2 = MockedContent.CreateSimpleContent(contentType, "child2", child1);
ServiceContext.ContentService.Save(child2); ServiceContext.ContentService.Save(child2);
ServiceContext.ContentService.SetPermission(parent, ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(parent, ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(parent, ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(parent, ActionDelete.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(parent, ActionMove.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(parent, ActionMove.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(parent, ActionBrowse.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(parent, ActionBrowse.ActionLetter, new int[] { userGroup.Id });
ServiceContext.ContentService.SetPermission(parent, ActionDelete.Instance.Letter, new int[] { userGroup.Id }); ServiceContext.ContentService.SetPermission(parent, ActionDelete.ActionLetter, new int[] { userGroup.Id });
// Act // Act
var permissions = userService.GetPermissionsForPath(userGroup, child2.Path); var permissions = userService.GetPermissionsForPath(userGroup, child2.Path);

View File

@@ -36,9 +36,10 @@ using Umbraco.Web;
using Umbraco.Web.Services; using Umbraco.Web.Services;
using Umbraco.Examine; using Umbraco.Examine;
using Umbraco.Tests.Testing.Objects.Accessors; using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing.CompositionRoots; using Umbraco.Web.Composing.CompositionRoots;
using Umbraco.Web.ContentApps; using Umbraco.Web.ContentApps;
using Umbraco.Web._Legacy.Actions;
using Current = Umbraco.Core.Composing.Current; using Current = Umbraco.Core.Composing.Current;
using Umbraco.Web.Routing; using Umbraco.Web.Routing;
@@ -205,9 +206,7 @@ namespace Umbraco.Tests.Testing
Container.RegisterSingleton(f => runtimeStateMock.Object); Container.RegisterSingleton(f => runtimeStateMock.Object);
// ah... // ah...
Container.RegisterCollectionBuilder<ActionCollectionBuilder>() Container.RegisterCollectionBuilder<ActionCollectionBuilder>();
.SetProducer(Enumerable.Empty<Type>);
Container.RegisterCollectionBuilder<PropertyValueConverterCollectionBuilder>(); Container.RegisterCollectionBuilder<PropertyValueConverterCollectionBuilder>();
Container.RegisterSingleton<IPublishedContentTypeFactory, PublishedContentTypeFactory>(); Container.RegisterSingleton<IPublishedContentTypeFactory, PublishedContentTypeFactory>();

View File

@@ -406,7 +406,6 @@
<Compile Include="Persistence\Repositories\StylesheetRepositoryTest.cs" /> <Compile Include="Persistence\Repositories\StylesheetRepositoryTest.cs" />
<Compile Include="PublishedContent\PublishedContentMoreTests.cs" /> <Compile Include="PublishedContent\PublishedContentMoreTests.cs" />
<Compile Include="Publishing\PublishingStrategyTests.cs" /> <Compile Include="Publishing\PublishingStrategyTests.cs" />
<Compile Include="Composing\ActionCollectionTests.cs" />
<Compile Include="TestHelpers\Entities\MockedMember.cs" /> <Compile Include="TestHelpers\Entities\MockedMember.cs" />
<Compile Include="TestHelpers\Entities\MockedUser.cs" /> <Compile Include="TestHelpers\Entities\MockedUser.cs" />
<Compile Include="TestHelpers\Stubs\TestProfiler.cs" /> <Compile Include="TestHelpers\Stubs\TestProfiler.cs" />

View File

@@ -22,20 +22,5 @@ namespace Umbraco.Tests.Web.Controllers
}; };
[TestCaseSource("TestLegacyJsActionPaths")]
public void Separates_Legacy_JsActions_By_Block_Or_Url(object[] jsActions)
{
var jsBlocks =
BackOfficeController.GetLegacyActionJsForActions(BackOfficeController.LegacyJsActionType.JsBlock,
jsActions.Select(n => n.ToString()));
var jsUrls =
BackOfficeController.GetLegacyActionJsForActions(BackOfficeController.LegacyJsActionType.JsUrl,
jsActions.Select(n => n.ToString()));
Assert.That(jsBlocks.Count() == 4);
Assert.That(jsUrls.Count() == 3);
Assert.That(jsUrls.Last().StartsWith("~/") == false);
}
} }
} }

View File

@@ -22,7 +22,7 @@ using Umbraco.Web;
using Umbraco.Web.Editors; using Umbraco.Web.Editors;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache;
using Umbraco.Web._Legacy.Actions;
using Task = System.Threading.Tasks.Task; using Task = System.Threading.Tasks.Task;
using Umbraco.Core.Dictionary; using Umbraco.Core.Dictionary;
using Umbraco.Web.PropertyEditors; using Umbraco.Web.PropertyEditors;
@@ -30,6 +30,7 @@ using System;
using Umbraco.Web.WebApi; using Umbraco.Web.WebApi;
using Umbraco.Web.Trees; using Umbraco.Web.Trees;
using System.Globalization; using System.Globalization;
using Umbraco.Web.Actions;
namespace Umbraco.Tests.Web.Controllers namespace Umbraco.Tests.Web.Controllers
{ {
@@ -53,10 +54,10 @@ namespace Umbraco.Tests.Web.Controllers
{ {
new EntityPermission(0, 123, new[] new EntityPermission(0, 123, new[]
{ {
ActionBrowse.Instance.Letter.ToString(), ActionBrowse.ActionLetter.ToString(),
ActionUpdate.Instance.Letter.ToString(), ActionUpdate.ActionLetter.ToString(),
ActionPublish.Instance.Letter.ToString(), ActionPublish.ActionLetter.ToString(),
ActionNew.Instance.Letter.ToString() ActionNew.ActionLetter.ToString()
}), }),
}))); })));

View File

@@ -33,7 +33,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
* Returns the root angular scope * Returns the root angular scope
*/ */
function getRootScope() { function getRootScope() {
return angular.element(document.getElementById("umbracoMainPageBody")).scope(); return top.$("#umbracoMainPageBody").scope();
} }
/** /**
@@ -46,7 +46,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
* Returns the root angular injector * Returns the root angular injector
*/ */
function getRootInjector() { function getRootInjector() {
return angular.element(document.getElementById("umbracoMainPageBody")).injector(); return top.$("#umbracoMainPageBody").injector();
} }
@@ -327,7 +327,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
//add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked. //add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked.
dialog.element.data("modalCb", onCloseCallback); dialog.element.data("modalCb", onCloseCallback);
//add the close triggers //add the close triggers
if (angular.isArray(closeTriggers)) { if (top.angular.isArray(closeTriggers)) {
for (var i = 0; i < closeTriggers.length; i++) { for (var i = 0; i < closeTriggers.length; i++) {
var e = dialog.find(closeTriggers[i]); var e = dialog.find(closeTriggers[i]);
if (e.length > 0) { if (e.length > 0) {

View File

@@ -402,21 +402,34 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
throw "Cannot get a descendant node from a section container node without a treeAlias specified"; throw "Cannot get a descendant node from a section container node without a treeAlias specified";
} }
//if it is a section container, we need to find the tree to be searched //the treeNode passed in could be a section container, or it could be a section group
if (treeNode.isContainer) { //in either case we need to go through the children until we can find the actual tree root with the treeAlias
var foundRoot = null; var self = this;
for (var c = 0; c < treeNode.children.length; c++) { function getTreeRoot(tn) {
if (this.getTreeAlias(treeNode.children[c]) === treeAlias) { //if it is a section container, we need to find the tree to be searched
foundRoot = treeNode.children[c]; if (tn.isContainer) {
break; for (var c = 0; c < tn.children.length; c++) {
if (tn.children[c].isContainer) {
//recurse
return getTreeRoot(tn.children[c]);
}
else if (self.getTreeAlias(tn.children[c]) === treeAlias) {
return tn.children[c];
}
} }
return null;
} }
if (!foundRoot) { else {
throw "Could not find a tree in the current section with alias " + treeAlias; return tn;
} }
treeNode = foundRoot;
} }
var foundRoot = getTreeRoot(treeNode);
if (!foundRoot) {
throw "Could not find a tree in the current section with alias " + treeAlias;
}
treeNode = foundRoot;
//check this node //check this node
if (treeNode.id === id) { if (treeNode.id === id) {
return treeNode; return treeNode;

View File

@@ -0,0 +1,34 @@
/**
* @ngdoc controller
* @name Umbraco.Dialogs.LegacyDeleteController
* @function
*
* @description
* The controller for deleting content
*/
function LegacyDeleteController($scope, legacyResource, treeService, navigationService) {
$scope.performDelete = function () {
//mark it for deletion (used in the UI)
$scope.currentNode.loading = true;
legacyResource.deleteItem({
nodeId: $scope.currentNode.id,
nodeType: $scope.currentNode.nodeType,
alias: $scope.currentNode.name
}).then(function () {
$scope.currentNode.loading = false;
//TODO: Need to sync tree, etc...
treeService.removeNode($scope.currentNode);
navigationService.hideMenu();
});
};
$scope.cancel = function () {
navigationService.hideDialog();
};
}
angular.module("umbraco").controller("Umbraco.Dialogs.LegacyDeleteController", LegacyDeleteController);

View File

@@ -0,0 +1,14 @@
<div class="umb-dialog" ng-controller="Umbraco.Dialogs.LegacyDeleteController">
<div class="umb-dialog-body" >
<div class="umb-pane">
<p>
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong> ?
</p>
<umb-confirm on-confirm="performDelete" on-cancel="cancel">
</umb-confirm>
</div>
</div>
</div>

View File

@@ -324,8 +324,6 @@
<Content Include="Umbraco\Developer\RelationTypes\Images\Refresh.gif" /> <Content Include="Umbraco\Developer\RelationTypes\Images\Refresh.gif" />
<Content Include="Umbraco\Developer\RelationTypes\NewRelationType.aspx" /> <Content Include="Umbraco\Developer\RelationTypes\NewRelationType.aspx" />
<Content Include="Umbraco\Developer\RelationTypes\RelationTypesWebService.asmx" /> <Content Include="Umbraco\Developer\RelationTypes\RelationTypesWebService.asmx" />
<Content Include="Umbraco\Developer\RelationTypes\TreeMenu\ActionDeleteRelationType.js" />
<Content Include="Umbraco\Developer\RelationTypes\TreeMenu\ActionNewRelationType.js" />
<Content Include="Umbraco\Dialogs\ChangeDocType.aspx"> <Content Include="Umbraco\Dialogs\ChangeDocType.aspx">
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>
</Content> </Content>

View File

@@ -1,21 +0,0 @@
function actionDeleteRelationType(relationTypeId, relationTypeName) {
if (confirm('Are you sure you want to delete "' + relationTypeName + '"?')) {
$.ajax({
type: "POST",
url: "developer/RelationTypes/RelationTypesWebService.asmx/DeleteRelationType",
data: "{ 'relationTypeId' : '" + relationTypeId + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
UmbClientMgr.mainTree().refreshTree('relationTypes');
UmbClientMgr.appActions().openDashboard('developer');
},
error: function (data) { }
});
}
}

View File

@@ -1,3 +0,0 @@
function actionNewRelationType() {
UmbClientMgr.openModalWindow('developer/RelationTypes/NewRelationType.aspx', 'Create New RelationType', true, 400, 300, 0, 0);
}

View File

@@ -0,0 +1,21 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when a domain is being assigned to a document
/// </summary>
public class ActionAssignDomain : IAction
{
public const char ActionLetter = 'I';
public char Letter => ActionLetter;
public string Alias => "assignDomain";
public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
public string Icon => "home";
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,27 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is used as a security constraint that grants a user the ability to view nodes in a tree
/// that has permissions applied to it.
/// </summary>
/// <remarks>
/// This action should not be invoked. It is used as the minimum required permission to view nodes in the content tree. By
/// granting a user this permission, the user is able to see the node in the tree but not edit the document. This may be used by other trees
/// that support permissions in the future.
/// </remarks>
public class ActionBrowse : IAction
{
public const char ActionLetter = 'F';
public char Letter => ActionLetter;
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
public string Icon => "";
public string Alias => "browse";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
}

View File

@@ -0,0 +1,20 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when the document type of a piece of content is changed
/// </summary>
public class ActionChangeDocType : IAction
{
public char Letter => '7';
public string Alias => "changeDocType";
public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
public string Icon => "axis-rotation-2";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -3,8 +3,10 @@ using System.Globalization;
using System.Linq; using System.Linq;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Composing; using Umbraco.Core.Composing;
using Umbraco.Core.Models.Membership;
namespace Umbraco.Web._Legacy.Actions
namespace Umbraco.Web.Actions
{ {
public class ActionCollection : BuilderCollectionBase<IAction> public class ActionCollection : BuilderCollectionBase<IAction>
{ {
@@ -15,7 +17,7 @@ namespace Umbraco.Web._Legacy.Actions
internal T GetAction<T>() internal T GetAction<T>()
where T : IAction where T : IAction
{ {
return this.OfType<T>().SingleOrDefault(); return this.OfType<T>().FirstOrDefault();
} }
internal IEnumerable<IAction> GetByLetters(IEnumerable<string> letters) internal IEnumerable<IAction> GetByLetters(IEnumerable<string> letters)
@@ -25,5 +27,15 @@ namespace Umbraco.Web._Legacy.Actions
.WhereNotNull() .WhereNotNull()
.ToArray(); .ToArray();
} }
internal IReadOnlyList<IAction> FromEntityPermission(EntityPermission entityPermission)
{
return entityPermission.AssignedPermissions
.Where(x => x.Length == 1)
.Select(x => x.ToCharArray()[0])
.SelectMany(c => this.Where(x => x.Letter == c))
.Where(action => action != null)
.ToList();
}
} }
} }

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using LightInject;
using Umbraco.Core.Composing;
namespace Umbraco.Web.Actions
{
internal class ActionCollectionBuilder : LazyCollectionBuilderBase<ActionCollectionBuilder, ActionCollection, IAction>
{
public ActionCollectionBuilder(IServiceContainer container)
: base(container)
{ }
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;
}
}
}

View File

@@ -0,0 +1,20 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when copying a document, media, member
/// </summary>
public class ActionCopy : IAction
{
public char Letter => 'O';
public string Alias => "copy";
public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
public string Icon => "documents";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,16 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
public class ActionCreateBlueprintFromContent : IAction
{
public char Letter => 'ï';
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
public string Icon => "blueprint";
public string Alias => "createblueprint";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
}

View File

@@ -0,0 +1,23 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when a document, media, member is deleted
/// </summary>
public class ActionDelete : IAction
{
public const string ActionAlias = "delete";
public const char ActionLetter = 'D';
public char Letter => ActionLetter;
public string Alias => ActionAlias;
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => "delete";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,22 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked upon creation of a document, media, member
/// </summary>
public class ActionMove : IAction
{
public const char ActionLetter = 'M';
public char Letter => ActionLetter;
public string Alias => "move";
public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
public string Icon => "enter";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,23 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked upon creation of a document
/// </summary>
public class ActionNew : IAction
{
public const string ActionAlias = "create";
public const char ActionLetter = 'C';
public char Letter => ActionLetter;
public string Alias => ActionAlias;
public string Icon => "add";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
}
}

View File

@@ -0,0 +1,20 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when a document is protected or unprotected
/// </summary>
public class ActionProtect : IAction
{
public char Letter => 'P';
public string Alias => "protect";
public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
public string Icon => "lock";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,21 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when a document is being published
/// </summary>
public class ActionPublish : IAction
{
public const char ActionLetter = 'U';
public char Letter => ActionLetter;
public string Alias => "publish";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => string.Empty;
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,20 @@

namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when the content/media item is to be restored from the recycle bin
/// </summary>
public class ActionRestore : IAction
{
public const string ActionAlias = "restore";
public char Letter => 'V';
public string Alias => ActionAlias;
public string Category => null;
public string Icon => "undo";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => false;
}
}

View File

@@ -0,0 +1,20 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when rights are changed on a document
/// </summary>
public class ActionRights : IAction
{
public char Letter => 'R';
public string Alias => "rights";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => "vcard";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,22 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when copying a document is being rolled back
/// </summary>
public class ActionRollback : IAction
{
public const char ActionLetter = 'K';
public char Letter => ActionLetter;
public string Alias => "rollback";
public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory;
public string Icon => "undo";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,19 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when children to a document, media, member is being sorted
/// </summary>
public class ActionSort : IAction
{
public char Letter => 'S';
public string Alias => "sort";
public string Category => Constants.Conventions.PermissionCategories.StructureCategory;
public string Icon => "navigation-vertical";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,22 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when children to a document is being sent to published (by an editor without publishrights)
/// </summary>
public class ActionToPublish : IAction
{
public const char ActionLetter = 'H';
public char Letter => ActionLetter;
public string Alias => "sendtopublish";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => "outbox";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,21 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when a document is being unpublished
/// </summary>
public class ActionUnpublish : IAction
{
public char Letter => 'Z';
public string Alias => "unpublish";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => "circle-dotted";
public bool ShowInNotifier => false;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,22 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web.Actions
{
/// <summary>
/// This action is invoked when copying a document or media
/// </summary>
public class ActionUpdate : IAction
{
public const char ActionLetter = 'A';
public char Letter => ActionLetter;
public string Alias => "update";
public string Category => Constants.Conventions.PermissionCategories.ContentCategory;
public string Icon => "save";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => true;
}
}

View File

@@ -0,0 +1,46 @@
using Umbraco.Core.Composing;
namespace Umbraco.Web.Actions
{
/// <summary>
/// Defines a back office action that can be permission assigned or subscribed to for notifications
/// </summary>
/// <remarks>
/// If an IAction returns false for both ShowInNotifier and CanBePermissionAssigned then the IAction should not exist
/// </remarks>
public interface IAction : IDiscoverable
{
/// <summary>
/// The letter used to assign a permission (must be unique)
/// </summary>
char Letter { get; }
/// <summary>
/// Whether to allow subscribing to notifications for this action
/// </summary>
bool ShowInNotifier { get; }
/// <summary>
/// Whether to allow assigning permissions based on this action
/// </summary>
bool CanBePermissionAssigned { get; }
/// <summary>
/// The icon to display for this action
/// </summary>
string Icon { get; }
/// <summary>
/// The alias for this action (must be unique)
/// </summary>
string Alias { get; }
/// <summary>
/// The category used for this action
/// </summary>
/// <remarks>
/// Used in the UI when assigning permissions
/// </remarks>
string Category { get; }
}
}

View File

@@ -5,23 +5,24 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement; using Umbraco.Core.Services.Implement;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
namespace Umbraco.Web.Components namespace Umbraco.Web.Components
{ {
[RuntimeLevel(MinLevel = RuntimeLevel.Run)] [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public sealed class NotificationsComponent : UmbracoComponentBase, IUmbracoCoreComponent public sealed class NotificationsComponent : UmbracoComponentBase, IUmbracoCoreComponent
{ {
public void Initialize(INotificationService notificationService) public void Initialize(INotificationService notificationService, ActionCollection actions)
{ {
ContentService.SentToPublish += (sender, args) => ContentService.SentToPublish += (sender, args) =>
notificationService.SendNotification(args.Entity, ActionToPublish.Instance); notificationService.SendNotification(args.Entity, actions.GetAction<ActionToPublish>());
//Send notifications for the published action //Send notifications for the published action
ContentService.Published += (sender, args) => ContentService.Published += (sender, args) =>
{ {
foreach (var content in args.PublishedEntities) foreach (var content in args.PublishedEntities)
notificationService.SendNotification(content, ActionPublish.Instance); notificationService.SendNotification(content, actions.GetAction<ActionToPublish>());
}; };
//Send notifications for the update and created actions //Send notifications for the update and created actions
@@ -45,22 +46,22 @@ namespace Umbraco.Web.Components
updatedEntities.Add(entity); updatedEntities.Add(entity);
} }
} }
notificationService.SendNotification(newEntities, ActionNew.Instance); notificationService.SendNotification(newEntities, actions.GetAction<ActionNew>());
notificationService.SendNotification(updatedEntities, ActionUpdate.Instance); notificationService.SendNotification(updatedEntities, actions.GetAction<ActionUpdate>());
}; };
//Send notifications for the delete action //Send notifications for the delete action
ContentService.Deleted += (sender, args) => ContentService.Deleted += (sender, args) =>
{ {
foreach (var content in args.DeletedEntities) foreach (var content in args.DeletedEntities)
notificationService.SendNotification(content, ActionDelete.Instance); notificationService.SendNotification(content, actions.GetAction<ActionDelete>());
}; };
//Send notifications for the unpublish action //Send notifications for the unpublish action
ContentService.Unpublished += (sender, args) => ContentService.Unpublished += (sender, args) =>
{ {
foreach (var content in args.PublishedEntities) foreach (var content in args.PublishedEntities)
notificationService.SendNotification(content, ActionUnpublish.Instance); notificationService.SendNotification(content, actions.GetAction<ActionUnpublish>());
}; };
} }
} }

View File

@@ -19,6 +19,7 @@ using Umbraco.Core.Services;
using Umbraco.Core.Strings; using Umbraco.Core.Strings;
using Umbraco.Core.Sync; using Umbraco.Core.Sync;
using Umbraco.Core._Legacy.PackageActions; using Umbraco.Core._Legacy.PackageActions;
using Umbraco.Web.Actions;
using Umbraco.Web.Cache; using Umbraco.Web.Cache;
using Umbraco.Web.Editors; using Umbraco.Web.Editors;
using Umbraco.Web.HealthCheck; using Umbraco.Web.HealthCheck;
@@ -27,7 +28,7 @@ using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing; using Umbraco.Web.Routing;
using Umbraco.Web.WebApi; using Umbraco.Web.WebApi;
using Umbraco.Web._Legacy.Actions;
using CoreCurrent = Umbraco.Core.Composing.Current; using CoreCurrent = Umbraco.Core.Composing.Current;
namespace Umbraco.Web.Composing namespace Umbraco.Web.Composing

View File

@@ -3,13 +3,13 @@ using LightInject;
using Umbraco.Core.Composing; using Umbraco.Core.Composing;
using Current = Umbraco.Web.Composing.Current; using Current = Umbraco.Web.Composing.Current;
using Umbraco.Core.Macros; using Umbraco.Core.Macros;
using Umbraco.Web.Actions;
using Umbraco.Web.Editors; using Umbraco.Web.Editors;
using Umbraco.Web.HealthCheck; using Umbraco.Web.HealthCheck;
using Umbraco.Web.Media; using Umbraco.Web.Media;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing; using Umbraco.Web.Routing;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Web.ContentApps; using Umbraco.Web.ContentApps;
// the namespace here is intentional - although defined in Umbraco.Web assembly, // the namespace here is intentional - although defined in Umbraco.Web assembly,

View File

@@ -3,18 +3,15 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.UI; using System.Web.UI;
using LightInject;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin; using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security; using Microsoft.Owin.Security;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Cache; using Umbraco.Core.Cache;
using Umbraco.Core.Configuration; using Umbraco.Core.Configuration;
@@ -22,18 +19,13 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging; using Umbraco.Core.Logging;
using Umbraco.Core.Manifest; using Umbraco.Core.Manifest;
using Umbraco.Core.Models.Identity; using Umbraco.Core.Models.Identity;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Security;
using Umbraco.Web.Models; using Umbraco.Web.Models;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.Trees;
using Umbraco.Web.UI.JavaScript; using Umbraco.Web.UI.JavaScript;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Features; using Umbraco.Web.Features;
using Umbraco.Web.Security; using Umbraco.Web.Security;
using Action = Umbraco.Web._Legacy.Actions.Action;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
using JArray = Newtonsoft.Json.Linq.JArray; using JArray = Newtonsoft.Json.Linq.JArray;
@@ -197,11 +189,8 @@ namespace Umbraco.Web.Editors
{ {
var initJs = new JsInitialization(_manifestParser); var initJs = new JsInitialization(_manifestParser);
var initCss = new CssInitialization(_manifestParser); var initCss = new CssInitialization(_manifestParser);
//get the legacy ActionJs file references to append as well var files = initJs.OptimizeBackOfficeScriptFiles(HttpContext, JsInitialization.GetDefaultInitialization());
var legacyActionJsRef = GetLegacyActionJs(LegacyJsActionType.JsUrl);
var files = initJs.OptimizeBackOfficeScriptFiles(HttpContext, JsInitialization.GetDefaultInitialization(), legacyActionJsRef);
var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco"); var result = JsInitialization.GetJavascriptInitialization(HttpContext, files, "umbraco");
result += initCss.GetStylesheetInitialization(HttpContext); result += initCss.GetStylesheetInitialization(HttpContext);
@@ -519,50 +508,7 @@ namespace Umbraco.Web.Editors
} }
return true; return true;
} }
internal static IEnumerable<string> GetLegacyActionJsForActions(LegacyJsActionType type, IEnumerable<string> values)
{
var blockList = new List<string>();
var urlList = new List<string>();
foreach (var jsFile in values)
{
var isJsPath = jsFile.DetectIsJavaScriptPath();
if (isJsPath.Success)
{
urlList.Add(isJsPath.Result);
}
else
{
blockList.Add(isJsPath.Result);
}
}
switch (type)
{
case LegacyJsActionType.JsBlock:
return blockList;
case LegacyJsActionType.JsUrl:
return urlList;
}
return blockList;
}
/// <summary>
/// Renders out all JavaScript references that have been declared in IActions
/// </summary>
private static IEnumerable<string> GetLegacyActionJs(LegacyJsActionType type)
{
return GetLegacyActionJsForActions(type, Action.GetJavaScriptFileReferences());
}
internal enum LegacyJsActionType
{
JsBlock,
JsUrl
}
private ActionResult RedirectToLocal(string returnUrl) private ActionResult RedirectToLocal(string returnUrl)
{ {
if (Url.IsLocalUrl(returnUrl)) if (Url.IsLocalUrl(returnUrl))

View File

@@ -30,10 +30,11 @@ using Umbraco.Core.Models.Validation;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Models; using Umbraco.Web.Models;
using Umbraco.Web.WebServices; using Umbraco.Web.WebServices;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
using Language = Umbraco.Web.Models.ContentEditing.Language; using Language = Umbraco.Web.Models.ContentEditing.Language;
using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors;
using Umbraco.Web.Actions;
using Umbraco.Web.ContentApps; using Umbraco.Web.ContentApps;
using Umbraco.Web.Editors.Binders; using Umbraco.Web.Editors.Binders;
using Umbraco.Web.Editors.Filters; using Umbraco.Web.Editors.Filters;
@@ -931,14 +932,14 @@ namespace Umbraco.Web.Editors
var errMsg = Services.TextService.Localize(localizationKey, new[] { _allLangs.Value[culture].CultureName }); var errMsg = Services.TextService.Localize(localizationKey, new[] { _allLangs.Value[culture].CultureName });
ModelState.AddModelError(key, errMsg); ModelState.AddModelError(key, errMsg);
} }
/// <summary> /// <summary>
/// Publishes a document with a given ID /// Publishes a document with a given ID
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks> /// <remarks>
/// The CanAccessContentAuthorize attribute will deny access to this method if the current user /// The EnsureUserPermissionForContent attribute will deny access to this method if the current user
/// does not have Publish access to this node. /// does not have Publish access to this node.
/// </remarks> /// </remarks>
/// ///
@@ -1076,7 +1077,7 @@ namespace Umbraco.Web.Editors
if (sorted.ParentId > 0) if (sorted.ParentId > 0)
{ {
Services.NotificationService.SendNotification(contentService.GetById(sorted.ParentId), ActionSort.Instance, UmbracoContext, Services.TextService, GlobalSettings); Services.NotificationService.SendNotification(contentService.GetById(sorted.ParentId), Current.Actions.GetAction<ActionSort>(), UmbracoContext, Services.TextService, GlobalSettings);
} }
return Request.CreateResponse(HttpStatusCode.OK); return Request.CreateResponse(HttpStatusCode.OK);
@@ -1223,7 +1224,7 @@ namespace Umbraco.Web.Editors
var permission = Services.UserService.GetPermissions(Security.CurrentUser, node.Path); var permission = Services.UserService.GetPermissions(Security.CurrentUser, node.Path);
if (permission.AssignedPermissions.Contains(ActionAssignDomain.Instance.Letter.ToString(), StringComparer.Ordinal) == false) if (permission.AssignedPermissions.Contains(ActionAssignDomain.ActionLetter.ToString(), StringComparer.Ordinal) == false)
{ {
var response = Request.CreateResponse(HttpStatusCode.BadRequest); var response = Request.CreateResponse(HttpStatusCode.BadRequest);
response.Content = new StringContent("You do not have permission to assign domains on that node."); response.Content = new StringContent("You do not have permission to assign domains on that node.");
@@ -1760,6 +1761,7 @@ namespace Umbraco.Web.Editors
: content.Variants.FirstOrDefault(x => x.Language.IsoCode == culture); : content.Variants.FirstOrDefault(x => x.Language.IsoCode == culture);
} }
[EnsureUserPermissionForContent("contentId", ActionRollback.ActionLetter)]
[HttpPost] [HttpPost]
public HttpResponseMessage PostRollbackContent(int contentId, int versionId, string culture = "*") public HttpResponseMessage PostRollbackContent(int contentId, int versionId, string culture = "*")
{ {

View File

@@ -9,11 +9,12 @@ using Umbraco.Core;
using Umbraco.Core.Logging; using Umbraco.Core.Logging;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Security; using Umbraco.Web.Security;
using Umbraco.Web.WebApi; using Umbraco.Web.WebApi;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web.Editors.Filters namespace Umbraco.Web.Editors.Filters
{ {
@@ -94,24 +95,24 @@ namespace Umbraco.Web.Editors.Filters
switch (contentItem.Action) switch (contentItem.Action)
{ {
case ContentSaveAction.Save: case ContentSaveAction.Save:
permissionToCheck.Add(ActionUpdate.Instance.Letter); permissionToCheck.Add(ActionUpdate.ActionLetter);
contentToCheck = contentItem.PersistedContent; contentToCheck = contentItem.PersistedContent;
contentIdToCheck = contentToCheck.Id; contentIdToCheck = contentToCheck.Id;
break; break;
case ContentSaveAction.Publish: case ContentSaveAction.Publish:
permissionToCheck.Add(ActionPublish.Instance.Letter); permissionToCheck.Add(ActionPublish.ActionLetter);
contentToCheck = contentItem.PersistedContent; contentToCheck = contentItem.PersistedContent;
contentIdToCheck = contentToCheck.Id; contentIdToCheck = contentToCheck.Id;
break; break;
case ContentSaveAction.SendPublish: case ContentSaveAction.SendPublish:
permissionToCheck.Add(ActionToPublish.Instance.Letter); permissionToCheck.Add(ActionToPublish.ActionLetter);
contentToCheck = contentItem.PersistedContent; contentToCheck = contentItem.PersistedContent;
contentIdToCheck = contentToCheck.Id; contentIdToCheck = contentToCheck.Id;
break; break;
case ContentSaveAction.SaveNew: case ContentSaveAction.SaveNew:
//Save new requires ActionNew //Save new requires ActionNew
permissionToCheck.Add(ActionNew.Instance.Letter); permissionToCheck.Add(ActionNew.ActionLetter);
if (contentItem.ParentId != Constants.System.Root) if (contentItem.ParentId != Constants.System.Root)
{ {
@@ -126,8 +127,8 @@ namespace Umbraco.Web.Editors.Filters
case ContentSaveAction.SendPublishNew: case ContentSaveAction.SendPublishNew:
//Send new requires both ActionToPublish AND ActionNew //Send new requires both ActionToPublish AND ActionNew
permissionToCheck.Add(ActionNew.Instance.Letter); permissionToCheck.Add(ActionNew.ActionLetter);
permissionToCheck.Add(ActionToPublish.Instance.Letter); permissionToCheck.Add(ActionToPublish.ActionLetter);
if (contentItem.ParentId != Constants.System.Root) if (contentItem.ParentId != Constants.System.Root)
{ {
contentToCheck = _contentService.GetById(contentItem.ParentId); contentToCheck = _contentService.GetById(contentItem.ParentId);
@@ -142,8 +143,8 @@ namespace Umbraco.Web.Editors.Filters
//Publish new requires both ActionNew AND ActionPublish //Publish new requires both ActionNew AND ActionPublish
//TODO: Shoudn't publish also require ActionUpdate since it will definitely perform an update to publish but maybe that's just implied //TODO: Shoudn't publish also require ActionUpdate since it will definitely perform an update to publish but maybe that's just implied
permissionToCheck.Add(ActionNew.Instance.Letter); permissionToCheck.Add(ActionNew.ActionLetter);
permissionToCheck.Add(ActionPublish.Instance.Letter); permissionToCheck.Add(ActionPublish.ActionLetter);
if (contentItem.ParentId != Constants.System.Root) if (contentItem.ParentId != Constants.System.Root)
{ {

View File

@@ -6,8 +6,9 @@ using Umbraco.Core;
using Umbraco.Core.CodeAnnotations; using Umbraco.Core.CodeAnnotations;
using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web.Models.Mapping namespace Umbraco.Web.Models.Mapping
{ {
@@ -37,13 +38,11 @@ namespace Umbraco.Web.Models.Mapping
private Permission GetPermission(IAction action, IUserGroup source) private Permission GetPermission(IAction action, IUserGroup source)
{ {
var result = new Permission(); var result = new Permission();
var attribute = action.GetType().GetCustomAttribute<ActionMetadataAttribute>(false);
result.Category = attribute == null result.Category = action.Category.IsNullOrWhiteSpace()
? _textService.Localize($"actionCategories/{Constants.Conventions.PermissionCategories.OtherCategory}") ? _textService.Localize($"actionCategories/{Constants.Conventions.PermissionCategories.OtherCategory}")
: _textService.Localize($"actionCategories/{attribute.Category}"); : _textService.Localize($"actionCategories/{action.Category}");
result.Name = attribute == null || attribute.Name.IsNullOrWhiteSpace() result.Name = _textService.Localize($"actions/{action.Alias}");
? _textService.Localize($"actions/{action.Alias}")
: attribute.Name;
result.Description = _textService.Localize($"actionDescriptions/{action.Alias}"); result.Description = _textService.Localize($"actionDescriptions/{action.Alias}");
result.Icon = action.Icon; result.Icon = action.Icon;
result.Checked = source.Permissions != null && source.Permissions.Contains(action.Letter.ToString(CultureInfo.InvariantCulture)); result.Checked = source.Permissions != null && source.Permissions.Contains(action.Letter.ToString(CultureInfo.InvariantCulture));

View File

@@ -11,7 +11,8 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Security; using Umbraco.Core.Security;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
namespace Umbraco.Web.Models.Mapping namespace Umbraco.Web.Models.Mapping
{ {

View File

@@ -1,41 +1,55 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Services;
namespace Umbraco.Web.Models.Trees namespace Umbraco.Web.Models.Trees
{ {
/// <summary> /// <inheritdoc />
/// A menu item that represents some JS that needs to execute when the menu item is clicked. /// <summary>
/// </summary> /// A menu item that represents some JS that needs to execute when the menu item is clicked.
/// <remarks> /// </summary>
/// These types of menu items are rare but they do exist. Things like refresh node simply execute /// <remarks>
/// JS and don't launch a dialog. /// These types of menu items are rare but they do exist. Things like refresh node simply execute
/// /// JS and don't launch a dialog.
/// Each action menu item describes what angular service that it's method exists in and what the method name is. /// Each action menu item describes what angular service that it's method exists in and what the method name is.
/// /// An action menu item must describe the angular service name for which it's method exists. It may also define what the
/// An action menu item must describe the angular service name for which it's method exists. It may also define what the /// method name is that will be called in this service but if one is not specified then we will assume the method name is the
/// method name is that will be called in this service but if one is not specified then we will assume the method name is the /// same as the Type name of the current action menu class.
/// same as the Type name of the current action menu class. /// </remarks>
/// </remarks>
public abstract class ActionMenuItem : MenuItem public abstract class ActionMenuItem : MenuItem
{ {
protected ActionMenuItem() /// <summary>
: base() /// The angular service name containing the <see cref="AngularServiceMethodName"/>
{ /// </summary>
var attribute = GetType().GetCustomAttribute<ActionMenuItemAttribute>(false); public abstract string AngularServiceName { get; }
if (attribute == null)
{
throw new InvalidOperationException("All " + typeof (ActionMenuItem).FullName + " instances must be attributed with " + typeof (ActionMenuItemAttribute).FullName);
}
/// <summary>
/// The angular service method name to call for this menu item
/// </summary>
public virtual string AngularServiceMethodName { get; } = null;
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 //add the current type to the metadata
if (attribute.MethodName.IsNullOrWhiteSpace()) if (AngularServiceMethodName.IsNullOrWhiteSpace())
{ {
//if no method name is supplied we will assume that the menu action is the type name of the current menu class //if no method name is supplied we will assume that the menu action is the type name of the current menu class
AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, this.GetType().Name)); ExecuteJsMethod($"{AngularServiceName}.{this.GetType().Name}");
} }
else else
{ {
AdditionalData.Add("jsAction", string.Format("{0}.{1}", attribute.ServiceName, attribute.MethodName)); ExecuteJsMethod($"{AngularServiceName}.{AngularServiceMethodName}");
} }
} }
} }

View File

@@ -1,39 +0,0 @@
using System;
using Umbraco.Core.Exceptions;
namespace Umbraco.Web.Models.Trees
{
/// <summary>
/// The attribute to assign to any ActionMenuItem objects.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class ActionMenuItemAttribute : Attribute
{
/// <summary>
/// This constructor defines both the angular service and method name to use
/// </summary>
/// <param name="serviceName"></param>
/// <param name="methodName"></param>
public ActionMenuItemAttribute(string serviceName, string methodName)
{
if (string.IsNullOrWhiteSpace(serviceName)) throw new ArgumentNullOrEmptyException(nameof(serviceName));
if (string.IsNullOrWhiteSpace(methodName)) throw new ArgumentNullOrEmptyException(nameof(methodName));
MethodName = methodName;
ServiceName = serviceName;
}
/// <summary>
/// This constructor will assume that the method name equals the type name of the action menu class
/// </summary>
/// <param name="serviceName"></param>
public ActionMenuItemAttribute(string serviceName)
{
if (string.IsNullOrWhiteSpace(serviceName)) throw new ArgumentNullOrEmptyException(nameof(serviceName));
MethodName = "";
ServiceName = serviceName;
}
public string MethodName { get; }
public string ServiceName { get; }
}
}

View File

@@ -1,10 +1,27 @@
namespace Umbraco.Web.Models.Trees using Umbraco.Core.Services;
using Umbraco.Web.Actions;
namespace Umbraco.Web.Models.Trees
{ {
/// <summary> /// <summary>
/// Represents the refresh node menu item /// Represents the refresh node menu item
/// </summary> /// </summary>
[ActionMenuItem("umbracoMenuActions")]
public sealed class CreateChildEntity : ActionMenuItem public sealed class CreateChildEntity : ActionMenuItem
{ {
public override string AngularServiceName => "umbracoMenuActions";
public CreateChildEntity(string name, bool seperatorBefore = false)
: base(ActionNew.ActionAlias, name)
{
Icon = "add"; Name = name;
SeperatorBefore = seperatorBefore;
}
public CreateChildEntity(ILocalizedTextService textService, bool seperatorBefore = false)
: base(ActionNew.ActionAlias, textService)
{
Icon = "add";
SeperatorBefore = seperatorBefore;
}
} }
} }

View File

@@ -1,15 +0,0 @@
namespace Umbraco.Web.Models.Trees
{
/// <summary>
/// Represents the disable user menu item
/// </summary>
[ActionMenuItem("umbracoMenuActions")]
public sealed class DisableUser : ActionMenuItem
{
public DisableUser()
{
Alias = "disable";
Icon = "remove";
}
}
}

View File

@@ -1,9 +1,17 @@
namespace Umbraco.Web.Models.Trees using Umbraco.Core.Services;
namespace Umbraco.Web.Models.Trees
{ {
/// <summary> /// <summary>
/// Represents the export member menu item /// Represents the export member menu item
/// </summary> /// </summary>
[ActionMenuItem("umbracoMenuActions")]
public sealed class ExportMember : ActionMenuItem public sealed class ExportMember : ActionMenuItem
{ } {
public override string AngularServiceName => "umbracoMenuActions";
public ExportMember(ILocalizedTextService textService) : base("export", textService)
{
Icon = "download-alt";
}
}
} }

View File

@@ -5,8 +5,9 @@ using System.Collections.Generic;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web.Models.Trees namespace Umbraco.Web.Models.Trees
{ {
@@ -30,15 +31,27 @@ namespace Umbraco.Web.Models.Trees
Name = name; Name = name;
} }
public MenuItem(IAction legacyMenu, string name = "")
public MenuItem(string alias, ILocalizedTextService textService)
: this() : this()
{ {
Name = name.IsNullOrWhiteSpace() ? legacyMenu.Alias : name; Alias = alias;
Alias = legacyMenu.Alias; Name = textService.Localize($"actions/{Alias}");
}
/// <summary>
/// Create a menu item based on an <see cref="IAction"/> definition
/// </summary>
/// <param name="action"></param>
/// <param name="name"></param>
public MenuItem(IAction action, string name = "")
: this()
{
Name = name.IsNullOrWhiteSpace() ? action.Alias : name;
Alias = action.Alias;
SeperatorBefore = false; SeperatorBefore = false;
Icon = legacyMenu.Icon; Icon = action.Icon;
Action = legacyMenu; Action = action;
OpensDialog = legacyMenu.OpensDialog;
} }
#endregion #endregion
@@ -73,6 +86,9 @@ namespace Umbraco.Web.Models.Trees
[DataMember(Name = "cssclass")] [DataMember(Name = "cssclass")]
public string Icon { get; set; } public string Icon { get; set; }
/// <summary>
/// Used in the UI to inform the user that the menu item will open a dialog/confirmation
/// </summary>
[DataMember(Name = "opensDialog")] [DataMember(Name = "opensDialog")]
public bool OpensDialog { get; set; } public bool OpensDialog { get; set; }
@@ -128,7 +144,7 @@ namespace Umbraco.Web.Models.Trees
/// Adds the required meta data to the menu item so that angular knows to attempt to call the Js method. /// Adds the required meta data to the menu item so that angular knows to attempt to call the Js method.
/// </summary> /// </summary>
/// <param name="jsToExecute"></param> /// <param name="jsToExecute"></param>
public void ExecuteLegacyJs(string jsToExecute) public void ExecuteJsMethod(string jsToExecute)
{ {
SetJsAction(jsToExecute); SetJsAction(jsToExecute);
} }
@@ -206,7 +222,7 @@ namespace Umbraco.Web.Models.Trees
} }
} }
} }
#endregion #endregion
} }

View File

@@ -1,8 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web.Models.Trees namespace Umbraco.Web.Models.Trees
{ {
@@ -24,7 +26,7 @@ namespace Umbraco.Web.Models.Trees
} }
/// <summary> /// <summary>
/// Adds a menu item /// Adds a menu item based on a <see cref="IAction"/>
/// </summary> /// </summary>
/// <param name="action"></param> /// <param name="action"></param>
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param> /// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
@@ -32,78 +34,20 @@ namespace Umbraco.Web.Models.Trees
{ {
var item = new MenuItem(action, name); var item = new MenuItem(action, name);
DetectLegacyActionMenu(action.GetType(), item);
Add(item); Add(item);
return item; return item;
} }
/// <summary>
/// Adds a menu item
/// </summary>
/// <typeparam name="TMenuItem"></typeparam>
/// <typeparam name="TAction"></typeparam>
/// <param name="hasSeparator"></param>
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
/// <param name="additionalData"></param>
/// <returns></returns>
public TMenuItem Add<TMenuItem, TAction>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
where TAction : IAction
where TMenuItem : MenuItem, new()
{
var item = CreateMenuItem<TAction>(name, hasSeparator, additionalData);
if (item == null) return null;
var customMenuItem = new TMenuItem
{
Name = item.Name,
Alias = item.Alias,
SeperatorBefore = hasSeparator,
Icon = item.Icon,
Action = item.Action
};
Add(customMenuItem);
return customMenuItem;
}
/// <summary>
/// Adds a menu item
/// </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, null);
}
/// <summary>
/// Adds a menu item with a key value pair which is merged to the AdditionalData bag
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
/// <param name="hasSeparator"></param>
public MenuItem Add<T>(string name, string key, string value, bool hasSeparator = false)
where T : IAction
{
return Add<T>(name, hasSeparator, new Dictionary<string, object> { { key, value } });
}
/// <summary> /// <summary>
/// Adds a menu item with a dictionary which is merged to the AdditionalData bag /// Adds a menu item with a dictionary which is merged to the AdditionalData bag
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="hasSeparator"></param> /// <param name="hasSeparator"></param>
/// /// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param> /// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param>
/// <param name="additionalData"></param> public MenuItem Add<T>(string name, bool hasSeparator = false)
public MenuItem Add<T>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
where T : IAction where T : IAction
{ {
var item = CreateMenuItem<T>(name, hasSeparator, additionalData); var item = CreateMenuItem<T>(name, hasSeparator);
if (item != null) if (item != null)
{ {
Add(item); Add(item);
@@ -113,69 +57,51 @@ namespace Umbraco.Web.Models.Trees
} }
/// <summary> /// <summary>
/// /// Adds a menu item with a dictionary which is merged to the AdditionalData bag
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="hasSeparator"></param> /// <param name="hasSeparator"></param>
/// <param name="name">The text to display for the menu item, will default to the IAction alias if not specified</param> /// <param name="textService">The <see cref="ILocalizedTextService"/> used to localize the action name based on it's alias</param>
/// <param name="additionalData"></param> /// <param name="opensDialog"></param>
/// <returns></returns> public MenuItem Add<T>(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false)
internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false, IDictionary<string, object> additionalData = null)
where T : IAction where T : IAction
{ {
var item = Current.Actions.GetAction<T>(); var item = CreateMenuItem<T>(textService, hasSeparator);
if (item != null) if (item != null)
{ {
var menuItem = new MenuItem(item, name) Add(item);
{ return item;
SeperatorBefore = hasSeparator
};
if (additionalData != null)
{
foreach (var i in additionalData)
{
menuItem.AdditionalData[i.Key] = i.Value;
}
}
DetectLegacyActionMenu(typeof(T), menuItem);
//TODO: Once we implement 'real' menu items, not just IActions we can implement this since
// people may need to pass specific data to their menu items
////validate the data in the meta data bag
//item.ValidateRequiredData(AdditionalData);
return menuItem;
} }
return null; return null;
} }
/// <summary> internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false)
/// Checks if the IAction type passed in is attributed with LegacyActionMenuItemAttribute and if so where T : IAction
/// ensures that the correct action metadata is added.
/// </summary>
/// <param name="actionType"></param>
/// <param name="menuItem"></param>
private void DetectLegacyActionMenu(Type actionType, MenuItem menuItem)
{ {
//This checks for legacy IActions that have the LegacyActionMenuItemAttribute which is a legacy hack var item = Current.Actions.GetAction<T>();
// to make old IAction actions work in v7 by mapping to the JS used by the new menu items if (item == null) return null;
var attribute = actionType.GetCustomAttribute<LegacyActionMenuItemAttribute>(false); var menuItem = new MenuItem(item, name)
if (attribute != null)
{ {
//add the current type to the metadata SeperatorBefore = hasSeparator
if (attribute.MethodName.IsNullOrWhiteSpace()) };
{
//if no method name is supplied we will assume that the menu action is the type name of the current menu class return menuItem;
menuItem.AdditionalData.Add(MenuItem.JsActionKey, string.Format("{0}.{1}", attribute.ServiceName, this.GetType().Name));
}
else
{
menuItem.AdditionalData.Add(MenuItem.JsActionKey, string.Format("{0}.{1}", attribute.ServiceName, attribute.MethodName));
}
}
} }
internal MenuItem CreateMenuItem<T>(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false)
where T : IAction
{
var item = Current.Actions.GetAction<T>();
if (item == null) return null;
var menuItem = new MenuItem(item, textService.Localize($"actions/{item.Alias}"))
{
SeperatorBefore = hasSeparator,
OpensDialog = opensDialog
};
return menuItem;
}
} }
} }

View File

@@ -1,10 +1,27 @@
namespace Umbraco.Web.Models.Trees using Umbraco.Core.Services;
namespace Umbraco.Web.Models.Trees
{ {
/// <inheritdoc />
/// <summary> /// <summary>
/// Represents the refresh node menu item /// Represents the refresh node menu item
/// </summary> /// </summary>
[ActionMenuItem("umbracoMenuActions")]
public sealed class RefreshNode : ActionMenuItem public sealed class RefreshNode : ActionMenuItem
{ {
public override string AngularServiceName => "umbracoMenuActions";
public RefreshNode(string name, bool seperatorBefore = false)
: base("refreshNode", name)
{
Icon = "refresh";
SeperatorBefore = seperatorBefore;
}
public RefreshNode(ILocalizedTextService textService, bool seperatorBefore = false)
: base("refreshNode", textService)
{
Icon = "refresh";
SeperatorBefore = seperatorBefore;
}
} }
} }

View File

@@ -6,9 +6,10 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Web._Legacy.Actions;
using System.Collections.Generic; using System.Collections.Generic;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
namespace Umbraco.Web namespace Umbraco.Web

View File

@@ -31,6 +31,7 @@ using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.Runtime; using Umbraco.Core.Runtime;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Examine; using Umbraco.Examine;
using Umbraco.Web.Actions;
using Umbraco.Web.Cache; using Umbraco.Web.Cache;
using Umbraco.Web.Composing.CompositionRoots; using Umbraco.Web.Composing.CompositionRoots;
using Umbraco.Web.ContentApps; using Umbraco.Web.ContentApps;
@@ -53,7 +54,7 @@ using Umbraco.Web.Tour;
using Umbraco.Web.Trees; using Umbraco.Web.Trees;
using Umbraco.Web.UI.JavaScript; using Umbraco.Web.UI.JavaScript;
using Umbraco.Web.WebApi; using Umbraco.Web.WebApi;
using Umbraco.Web._Legacy.Actions;
using Current = Umbraco.Web.Composing.Current; using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Web.Runtime namespace Umbraco.Web.Runtime
@@ -139,7 +140,7 @@ namespace Umbraco.Web.Runtime
Current.DefaultRenderMvcControllerType = typeof(RenderMvcController); // fixme WRONG! Current.DefaultRenderMvcControllerType = typeof(RenderMvcController); // fixme WRONG!
composition.Container.RegisterCollectionBuilder<ActionCollectionBuilder>() composition.Container.RegisterCollectionBuilder<ActionCollectionBuilder>()
.SetProducer(() => typeLoader.GetActions()); .Add(() => typeLoader.GetTypes<IAction>());
var surfaceControllerTypes = new SurfaceControllerTypeCollection(typeLoader.GetSurfaceControllers()); var surfaceControllerTypes = new SurfaceControllerTypeCollection(typeLoader.GetSurfaceControllers());
composition.Container.RegisterInstance(surfaceControllerTypes); composition.Container.RegisterInstance(surfaceControllerTypes);

View File

@@ -4,10 +4,11 @@ using Umbraco.Core;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -92,9 +93,8 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
// root actions // root actions
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService, true));
$"actions/{ActionRefresh.Instance.Alias}"), true);
return menu; return menu;
} }
var cte = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType); var cte = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
@@ -102,15 +102,15 @@ namespace Umbraco.Web.Trees
if (cte != null) if (cte != null)
{ {
var ct = Services.ContentTypeService.Get(cte.Id); var ct = Services.ContentTypeService.Get(cte.Id);
var createItem = menu.Items.Add<ActionCreateBlueprintFromContent>(Services.TextService.Localize($"actions/{ActionCreateBlueprintFromContent.Instance.Alias}")); var createItem = menu.Items.Add<ActionCreateBlueprintFromContent>(Services.TextService, opensDialog: true);
createItem.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct.Alias); createItem.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct.Alias);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize($"actions/{ActionRefresh.Instance.Alias}"), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}")); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
return menu; return menu;
} }

View File

@@ -8,11 +8,12 @@ using Umbraco.Core;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Search; using Umbraco.Web.Search;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
@@ -114,23 +115,21 @@ namespace Umbraco.Web.Trees
// if the user's start node is not the root then the only menu item to display is refresh // if the user's start node is not the root then the only menu item to display is refresh
if (UserStartNodes.Contains(Constants.System.Root) == false) if (UserStartNodes.Contains(Constants.System.Root) == false)
{ {
menu.Items.Add<RefreshNode, ActionRefresh>( menu.Items.Add(new RefreshNode(Services.TextService, true));
Services.TextService.Localize(string.Concat("actions/", ActionRefresh.Instance.Alias)),
true);
return menu; return menu;
} }
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
// we need to get the default permissions as you can't set permissions on the very root node // we need to get the default permissions as you can't set permissions on the very root node
var permission = Services.UserService.GetPermissions(Security.CurrentUser, Constants.System.Root).First(); var permission = Services.UserService.GetPermissions(Security.CurrentUser, Constants.System.Root).First();
var nodeActions = global::Umbraco.Web._Legacy.Actions.Action.FromEntityPermission(permission) var nodeActions = Current.Actions.FromEntityPermission(permission)
.Select(x => new MenuItem(x)); .Select(x => new MenuItem(x));
//these two are the standard items //these two are the standard items
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionSort>(Services.TextService.Localize("actions", ActionSort.Instance.Alias), true); menu.Items.Add<ActionSort>(Services.TextService, true);
//filter the standard items //filter the standard items
FilterUserAllowedMenuItems(menu, nodeActions); FilterUserAllowedMenuItems(menu, nodeActions);
@@ -143,7 +142,7 @@ namespace Umbraco.Web.Trees
// add default actions for *all* users // add default actions for *all* users
// fixme - temp disable RePublish as the page itself (republish.aspx) has been temp disabled // fixme - temp disable RePublish as the page itself (republish.aspx) has been temp disabled
//menu.Items.Add<ActionRePublish>(Services.TextService.Localize("actions", ActionRePublish.Instance.Alias)).ConvertLegacyMenuItem(null, "content", "content"); //menu.Items.Add<ActionRePublish>(Services.TextService.Localize("actions", ActionRePublish.Instance.Alias)).ConvertLegacyMenuItem(null, "content", "content");
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -165,9 +164,7 @@ namespace Umbraco.Web.Trees
if (Security.CurrentUser.HasPathAccess(item, Services.EntityService, RecycleBinId) == false) if (Security.CurrentUser.HasPathAccess(item, Services.EntityService, RecycleBinId) == false)
{ {
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
menu.Items.Add<RefreshNode, ActionRefresh>( menu.Items.Add(new RefreshNode(Services.TextService, true));
Services.TextService.Localize(string.Concat("actions/", ActionRefresh.Instance.Alias)),
true);
return menu; return menu;
} }
@@ -182,7 +179,7 @@ namespace Umbraco.Web.Trees
else else
{ {
//set the default to create //set the default to create
nodeMenu.DefaultMenuAlias = ActionNew.Instance.Alias; nodeMenu.DefaultMenuAlias = ActionNew.ActionAlias;
} }
var allowedMenuItems = GetAllowedUserMenuItemsForNode(item); var allowedMenuItems = GetAllowedUserMenuItemsForNode(item);
@@ -228,25 +225,25 @@ namespace Umbraco.Web.Trees
protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item) protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item)
{ {
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
AddActionNode<ActionNew>(item, menu); AddActionNode<ActionNew>(item, menu, opensDialog: true);
AddActionNode<ActionDelete>(item, menu); AddActionNode<ActionDelete>(item, menu, opensDialog: true);
AddActionNode<ActionCreateBlueprintFromContent>(item, menu, opensDialog: true);
AddActionNode<ActionCreateBlueprintFromContent>(item, menu); AddActionNode<ActionMove>(item, menu, true, opensDialog: true);
AddActionNode<ActionCopy>(item, menu, opensDialog: true);
//need to ensure some of these are converted to the legacy system - until we upgrade them all to be angularized.
AddActionNode<ActionMove>(item, menu, true);
AddActionNode<ActionCopy>(item, menu);
AddActionNode<ActionSort>(item, menu, true); AddActionNode<ActionSort>(item, menu, true);
AddActionNode<ActionAssignDomain>(item, menu, opensDialog: true);
AddActionNode<ActionRights>(item, menu, opensDialog: true);
//fixme - conver this editor to angular
AddActionNode<ActionProtect>(item, menu, true, convert: true, opensDialog: true);
AddActionNode<ActionToPublish>(item, menu, convert: true); menu.Items.Add(new MenuItem("notify", Services.TextService)
AddActionNode<ActionAssignDomain>(item, menu); {
AddActionNode<ActionRights>(item, menu, convert: true); Icon = "megaphone",
AddActionNode<ActionProtect>(item, menu, true, true); SeperatorBefore = true,
OpensDialog = true
AddActionNode<ActionNotify>(item, menu, true); });
AddActionNode<RefreshNode, ActionRefresh>(item, menu, true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -259,10 +256,10 @@ namespace Umbraco.Web.Trees
protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity item) protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity item)
{ {
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
menu.Items.Add<ActionRestore>(Services.TextService.Localize("actions", ActionRestore.Instance.Alias)); menu.Items.Add<ActionRestore>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -306,19 +303,14 @@ namespace Umbraco.Web.Trees
entity.Name = "[[" + entity.Id + "]]"; entity.Name = "[[" + entity.Id + "]]";
} }
private void AddActionNode<TAction>(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool convert = false) //fixme: Remove the need for converting to legacy
private void AddActionNode<TAction>(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool convert = false, bool opensDialog = false)
where TAction : IAction where TAction : IAction
{ {
//fixme: Inject
var menuItem = menu.Items.Add<TAction>(Services.TextService.Localize("actions", Current.Actions.GetAction<TAction>().Alias), hasSeparator); var menuItem = menu.Items.Add<TAction>(Services.TextService.Localize("actions", Current.Actions.GetAction<TAction>().Alias), hasSeparator);
if (convert) menuItem.ConvertLegacyMenuItem(item, "content", "content"); if (convert) menuItem.ConvertLegacyMenuItem(item, "content", "content");
} menuItem.OpensDialog = opensDialog;
private void AddActionNode<TItem, TAction>(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool convert = false)
where TItem : MenuItem, new()
where TAction : IAction
{
var menuItem = menu.Items.Add<TItem, TAction>(Services.TextService.Localize("actions", Current.Actions.GetAction<TAction>().Alias), hasSeparator);
if (convert) menuItem.ConvertLegacyMenuItem(item, "content", "content");
} }
public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null) public IEnumerable<SearchResultItem> Search(string query, int pageSize, long pageIndex, out long totalFound, string searchFrom = null)

View File

@@ -14,7 +14,9 @@ using Umbraco.Web.Models.Trees;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using System.Globalization; using System.Globalization;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
{ {
@@ -347,8 +349,12 @@ namespace Umbraco.Web.Trees
if (RecycleBinId.ToInvariantString() == id) if (RecycleBinId.ToInvariantString() == id)
{ {
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
menu.Items.Add<ActionEmptyTranscan>(Services.TextService.Localize("actions/emptyTrashcan")); menu.Items.Add(new MenuItem("emptyRecycleBin", Services.TextService)
menu.Items.Add<ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); {
Icon = "trash",
OpensDialog = true
});
menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -381,13 +387,16 @@ namespace Umbraco.Web.Trees
internal IEnumerable<MenuItem> GetAllowedUserMenuItemsForNode(IUmbracoEntity dd) internal IEnumerable<MenuItem> GetAllowedUserMenuItemsForNode(IUmbracoEntity dd)
{ {
var permission = Services.UserService.GetPermissions(Security.CurrentUser, dd.Path); var permission = Services.UserService.GetPermissions(Security.CurrentUser, dd.Path);
var actions = global::Umbraco.Web._Legacy.Actions.Action.FromEntityPermission(permission) //fixme: inject
var actions = Current.Actions.FromEntityPermission(permission)
.ToList(); .ToList();
var actionDelete = Current.Actions.GetAction<ActionDelete>();
// A user is allowed to delete their own stuff // A user is allowed to delete their own stuff
var tryGetCurrentUserId = Security.GetUserId(); var tryGetCurrentUserId = Security.GetUserId();
if (tryGetCurrentUserId && dd.CreatorId == tryGetCurrentUserId.Result && actions.Contains(ActionDelete.Instance) == false) if (tryGetCurrentUserId && dd.CreatorId == tryGetCurrentUserId.Result && actions.Contains(actionDelete) == false)
actions.Add(ActionDelete.Instance); actions.Add(actionDelete);
return actions.Select(x => new MenuItem(x)); return actions.Select(x => new MenuItem(x));
} }

View File

@@ -7,7 +7,8 @@ using Umbraco.Core;
using Umbraco.Core.Configuration; using Umbraco.Core.Configuration;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
@@ -77,12 +78,18 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
// root actions // root actions
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionImport>(Services.TextService.Localize(string.Format("actions/{0}", ActionImport.Instance.Alias)), true); menu.Items.Add(new MenuItem("importDocumentType", Services.TextService)
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); {
Icon = "page-up",
SeperatorBefore = true,
OpensDialog = true
});
menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -90,11 +97,11 @@ namespace Umbraco.Web.Trees
if (container != null) if (container != null)
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add(new MenuItem("rename", Services.TextService.Localize(String.Format("actions/{0}", "rename"))) menu.Items.Add(new MenuItem("rename", Services.TextService)
{ {
Icon = "icon icon-edit" Icon = "icon icon-edit"
}); });
@@ -102,11 +109,9 @@ namespace Umbraco.Web.Trees
if (container.HasChildren == false) if (container.HasChildren == false)
{ {
//can delete doc type //can delete doc type
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
} }
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
} }
else else
{ {
@@ -115,18 +120,23 @@ namespace Umbraco.Web.Trees
if (enableInheritedDocumentTypes) if (enableInheritedDocumentTypes)
{ {
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
} }
//no move action if this is a child doc type //no move action if this is a child doc type
if (parent == null) if (parent == null)
{ {
menu.Items.Add<ActionMove>(Services.TextService.Localize(string.Format("actions/{0}", ActionMove.Instance.Alias)), true); menu.Items.Add<ActionMove>(Services.TextService, true, opensDialog: true);
} }
menu.Items.Add<ActionCopy>(Services.TextService.Localize(string.Format("actions/{0}", ActionCopy.Instance.Alias))); menu.Items.Add<ActionCopy>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionExport>(Services.TextService.Localize(string.Format("actions/{0}", ActionExport.Instance.Alias)), true); menu.Items.Add(new MenuItem("export", Services.TextService)
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); {
Icon = "download-alt",
SeperatorBefore = true,
OpensDialog = true
});
menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
if (enableInheritedDocumentTypes) if (enableInheritedDocumentTypes)
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
} }
return menu; return menu;

View File

@@ -9,9 +9,10 @@ using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Search; using Umbraco.Web.Search;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -100,11 +101,11 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
// root actions // root actions
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -112,9 +113,9 @@ namespace Umbraco.Web.Trees
if (container != null) if (container != null)
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add(new MenuItem("rename", Services.TextService.Localize("actions/rename")) menu.Items.Add(new MenuItem("rename", Services.TextService.Localize("actions/rename"))
{ {
@@ -124,19 +125,18 @@ namespace Umbraco.Web.Trees
if (container.HasChildren == false) if (container.HasChildren == false)
{ {
//can delete data type //can delete data type
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}")); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
} }
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService, true));
$"actions/{ActionRefresh.Instance.Alias}"), hasSeparator: true);
} }
else else
{ {
var nonDeletableSystemDataTypeIds = GetNonDeletableSystemDataTypeIds(); var nonDeletableSystemDataTypeIds = GetNonDeletableSystemDataTypeIds();
if (nonDeletableSystemDataTypeIds.Contains(int.Parse(id)) == false) if (nonDeletableSystemDataTypeIds.Contains(int.Parse(id)) == false)
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}")); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionMove>(Services.TextService.Localize($"actions/{ActionMove.Instance.Alias}"), hasSeparator: true); menu.Items.Add<ActionMove>(Services.TextService, hasSeparator: true, opensDialog: true);
} }
return menu; return menu;

View File

@@ -3,7 +3,8 @@ using System.Linq;
using System.Net.Http.Formatting; using System.Net.Http.Formatting;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
@@ -95,14 +96,12 @@ namespace Umbraco.Web.Trees
{ {
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
if (id != Constants.System.Root.ToInvariantString()) if (id != Constants.System.Root.ToInvariantString())
menu.Items.Add<ActionDelete>(Services.TextService.Localize( menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
$"actions/{ActionDelete.Instance.Alias}"), true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService, true));
$"actions/{ActionRefresh.Instance.Alias}"), true);
return menu; return menu;
} }

View File

@@ -7,8 +7,9 @@ using System.Web;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.IO; using Umbraco.Core.IO;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -79,11 +80,11 @@ namespace Umbraco.Web.Trees
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
//create action //create action
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
//refresh action //refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -93,9 +94,9 @@ namespace Umbraco.Web.Trees
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
//create action //create action
menu.Items.Add<ActionNew>(Services.TextService.Localize(string.Format("actions/{0}", ActionNew.Instance.Alias))); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
var hasChildren = FileSystem.GetFiles(path).Any() || FileSystem.GetDirectories(path).Any(); var hasChildren = FileSystem.GetFiles(path).Any() || FileSystem.GetDirectories(path).Any();
@@ -103,11 +104,11 @@ namespace Umbraco.Web.Trees
if (hasChildren == false) if (hasChildren == false)
{ {
//delete action //delete action
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true); menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
} }
//refresh action //refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -117,7 +118,7 @@ namespace Umbraco.Web.Trees
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
//if it's not a directory then we only allow to delete the item //if it's not a directory then we only allow to delete the item
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias))); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
return menu; return menu;
} }

View File

@@ -6,7 +6,8 @@ using System.Web.Http.Routing;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Configuration; using Umbraco.Core.Configuration;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
@@ -17,6 +18,8 @@ namespace Umbraco.Web.Trees
/// </summary> /// </summary>
internal class LegacyTreeDataConverter internal class LegacyTreeDataConverter
{ {
//fixme: remove this whole class when everything is angularized
/// <summary> /// <summary>
/// This will look at the legacy IAction's JsFunctionName and convert it to a confirmation dialog view if possible /// This will look at the legacy IAction's JsFunctionName and convert it to a confirmation dialog view if possible
/// </summary> /// </summary>
@@ -24,14 +27,9 @@ namespace Umbraco.Web.Trees
/// <returns></returns> /// <returns></returns>
internal static Attempt<string> GetLegacyConfirmView(IAction action) internal static Attempt<string> GetLegacyConfirmView(IAction action)
{ {
if (action.JsFunctionName.IsNullOrWhiteSpace()) switch (action)
{ {
return Attempt<string>.Fail(); case ActionDelete actionDelete:
}
switch (action.JsFunctionName)
{
case "UmbClientMgr.appActions().actionDelete()":
return Attempt.Succeed( return Attempt.Succeed(
UmbracoConfig.For.GlobalSettings().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html"); UmbracoConfig.For.GlobalSettings().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html");
} }
@@ -49,64 +47,18 @@ namespace Umbraco.Web.Trees
/// <param name="nodeType"></param> /// <param name="nodeType"></param>
internal static Attempt<LegacyUrlAction> GetUrlAndTitleFromLegacyAction(IAction action, string nodeId, string nodeType, string nodeName, string currentSection) internal static Attempt<LegacyUrlAction> GetUrlAndTitleFromLegacyAction(IAction action, string nodeId, string nodeType, string nodeName, string currentSection)
{ {
if (action.JsFunctionName.IsNullOrWhiteSpace()) switch (action)
{ {
return Attempt<LegacyUrlAction>.Fail(); case ActionNew actionNew:
}
switch (action.JsFunctionName)
{
case "UmbClientMgr.appActions().actionNew()":
return Attempt.Succeed( return Attempt.Succeed(
new LegacyUrlAction( new LegacyUrlAction(
"create.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks, "create.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/create"))); Current.Services.TextService.Localize("actions/create")));
case "UmbClientMgr.appActions().actionNewFolder()": case ActionProtect actionProtect:
return Attempt.Succeed(
new LegacyUrlAction(
"createFolder.aspx?nodeId=" + nodeId + "&nodeType=" + nodeType + "&nodeName=" + nodeName + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/create")));
case "UmbClientMgr.appActions().actionProtect()":
return Attempt.Succeed( return Attempt.Succeed(
new LegacyUrlAction( new LegacyUrlAction(
"dialogs/protectPage.aspx?mode=cut&nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks, "dialogs/protectPage.aspx?mode=cut&nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/protect"))); Current.Services.TextService.Localize("actions/protect")));
case "UmbClientMgr.appActions().actionRollback()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/rollback.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/rollback")));
case "UmbClientMgr.appActions().actionNotify()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/notifications.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/notify")));
case "UmbClientMgr.appActions().actionPublish()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/publish.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/publish")));
case "UmbClientMgr.appActions().actionChangeDocType()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/ChangeDocType.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/changeDocType")));
case "UmbClientMgr.appActions().actionToPublish()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/SendPublish.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/sendtopublish")));
case "UmbClientMgr.appActions().actionRePublish()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/republish.aspx?rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/republish")));
case "UmbClientMgr.appActions().actionSendToTranslate()":
return Attempt.Succeed(
new LegacyUrlAction(
"dialogs/sendToTranslation.aspx?id=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
Current.Services.TextService.Localize("actions/sendToTranslate")));
} }
return Attempt<LegacyUrlAction>.Fail(); return Attempt<LegacyUrlAction>.Fail();
} }

View File

@@ -8,7 +8,8 @@ using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -58,13 +59,13 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//Create the normal create action //Create the normal create action
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)) menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true)
//Since we haven't implemented anything for macros in angular, this needs to be converted to //Since we haven't implemented anything for macros in angular, this needs to be converted to
//use the legacy format //use the legacy format
.ConvertLegacyMenuItem(null, "initmacros", queryStrings.GetValue<string>("application")); .ConvertLegacyMenuItem(null, "initmacros", queryStrings.GetValue<string>("application"));
//refresh action //refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -74,7 +75,7 @@ namespace Umbraco.Web.Trees
if (macro == null) return new MenuItemCollection(); if (macro == null) return new MenuItemCollection();
//add delete option for all macros //add delete option for all macros
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)) menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true)
//Since we haven't implemented anything for macros in angular, this needs to be converted to //Since we haven't implemented anything for macros in angular, this needs to be converted to
//use the legacy format //use the legacy format
.ConvertLegacyMenuItem(new EntitySlim .ConvertLegacyMenuItem(new EntitySlim

View File

@@ -8,10 +8,12 @@ using Umbraco.Core;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Search; using Umbraco.Web.Search;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
@@ -81,28 +83,25 @@ namespace Umbraco.Web.Trees
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
//set the default //set the default
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
// if the user's start node is not the root then the only menu item to display is refresh // if the user's start node is not the root then the only menu item to display is refresh
if (UserStartNodes.Contains(Constants.System.Root) == false) if (UserStartNodes.Contains(Constants.System.Root) == false)
{ {
menu.Items.Add<RefreshNode, ActionRefresh>( menu.Items.Add(new RefreshNode(Services.TextService, true));
Services.TextService.Localize(string.Concat("actions/", ActionRefresh.Instance.Alias)),
true);
return menu; return menu;
} }
// root actions // root actions
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionSort>(Services.TextService.Localize("actions", ActionSort.Instance.Alias), true); menu.Items.Add<ActionSort>(Services.TextService, true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
int iid; if (int.TryParse(id, out var iid) == false)
if (int.TryParse(id, out iid) == false)
{ {
throw new HttpResponseException(HttpStatusCode.NotFound); throw new HttpResponseException(HttpStatusCode.NotFound);
} }
@@ -115,29 +114,30 @@ namespace Umbraco.Web.Trees
//if the user has no path access for this node, all they can do is refresh //if the user has no path access for this node, all they can do is refresh
if (Security.CurrentUser.HasPathAccess(item, Services.EntityService, RecycleBinId) == false) if (Security.CurrentUser.HasPathAccess(item, Services.EntityService, RecycleBinId) == false)
{ {
menu.Items.Add<RefreshNode, ActionRefresh>( menu.Items.Add(new RefreshNode(Services.TextService, true));
Services.TextService.Localize(string.Concat("actions/", ActionRefresh.Instance.Alias)),
true);
return menu; return menu;
} }
//return a normal node menu: //return a normal node menu:
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionMove>(Services.TextService.Localize("actions", ActionMove.Instance.Alias)); menu.Items.Add<ActionMove>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionSort>(Services.TextService.Localize("actions", ActionSort.Instance.Alias)); menu.Items.Add<ActionSort>(Services.TextService);
menu.Items.Add<ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
//if the media item is in the recycle bin, don't have a default menu, just show the regular menu //if the media item 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())) if (item.Path.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Contains(RecycleBinId.ToInvariantString()))
{ {
menu.DefaultMenuAlias = null; menu.DefaultMenuAlias = null;
menu.Items.Insert(2, new MenuItem(ActionRestore.Instance, Services.TextService.Localize("actions", ActionRestore.Instance.Alias))); menu.Items.Insert(2, new MenuItem(ActionRestore.ActionAlias, Services.TextService)
{
OpensDialog = true
});
} }
else else
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
} }
return menu; return menu;

View File

@@ -9,8 +9,9 @@ using Umbraco.Core.Models;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Web.Search; using Umbraco.Web.Search;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -70,12 +71,11 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
// root actions // root actions
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService));
$"actions/{ActionRefresh.Instance.Alias}"));
return menu; return menu;
} }
@@ -83,9 +83,9 @@ namespace Umbraco.Web.Trees
if (container != null) if (container != null)
{ {
//set the default to create //set the default to create
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
menu.Items.Add(new MenuItem("rename", Services.TextService.Localize("actions/rename")) menu.Items.Add(new MenuItem("rename", Services.TextService.Localize("actions/rename"))
{ {
@@ -95,10 +95,9 @@ namespace Umbraco.Web.Trees
if (container.HasChildren == false) if (container.HasChildren == false)
{ {
//can delete doc type //can delete doc type
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}")); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
} }
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService, true));
$"actions/{ActionRefresh.Instance.Alias}"), hasSeparator: true);
} }
else else
{ {
@@ -107,29 +106,28 @@ namespace Umbraco.Web.Trees
if (enableInheritedMediaTypes) if (enableInheritedMediaTypes)
{ {
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
//no move action if this is a child doc type //no move action if this is a child doc type
if (parent == null) if (parent == null)
{ {
menu.Items.Add<ActionMove>(Services.TextService.Localize($"actions/{ActionMove.Instance.Alias}"), true); menu.Items.Add<ActionMove>(Services.TextService, true, opensDialog: true);
} }
} }
else else
{ {
menu.Items.Add<ActionMove>(Services.TextService.Localize($"actions/{ActionMove.Instance.Alias}")); menu.Items.Add<ActionMove>(Services.TextService, opensDialog: true);
//no move action if this is a child doc type //no move action if this is a child doc type
if (parent == null) if (parent == null)
{ {
menu.Items.Add<ActionMove>(Services.TextService.Localize($"actions/{ActionMove.Instance.Alias}"), true); menu.Items.Add<ActionMove>(Services.TextService, true, opensDialog: true);
} }
} }
menu.Items.Add<ActionCopy>(Services.TextService.Localize($"actions/{ActionCopy.Instance.Alias}")); menu.Items.Add<ActionCopy>(Services.TextService, opensDialog: true);
menu.Items.Add<ActionDelete>(Services.TextService.Localize($"actions/{ActionDelete.Instance.Alias}")); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
if (enableInheritedMediaTypes) if (enableInheritedMediaTypes)
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize( menu.Items.Add(new RefreshNode(Services.TextService, true));
$"actions/{ActionRefresh.Instance.Alias}"), true);
} }
return menu; return menu;

View File

@@ -10,10 +10,11 @@ using Umbraco.Core;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Security; using Umbraco.Core.Security;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Search; using Umbraco.Web.Search;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
@@ -155,36 +156,35 @@ namespace Umbraco.Web.Trees
if (_provider.IsUmbracoMembershipProvider()) if (_provider.IsUmbracoMembershipProvider())
{ {
//set default //set default
menu.DefaultMenuAlias = ActionNew.Instance.Alias; menu.DefaultMenuAlias = ActionNew.ActionAlias;
//Create the normal create action //Create the normal create action
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
} }
else else
{ {
//Create a custom create action - this does not launch a dialog, it just navigates to the create screen //Create a custom create action - this does not launch a dialog, it just navigates to the create screen
// we'll create it based on the ActionNew so it maintains the same icon properties, name, etc... // we'll create it based on the ActionNew so it maintains the same icon properties, name, etc...
var createMenuItem = new MenuItem(ActionNew.Instance); var createMenuItem = new MenuItem(ActionNew.ActionAlias, Services.TextService)
{
Icon = "add",
OpensDialog = true
};
//we want to go to this route: /member/member/edit/-1?create=true //we want to go to this route: /member/member/edit/-1?create=true
createMenuItem.NavigateToRoute("/member/member/edit/-1?create=true"); createMenuItem.NavigateToRoute("/member/member/edit/-1?create=true");
menu.Items.Add(createMenuItem); menu.Items.Add(createMenuItem);
} }
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
//add delete option for all members //add delete option for all members
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
if (Security.CurrentUser.HasAccessToSensitiveData()) if (Security.CurrentUser.HasAccessToSensitiveData())
{ {
menu.Items.Add(new ExportMember menu.Items.Add(new ExportMember(Services.TextService));
{
Name = Services.TextService.Localize("actions/export"),
Icon = "download-alt",
Alias = "export"
});
} }

View File

@@ -2,7 +2,8 @@
using System.Net.Http.Formatting; using System.Net.Http.Formatting;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -25,14 +26,14 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
// root actions // root actions
menu.Items.Add<CreateChildEntity, ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); menu.Items.Add(new CreateChildEntity(Services.TextService));
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
else else
{ {
//delete member type/group //delete member type/group
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
} }
return menu; return menu;

View File

@@ -8,7 +8,8 @@ using Umbraco.Web.WebApi.Filters;
using umbraco; using umbraco;
using umbraco.cms.businesslogic.packager; using umbraco.cms.businesslogic.packager;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -83,21 +84,20 @@ namespace Umbraco.Web.Trees
// Root actions // Root actions
if (id == "-1") if (id == "-1")
{ {
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")) menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true)
.ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue<string>("application")); .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue<string>("application"));
} }
else if (id == "created") else if (id == "created")
{ {
menu.Items.Add<ActionNew>(Services.TextService.Localize($"actions/{ActionNew.Instance.Alias}")) menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true)
.ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue<string>("application")); .ConvertLegacyMenuItem(null, Constants.Trees.Packages, queryStrings.GetValue<string>("application"));
menu.Items.Add<RefreshNode, ActionRefresh>( menu.Items.Add(new RefreshNode(Services.TextService, true));
Services.TextService.Localize($"actions/{ActionRefresh.Instance.Alias}"), true);
} }
else else
{ {
//it's a package node //it's a package node
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)); menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true);
} }
return menu; return menu;

View File

@@ -4,10 +4,11 @@ using System.Net.Http.Formatting;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Web.Actions;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
{ {
@@ -24,12 +25,10 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//Create the normal create action //Create the normal create action
menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)) var addMenuItem = menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
//Since we haven't implemented anything for relationtypes in angular, this needs to be converted to addMenuItem.LaunchDialogUrl("developer/RelationTypes/NewRelationType.aspx", "Create New RelationType");
//use the legacy format
.ConvertLegacyMenuItem(null, "initrelationTypes", queryStrings.GetValue<string>("application"));
//refresh action //refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -38,7 +37,7 @@ namespace Umbraco.Web.Trees
if (relationType == null) return new MenuItemCollection(); if (relationType == null) return new MenuItemCollection();
//add delete option for all macros //add delete option for all macros
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias)) menu.Items.Add<ActionDelete>(Services.TextService, opensDialog: true)
//Since we haven't implemented anything for relationtypes in angular, this needs to be converted to //Since we haven't implemented anything for relationtypes in angular, this needs to be converted to
//use the legacy format //use the legacy format
.ConvertLegacyMenuItem(new EntitySlim .ConvertLegacyMenuItem(new EntitySlim

View File

@@ -8,12 +8,13 @@ using Umbraco.Core;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.Search; using Umbraco.Web.Search;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -69,13 +70,13 @@ namespace Umbraco.Web.Trees
var menu = new MenuItemCollection(); var menu = new MenuItemCollection();
//Create the normal create action //Create the normal create action
var item = menu.Items.Add<ActionNew>(Services.TextService.Localize("actions", ActionNew.Instance.Alias)); var item = menu.Items.Add<ActionNew>(Services.TextService, opensDialog: true);
item.NavigateToRoute($"{queryStrings.GetValue<string>("application")}/templates/edit/{id}?create=true"); item.NavigateToRoute($"{queryStrings.GetValue<string>("application")}/templates/edit/{id}?create=true");
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
//refresh action //refresh action
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }
@@ -88,11 +89,11 @@ namespace Umbraco.Web.Trees
if (template.IsMasterTemplate == false) if (template.IsMasterTemplate == false)
{ {
//add delete option if it doesn't have children //add delete option if it doesn't have children
menu.Items.Add<ActionDelete>(Services.TextService.Localize("actions", ActionDelete.Instance.Alias), true); menu.Items.Add<ActionDelete>(Services.TextService, true, opensDialog: true);
} }
//add refresh //add refresh
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;

View File

@@ -3,10 +3,11 @@ using System.Linq;
using System.Net.Http.Formatting; using System.Net.Http.Formatting;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Services; using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees
@@ -43,7 +44,7 @@ namespace Umbraco.Web.Trees
if (id == Constants.System.Root.ToInvariantString()) if (id == Constants.System.Root.ToInvariantString())
{ {
// root actions // root actions
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize("actions", ActionRefresh.Instance.Alias), true); menu.Items.Add(new RefreshNode(Services.TextService, true));
return menu; return menu;
} }

View File

@@ -4,7 +4,7 @@ using Umbraco.Core.Services;
using Umbraco.Web.Models.Trees; using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc; using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi.Filters; using Umbraco.Web.WebApi.Filters;
using Umbraco.Web._Legacy.Actions;
using Constants = Umbraco.Core.Constants; using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Trees namespace Umbraco.Web.Trees

View File

@@ -5,7 +5,7 @@ using Umbraco.Web.Mvc;
using Umbraco.Web.Trees; using Umbraco.Web.Trees;
using Umbraco.Web.WebApi; using Umbraco.Web.WebApi;
using Umbraco.Core.Composing; using Umbraco.Core.Composing;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web namespace Umbraco.Web
{ {
@@ -14,15 +14,6 @@ namespace Umbraco.Web
/// </summary> /// </summary>
public static class TypeLoaderExtensions public static class TypeLoaderExtensions
{ {
/// <summary>
/// Returns all available IAction in application
/// </summary>
/// <returns></returns>
internal static IEnumerable<Type> GetActions(this TypeLoader mgr)
{
return mgr.GetTypes<IAction>();
}
/// <summary> /// <summary>
/// Returns all available TreeApiController's in application that are attribute with TreeAttribute /// Returns all available TreeApiController's in application that are attribute with TreeAttribute
/// </summary> /// </summary>
@@ -43,15 +34,5 @@ namespace Umbraco.Web
return mgr.GetTypes<UmbracoApiController>(); return mgr.GetTypes<UmbracoApiController>();
} }
/// <summary>
/// Returns all available ISearchableTrees in application
/// </summary>
/// <param name="mgr"></param>
/// <returns></returns>
internal static IEnumerable<Type> GetSearchableTrees(this TypeLoader mgr)
{
return mgr.GetTypes<ISearchableTree>();
}
} }
} }

View File

@@ -11,9 +11,10 @@ using Umbraco.Core.Exceptions;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities; using Umbraco.Core.Models.Entities;
using Umbraco.Core.Security; using Umbraco.Core.Security;
using Umbraco.Web.Actions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Security; using Umbraco.Web.Security;
using Umbraco.Web._Legacy.Actions;
namespace Umbraco.Web.UI.Pages namespace Umbraco.Web.UI.Pages
{ {

View File

@@ -427,7 +427,6 @@
<Compile Include="PublishedCache\NuCache\PublishedSnapshot.cs" /> <Compile Include="PublishedCache\NuCache\PublishedSnapshot.cs" />
<Compile Include="PublishedCache\PublishedElement.cs" /> <Compile Include="PublishedCache\PublishedElement.cs" />
<Compile Include="PublishedCache\PublishedElementPropertyBase.cs" /> <Compile Include="PublishedCache\PublishedElementPropertyBase.cs" />
<Compile Include="Models\Trees\DisableUser.cs" />
<Compile Include="PropertyEditors\ValueConverters\ContentPickerValueConverter.cs" /> <Compile Include="PropertyEditors\ValueConverters\ContentPickerValueConverter.cs" />
<Compile Include="PublishedCache\PublishedSnapshotServiceBase.cs" /> <Compile Include="PublishedCache\PublishedSnapshotServiceBase.cs" />
<Compile Include="PublishedCache\IDomainCache.cs" /> <Compile Include="PublishedCache\IDomainCache.cs" />
@@ -530,39 +529,26 @@
<Compile Include="Runtime\WebRuntimeComponent.cs" /> <Compile Include="Runtime\WebRuntimeComponent.cs" />
<Compile Include="Editors\PublishedStatusController.cs" /> <Compile Include="Editors\PublishedStatusController.cs" />
<Compile Include="Editors\NuCacheStatusController.cs" /> <Compile Include="Editors\NuCacheStatusController.cs" />
<Compile Include="_Legacy\Actions\Action.cs" /> <Compile Include="Actions\ActionAssignDomain.cs" />
<Compile Include="_Legacy\Actions\ActionAssignDomain.cs" /> <Compile Include="Actions\ActionBrowse.cs" />
<Compile Include="_Legacy\Actions\ActionBrowse.cs" /> <Compile Include="Actions\ActionChangeDocType.cs" />
<Compile Include="_Legacy\Actions\ActionChangeDocType.cs" /> <Compile Include="Actions\ActionCollection.cs" />
<Compile Include="_Legacy\Actions\ActionCollection.cs" /> <Compile Include="Actions\ActionCollectionBuilder.cs" />
<Compile Include="_Legacy\Actions\ActionCollectionBuilder.cs" /> <Compile Include="Actions\ActionCopy.cs" />
<Compile Include="_Legacy\Actions\ActionCopy.cs" /> <Compile Include="Actions\ActionCreateBlueprintFromContent.cs" />
<Compile Include="_Legacy\Actions\ActionCreateBlueprintFromContent.cs" /> <Compile Include="Actions\ActionDelete.cs" />
<Compile Include="_Legacy\Actions\ActionDelete.cs" /> <Compile Include="Actions\ActionMove.cs" />
<Compile Include="_Legacy\Actions\ActionEmptyTranscan.cs" /> <Compile Include="Actions\ActionNew.cs" />
<Compile Include="_Legacy\Actions\ActionExport.cs" /> <Compile Include="Actions\ActionProtect.cs" />
<Compile Include="_Legacy\Actions\ActionImport.cs" /> <Compile Include="Actions\ActionPublish.cs" />
<Compile Include="_Legacy\Actions\ActionMove.cs" /> <Compile Include="Actions\ActionRestore.cs" />
<Compile Include="_Legacy\Actions\ActionNew.cs" /> <Compile Include="Actions\ActionRights.cs" />
<Compile Include="_Legacy\Actions\ActionNotify.cs" /> <Compile Include="Actions\ActionRollback.cs" />
<Compile Include="_Legacy\Actions\ActionNull.cs" /> <Compile Include="Actions\ActionSort.cs" />
<Compile Include="_Legacy\Actions\ActionPackage.cs" /> <Compile Include="Actions\ActionToPublish.cs" />
<Compile Include="_Legacy\Actions\ActionPackageCreate.cs" /> <Compile Include="Actions\ActionUnpublish.cs" />
<Compile Include="_Legacy\Actions\ActionProtect.cs" /> <Compile Include="Actions\ActionUpdate.cs" />
<Compile Include="_Legacy\Actions\ActionPublish.cs" /> <Compile Include="Actions\IAction.cs" />
<Compile Include="_Legacy\Actions\ActionRefresh.cs" />
<Compile Include="_Legacy\Actions\ActionRePublish.cs" />
<Compile Include="_Legacy\Actions\ActionRestore.cs" />
<Compile Include="_Legacy\Actions\ActionRights.cs" />
<Compile Include="_Legacy\Actions\ActionRollback.cs" />
<Compile Include="_Legacy\Actions\ActionSort.cs" />
<Compile Include="_Legacy\Actions\ActionToPublish.cs" />
<Compile Include="_Legacy\Actions\ActionTranslate.cs" />
<Compile Include="_Legacy\Actions\ActionUnpublish.cs" />
<Compile Include="_Legacy\Actions\ActionUpdate.cs" />
<Compile Include="_Legacy\Actions\ContextMenuSeperator.cs" />
<Compile Include="_Legacy\Actions\IAction.cs" />
<Compile Include="_Legacy\Actions\LegacyActionMenuItemAttribute.cs" />
<Compile Include="Models\ContentEditing\EntityBasic.cs" /> <Compile Include="Models\ContentEditing\EntityBasic.cs" />
<Compile Include="Models\Trees\ApplicationAttribute.cs" /> <Compile Include="Models\Trees\ApplicationAttribute.cs" />
<Compile Include="Models\Trees\ApplicationDefinitions.cs" /> <Compile Include="Models\Trees\ApplicationDefinitions.cs" />
@@ -947,7 +933,6 @@
<Compile Include="PropertyEditors\TrueFalsePropertyEditor.cs" /> <Compile Include="PropertyEditors\TrueFalsePropertyEditor.cs" />
<Compile Include="Trees\MediaTreeController.cs" /> <Compile Include="Trees\MediaTreeController.cs" />
<Compile Include="Models\Trees\ActionMenuItem.cs" /> <Compile Include="Models\Trees\ActionMenuItem.cs" />
<Compile Include="Models\Trees\ActionMenuItemAttribute.cs" />
<Compile Include="Trees\ActionUrlMethod.cs" /> <Compile Include="Trees\ActionUrlMethod.cs" />
<Compile Include="Trees\ContentTreeControllerBase.cs" /> <Compile Include="Trees\ContentTreeControllerBase.cs" />
<Compile Include="Trees\ISearchableTree.cs" /> <Compile Include="Trees\ISearchableTree.cs" />
@@ -1263,12 +1248,6 @@
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx.designer.cs"> <Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx.designer.cs">
<DependentUpon>NewRelationType.aspx</DependentUpon> <DependentUpon>NewRelationType.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\RelationTypesWebService.asmx.cs">
<DependentUpon>RelationTypesWebService.asmx</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\TreeMenu\ActionDeleteRelationType.cs" />
<Compile Include="umbraco.presentation\umbraco\developer\RelationTypes\TreeMenu\ActionNewRelationType.cs" />
<Compile Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx.cs"> <Compile Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx.cs">
<DependentUpon>insertMasterpageContent.aspx</DependentUpon> <DependentUpon>insertMasterpageContent.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>
@@ -1372,7 +1351,6 @@
<Content Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx"> <Content Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx">
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>
</Content> </Content>
<Content Include="umbraco.presentation\umbraco\developer\RelationTypes\RelationTypesWebService.asmx" />
<Content Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx" /> <Content Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx" />
<Content Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx"> <Content Include="umbraco.presentation\umbraco\dialogs\insertMasterpageContent.aspx">
<SubType>ASPXCodeBehind</SubType> <SubType>ASPXCodeBehind</SubType>

View File

@@ -5,9 +5,10 @@ using System.Web.Http.Filters;
using Umbraco.Core.Exceptions; using Umbraco.Core.Exceptions;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Web.Editors; using Umbraco.Web.Editors;
using Umbraco.Web._Legacy.Actions;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Web.Actions;
namespace Umbraco.Web.WebApi.Filters namespace Umbraco.Web.WebApi.Filters
{ {
@@ -39,7 +40,7 @@ namespace Umbraco.Web.WebApi.Filters
{ {
if (string.IsNullOrEmpty(paramName)) throw new ArgumentNullOrEmptyException(nameof(paramName)); if (string.IsNullOrEmpty(paramName)) throw new ArgumentNullOrEmptyException(nameof(paramName));
_paramName = paramName; _paramName = paramName;
_permissionToCheck = ActionBrowse.Instance.Letter; _permissionToCheck = ActionBrowse.ActionLetter;
} }
public EnsureUserPermissionForContentAttribute(string paramName, char permissionToCheck) public EnsureUserPermissionForContentAttribute(string paramName, char permissionToCheck)

View File

@@ -8,7 +8,8 @@ using Umbraco.Core.Services;
using Umbraco.Core; using Umbraco.Core;
using Umbraco.Web.Composing; using Umbraco.Web.Composing;
using Umbraco.Core.Models; using Umbraco.Core.Models;
using Umbraco.Web._Legacy.Actions; using Umbraco.Web.Actions;
namespace Umbraco.Web.WebApi.Filters namespace Umbraco.Web.WebApi.Filters
{ {
@@ -25,7 +26,7 @@ namespace Umbraco.Web.WebApi.Filters
public FilterAllowedOutgoingContentAttribute(Type outgoingType) public FilterAllowedOutgoingContentAttribute(Type outgoingType)
: this(outgoingType, Current.Services.UserService, Current.Services.EntityService) : this(outgoingType, Current.Services.UserService, Current.Services.EntityService)
{ {
_permissionToCheck = ActionBrowse.Instance.Letter; _permissionToCheck = ActionBrowse.ActionLetter;
} }
public FilterAllowedOutgoingContentAttribute(Type outgoingType, char permissionToCheck) public FilterAllowedOutgoingContentAttribute(Type outgoingType, char permissionToCheck)
@@ -37,7 +38,7 @@ namespace Umbraco.Web.WebApi.Filters
public FilterAllowedOutgoingContentAttribute(Type outgoingType, string propertyName) public FilterAllowedOutgoingContentAttribute(Type outgoingType, string propertyName)
: this(outgoingType, propertyName, Current.Services.UserService, Current.Services.EntityService) : this(outgoingType, propertyName, Current.Services.UserService, Current.Services.EntityService)
{ {
_permissionToCheck = ActionBrowse.Instance.Letter; _permissionToCheck = ActionBrowse.ActionLetter;
} }
public FilterAllowedOutgoingContentAttribute(Type outgoingType, IUserService userService, IEntityService entityService) public FilterAllowedOutgoingContentAttribute(Type outgoingType, IUserService userService, IEntityService entityService)
@@ -45,7 +46,7 @@ namespace Umbraco.Web.WebApi.Filters
{ {
_userService = userService ?? throw new ArgumentNullException(nameof(userService)); _userService = userService ?? throw new ArgumentNullException(nameof(userService));
_entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
_permissionToCheck = ActionBrowse.Instance.Letter; _permissionToCheck = ActionBrowse.ActionLetter;
} }
public FilterAllowedOutgoingContentAttribute(Type outgoingType, char permissionToCheck, IUserService userService, IEntityService entityService) public FilterAllowedOutgoingContentAttribute(Type outgoingType, char permissionToCheck, IUserService userService, IEntityService entityService)
@@ -65,7 +66,7 @@ namespace Umbraco.Web.WebApi.Filters
_entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
_userService = userService; _userService = userService;
_entityService = entityService; _entityService = entityService;
_permissionToCheck = ActionBrowse.Instance.Letter; _permissionToCheck = ActionBrowse.ActionLetter;
} }
protected override void FilterItems(IUser user, IList items) protected override void FilterItems(IUser user, IList items)

View File

@@ -1,193 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Membership;
using Umbraco.Web.Composing;
using Umbraco.Core.Services;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// Actions and Actionhandlers are a key concept to umbraco and a developer whom wish to apply
/// businessrules whenever data is changed within umbraco, by implementing the IActionHandler
/// interface it's possible to invoke methods (foreign to umbraco) - this can be used whenever
/// there is a specific rule which needs to be applied to content.
///
/// The Action class itself has responsibility for registering actions and actionhandlers,
/// and contains methods which will be invoked whenever a change is made to ex. a document, media or member
///
/// An action/actionhandler will automatically be registered, using reflection
/// which is enabling thirdparty developers to extend the core functionality of
/// umbraco without changing the codebase.
/// </summary>
[Obsolete("Actions and ActionHandlers are obsolete and should no longer be used")]
public class Action
{
private static readonly Dictionary<string, string> ActionJs = new Dictionary<string, string>();
/// <summary>
/// Jacascript for the contextmenu
/// Suggestion: this method should be moved to the presentation layer.
/// </summary>
/// <param name="language"></param>
/// <returns>String representation</returns>
public string ReturnJavascript(string language)
{
return findActions(language);
}
/// <summary>
/// Returns a list of JavaScript file paths.
/// </summary>
/// <returns></returns>
public static List<string> GetJavaScriptFileReferences()
{
return Current.Actions
.Where(x => !string.IsNullOrWhiteSpace(x.JsSource))
.Select(x => x.JsSource).ToList();
//return ActionJsReference;
}
/// <summary>
/// Javascript menuitems - tree contextmenu
/// Umbraco console
///
/// Suggestion: this method should be moved to the presentation layer.
/// </summary>
/// <param name="language"></param>
/// <returns></returns>
private static string findActions(string language)
{
if (!ActionJs.ContainsKey(language))
{
string _actionJsList = "";
foreach (IAction action in Current.Actions)
{
// Adding try/catch so this rutine doesn't fail if one of the actions fail
// Add to language JsList
try
{
// NH: Add support for css sprites
string icon = action.Icon;
if (!string.IsNullOrEmpty(icon) && icon.StartsWith("."))
icon = icon.Substring(1, icon.Length - 1);
else
icon = "images/" + icon;
_actionJsList += string.Format(",\n\tmenuItem(\"{0}\", \"{1}\", \"{2}\", \"{3}\")",
action.Letter, icon, Current.Services.TextService.Localize("actions/"+ action.Alias, new[] { language }), action.JsFunctionName);
}
catch (Exception ex)
{
Current.Logger.Error<Action>(ex, "Error registrering action to javascript");
}
}
if (_actionJsList.Length > 0)
_actionJsList = _actionJsList.Substring(2, _actionJsList.Length - 2);
_actionJsList = "\nvar menuMethods = new Array(\n" + _actionJsList + "\n)\n";
ActionJs.Add(language, _actionJsList);
}
return ActionJs[language];
}
internal static List<IAction> FromEntityPermission(EntityPermission entityPermission)
{
List<IAction> list = new List<IAction>();
foreach (var c in entityPermission.AssignedPermissions.Where(x => x.Length == 1).Select(x => x.ToCharArray()[0]))
{
IAction action = Current.Actions.ToList().Find(
delegate (IAction a)
{
return a.Letter == c;
}
);
if (action != null)
list.Add(action);
}
return list;
}
/// <summary>
/// Returns a list of IActions that are permission assignable
/// </summary>
/// <returns></returns>
public static List<IAction> GetPermissionAssignable()
{
return Current.Actions.ToList().FindAll(x => x.CanBePermissionAssigned);
}
/// <summary>
/// Check if the current IAction is using legacy javascript methods
/// </summary>
/// <param name="action"></param>
/// <returns>false if the Iaction is incompatible with 4.5</returns>
public static bool ValidateActionJs(IAction action)
{
return !action.JsFunctionName.Contains("+");
}
/// <summary>
/// Method to convert the old modal calls to the new ones
/// </summary>
/// <param name="javascript"></param>
/// <returns></returns>
public static string ConvertLegacyJs(string javascript)
{
MatchCollection tags =
Regex.Matches(javascript, "openModal[^;]*;", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match tag in tags)
{
string[] function = tag.Value.Split(',');
if (function.Length > 0)
{
string newFunction = "UmbClientMgr.openModalWindow" + function[0].Substring(9).Replace("parent.nodeID", "UmbClientMgr.mainTree().getActionNode().nodeId").Replace("nodeID", "UmbClientMgr.mainTree().getActionNode().nodeId").Replace("parent.returnRandom()", "'" + Guid.NewGuid().ToString() + "'");
newFunction += ", " + function[1];
newFunction += ", true";
newFunction += ", " + function[2];
newFunction += ", " + function[3];
javascript = javascript.Replace(tag.Value, newFunction);
}
}
return javascript;
}
}
/// <summary>
/// This class is used to manipulate IActions that are implemented in a wrong way
/// For instance incompatible trees with 4.0 vs 4.5
/// </summary>
public class PlaceboAction : IAction
{
public char Letter { get; set; }
public bool ShowInNotifier { get; set; }
public bool CanBePermissionAssigned { get; set; }
public string Icon { get; set; }
public string Alias { get; set; }
public string JsFunctionName { get; set; }
public string JsSource { get; set; }
public bool OpensDialog { get; set; }
public PlaceboAction() { }
public PlaceboAction(IAction legacyAction)
{
Letter = legacyAction.Letter;
ShowInNotifier = legacyAction.ShowInNotifier;
CanBePermissionAssigned = legacyAction.CanBePermissionAssigned;
Icon = legacyAction.Icon;
Alias = legacyAction.Alias;
JsFunctionName = legacyAction.JsFunctionName;
JsSource = legacyAction.JsSource;
OpensDialog = legacyAction.OpensDialog;
}
}
}

View File

@@ -1,77 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when a domain is being assigned to a document
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.AdministrationCategory)]
public class ActionAssignDomain : IAction
{
public static ActionAssignDomain Instance { get; } = new ActionAssignDomain();
#region IAction Members
public char Letter
{
get
{
return 'I';
}
}
public string JsFunctionName
{
get
{
return null;
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "assignDomain";
}
}
public string Icon
{
get
{
return "home";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,67 +0,0 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is used as a security constraint that grants a user the ability to view nodes in a tree
/// that has permissions applied to it.
/// </summary>
/// <remarks>
/// This action should not be invoked. It is used as the minimum required permission to view nodes in the content tree. By
/// granting a user this permission, the user is able to see the node in the tree but not edit the document. This may be used by other trees
/// that support permissions in the future.
/// </remarks>
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionBrowse : IAction
{
//create singleton
private static readonly ActionBrowse instance = new ActionBrowse();
private ActionBrowse() { }
public static ActionBrowse Instance
{
get { return instance; }
}
#region IAction Members
public char Letter
{
get { return 'F'; }
}
public bool ShowInNotifier
{
get { return false; }
}
public bool CanBePermissionAssigned
{
get { return true; }
}
public string Icon
{
get { return ""; }
}
public string Alias
{
get { return "browse"; }
}
public string JsFunctionName
{
get { return ""; }
}
public string JsSource
{
get { return ""; }
}
public bool OpensDialog => false;
#endregion
}
}

View File

@@ -1,91 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when the document type of a piece of content is changed
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.AdministrationCategory)]
public class ActionChangeDocType : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionChangeDocType m_instance = new ActionChangeDocType();
#pragma warning restore 612,618
public static ActionChangeDocType Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return '7';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionChangeDocType()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "changeDocType";
}
}
public string Icon
{
get
{
return "axis-rotation-2";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,71 +0,0 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using LightInject;
using Umbraco.Core.Composing;
namespace Umbraco.Web._Legacy.Actions
{
internal class ActionCollectionBuilder : ICollectionBuilder<ActionCollection, IAction>
{
private static Func<IEnumerable<Type>> _producer;
// for tests only - does not register the collection
public ActionCollectionBuilder()
{ }
public ActionCollectionBuilder(IServiceContainer container)
{
var collectionLifetime = CollectionLifetime;
// register the collection - special lifetime
// the lifetime here is custom ResettablePerContainerLifetime which will manage one
// single instance of the collection (much alike PerContainerLifetime) but can be resetted
// to force a new collection to be created.
// this is needed because of the weird things we do during install, where we'd use the
// infamous DirtyBackdoorToConfiguration to reset the ActionResolver way after Resolution
// had frozen. This has been replaced by the possibility here to set the producer at any
// time - but the builder is internal - and all this will be gone eventually.
container.Register(factory => factory.GetInstance<ActionCollectionBuilder>().CreateCollection(), collectionLifetime);
}
public ActionCollection CreateCollection()
{
var actions = new List<IAction>();
foreach (var type in _producer())
{
var getter = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static);
var instance = getter == null
? Activator.CreateInstance(type) as IAction
: getter.GetValue(null, null) as IAction;
if (instance == null) continue;
actions.Add(instance);
}
return new ActionCollection(actions);
}
public void SetProducer(Func<IEnumerable<Type>> producer)
{
_producer = producer;
CollectionLifetime.Reset();
}
private ResettablePerContainerLifetime CollectionLifetime { get; } = new ResettablePerContainerLifetime();
private class ResettablePerContainerLifetime : ILifetime
{
private object _instance;
public object GetInstance(Func<object> createInstance, Scope scope)
{
// not dealing with disposable instances, actions are not disposable
return _instance ?? (_instance = createInstance());
}
public void Reset()
{
_instance = null;
}
}
}
}

View File

@@ -1,91 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when copying a document, media, member
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.StructureCategory)]
public class ActionCopy : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionCopy m_instance = new ActionCopy();
#pragma warning restore 612,618
public static ActionCopy Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'O';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionCopy()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "copy";
}
}
public string Icon
{
get
{
return "documents";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,33 +0,0 @@
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionCreateBlueprintFromContent : IAction
{
private static readonly ActionCreateBlueprintFromContent instance = new ActionCreateBlueprintFromContent();
public static ActionCreateBlueprintFromContent Instance
{
get { return instance; }
}
public char Letter { get; private set; }
public bool ShowInNotifier { get; private set; }
public bool CanBePermissionAssigned { get; private set; }
public string Icon { get; private set; }
public string Alias { get; private set; }
public string JsFunctionName { get; private set; }
public string JsSource { get; private set; }
public bool OpensDialog => true;
public ActionCreateBlueprintFromContent()
{
Letter = 'ï';
CanBePermissionAssigned = true;
Icon = "blueprint";
Alias = "createblueprint";
}
}
}

View File

@@ -1,85 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when a document, media, member is deleted
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionDelete : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionDelete m_instance = new ActionDelete();
#pragma warning restore 612,618
public static ActionDelete Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'D';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionDelete()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "delete";
}
}
public string Icon
{
get
{
return "delete";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,80 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when the trash can is emptied
/// </summary>
public class ActionEmptyTranscan : IAction
{
//create singleton
private static readonly ActionEmptyTranscan InnerInstance = new ActionEmptyTranscan();
public static ActionEmptyTranscan Instance
{
get { return InnerInstance; }
}
#region IAction Members
public char Letter
{
get
{
return 'N';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionEmptyTranscan()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "emptyRecycleBin";
}
}
public string Icon
{
get
{
return "trash";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,78 +0,0 @@
using System;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when exporting a document type
/// </summary>
public class ActionExport : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionExport m_instance = new ActionExport();
#pragma warning restore 612,618
public static ActionExport Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return '9';
}
}
public string JsFunctionName
{
get { return ""; }
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "export";
}
}
public string Icon
{
get
{
return "download-alt";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,79 +0,0 @@
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when importing a document type
/// </summary>
public class ActionImport : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionImport m_instance = new ActionImport();
#pragma warning restore 612,618
public static ActionImport Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return '8';
}
}
public string JsFunctionName
{
get
{
return "";
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "importDocumentType";
}
}
public string Icon
{
get
{
return "page-up";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,91 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked upon creation of a document, media, member
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.StructureCategory)]
public class ActionMove : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionMove m_instance = new ActionMove();
#pragma warning restore 612,618
public static ActionMove Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'M';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionMove()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "move";
}
}
public string Icon
{
get
{
return "enter";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,77 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked upon creation of a document
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionNew : IAction
{
public static ActionNew Instance { get; } = new ActionNew();
#region IAction Members
public char Letter
{
get
{
return 'C';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionNew()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "create";
}
}
public string Icon
{
get
{
return "add";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,84 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when a notification is sent
/// </summary>
public class ActionNotify : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionNotify m_instance = new ActionNotify();
#pragma warning restore 612,618
public static ActionNotify Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'T';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionNotify()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "notify";
}
}
public string Icon
{
get
{
return "megaphone";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,58 +0,0 @@
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This permission is assigned to a node when there are no permissions assigned to the node.
/// This is used internally to assign no permissions to a node for a user and shouldn't be used in code.
/// </summary>
public class ActionNull : IAction
{
//create singleton
private static readonly ActionNull instance = new ActionNull();
private ActionNull() { }
public static ActionNull Instance
{
get { return instance; }
}
#region IAction Members
public char Letter
{
get { return '-'; }
}
public bool ShowInNotifier
{
get { return false; }
}
public bool CanBePermissionAssigned
{
get { return false; }
}
public string Icon
{
get { return string.Empty; }
}
public string Alias
{
get { return string.Empty; }
}
public string JsFunctionName
{
get { return string.Empty; }
}
public string JsSource
{
get { return string.Empty; }
}
public bool OpensDialog => false;
#endregion
}
}

View File

@@ -1,82 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked upon creation of a document, media, member
/// </summary>
public class ActionPackage : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionPackage m_instance = new ActionPackage();
#pragma warning restore 612,618
public static ActionPackage Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'X';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionPackage()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return "";
}
}
public string Alias
{
get
{
return "importPackage";
}
}
public string Icon
{
get
{
return "gift";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => false;
#endregion
}
}

View File

@@ -1,82 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked upon creation of a document, media, member
/// </summary>
public class ActionPackageCreate : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionPackageCreate m_instance = new ActionPackageCreate();
#pragma warning restore 612,618
public static ActionPackageCreate Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'Y';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionPackageCreate()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "createPackage";
}
}
public string Icon
{
get
{
return "gift";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,91 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when a document is protected or unprotected
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.AdministrationCategory)]
public class ActionProtect : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionProtect m_instance = new ActionProtect();
#pragma warning restore 612,618
public static ActionProtect Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'P';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionProtect()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "protect";
}
}
public string Icon
{
get
{
return "lock";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,85 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when a document is being published
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionPublish : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionPublish m_instance = new ActionPublish();
#pragma warning restore 612,618
public static ActionPublish Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'U';
}
}
public string JsFunctionName
{
get
{
return string.Empty;
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "publish";
}
}
public string Icon
{
get
{
return string.Empty;
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,82 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when all documents are being republished
/// </summary>
public class ActionRePublish : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionRePublish m_instance = new ActionRePublish();
#pragma warning restore 612,618
public static ActionRePublish Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'B';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionRePublish()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "republish";
}
}
public string Icon
{
get
{
return "globe";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,89 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
namespace Umbraco.Web._Legacy.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>
[LegacyActionMenuItem("umbracoMenuActions", "RefreshNode")]
public class ActionRefresh : IAction
{
//create singleton
private static readonly ActionRefresh InnerInstance = new ActionRefresh();
public static ActionRefresh Instance
{
get { return InnerInstance; }
}
#region IAction Members
public char Letter
{
get
{
return 'L';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionRefresh()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "refreshNode";
}
}
public string Icon
{
get
{
return "refresh";
}
}
public bool ShowInNotifier
{
get
{
return false;
}
}
public bool CanBePermissionAssigned
{
get
{
return false;
}
}
public bool OpensDialog => false;
#endregion
}
}

View File

@@ -1,34 +0,0 @@
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when the content/media item is to be restored from the recycle bin
/// </summary>
public class ActionRestore : IAction
{
//create singleton
private ActionRestore() { }
public static ActionRestore Instance { get; } = new ActionRestore();
#region IAction Members
public char Letter => 'V';
public string JsFunctionName => null;
public string JsSource => null;
public string Alias => "restore";
public string Icon => "undo";
public bool ShowInNotifier => true;
public bool CanBePermissionAssigned => false;
public bool OpensDialog => true;
#endregion
}
}

View File

@@ -1,91 +0,0 @@
using System;
using Umbraco.Web.UI.Pages;
using Umbraco.Core;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Web._Legacy.Actions
{
/// <summary>
/// This action is invoked when rights are changed on a document
/// </summary>
[ActionMetadata(Constants.Conventions.PermissionCategories.ContentCategory)]
public class ActionRights : IAction
{
//create singleton
#pragma warning disable 612,618
private static readonly ActionRights m_instance = new ActionRights();
#pragma warning restore 612,618
public static ActionRights Instance
{
get { return m_instance; }
}
#region IAction Members
public char Letter
{
get
{
return 'R';
}
}
public string JsFunctionName
{
get
{
return string.Format("{0}.actionRights()", ClientTools.Scripts.GetAppActions);
}
}
public string JsSource
{
get
{
return null;
}
}
public string Alias
{
get
{
return "rights";
}
}
public string Icon
{
get
{
return "vcard";
}
}
public bool ShowInNotifier
{
get
{
return true;
}
}
public bool CanBePermissionAssigned
{
get
{
return true;
}
}
public bool OpensDialog => true;
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More