diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index 51d437b9cb..71e7afec12 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -190,20 +190,6 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); var actions = { openDashboard : function(section){ navService.changeSection(section); - }, - actionDisable: function () { - localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) { - var currentMenuNode = UmbClientMgr.mainTree().getActionNode(); - if (currentMenuNode) { - if (confirm(txtConfirmDisable + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) { - angularHelper.safeApply($rootScope, function () { - userResource.disableUser(currentMenuNode.nodeId).then(function () { - UmbClientMgr.mainTree().syncTree("-1," + currentMenuNode.nodeId, true); - }); - }); - } - } - }); } }; diff --git a/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js b/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js index bcfb5df0a7..c7438a1c47 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/menuactions.service.js @@ -8,10 +8,21 @@ * @description * Defines the methods that are called when menu items declare only an action to execute */ -function umbracoMenuActions($q, treeService, $location, navigationService, appState) { +function umbracoMenuActions($q, treeService, $location, navigationService, appState, localizationService, userResource) { return { + "DisableUser": function(args) { + localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) { + var currentMenuNode = UmbClientMgr.mainTree().getActionNode(); + if (confirm(txtConfirmDisable + ' "' + args.entity.name + '"?\n\n')) { + userResource.disableUser(args.entity.id).then(function () { + navigationService.syncTree({ tree: args.treeAlias, path: [args.entity.parentId, args.entity.id], forceReload: true }); + }); + } + }); + }, + /** * @ngdoc method * @name umbraco.services.umbracoMenuActions#RefreshNode diff --git a/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js b/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js index 46b7a15e48..e40e59e792 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js +++ b/src/Umbraco.Web.UI/umbraco_client/Application/UmbracoApplicationActions.js @@ -415,18 +415,6 @@ Umbraco.Application.Actions = function() { }, - actionDisable: function() { - /// - /// Used for users when disable is selected. - /// - - if (confirm(uiKeys['defaultdialogs_confirmdisable'] + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) { - umbraco.presentation.webservices.legacyAjaxCalls.DisableUser(UmbClientMgr.mainTree().getActionNode().nodeId, function() { - UmbClientMgr.mainTree().reloadActionNode(); - }); - } - }, - actionMove: function() { /// diff --git a/src/Umbraco.Web/Models/Trees/DisableUser.cs b/src/Umbraco.Web/Models/Trees/DisableUser.cs new file mode 100644 index 0000000000..b28b2043ab --- /dev/null +++ b/src/Umbraco.Web/Models/Trees/DisableUser.cs @@ -0,0 +1,15 @@ +namespace Umbraco.Web.Models.Trees +{ + /// + /// Represents the disable user menu item + /// + [ActionMenuItem("umbracoMenuActions")] + public sealed class DisableUser : ActionMenuItem + { + public DisableUser() + { + Alias = "disable"; + Icon = "remove"; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/Trees/UsersTreeController.cs b/src/Umbraco.Web/Trees/UsersTreeController.cs index 2cd2ec562f..1ac0f25e27 100644 --- a/src/Umbraco.Web/Trees/UsersTreeController.cs +++ b/src/Umbraco.Web/Trees/UsersTreeController.cs @@ -87,16 +87,11 @@ namespace Umbraco.Web.Trees if (id == "0") return menu; - // Disable user - menu.Items.Add( - Services.TextService.Localize("actions", ActionDisable.Instance.Alias), - false, - new Dictionary - { - {MenuItem.JsActionKey, ActionDisable.Instance.JsFunctionName} - } - ); - + menu.Items.Add(new DisableUser() + { + Name = Services.TextService.Localize("actions", "disable") + }); + return menu; } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index cc7bc3082b..5ae1a5ec51 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -326,6 +326,7 @@ + @@ -340,7 +341,6 @@ - diff --git a/src/Umbraco.Web/_Legacy/Actions/ActionDisable.cs b/src/Umbraco.Web/_Legacy/Actions/ActionDisable.cs deleted file mode 100644 index 0e72694fe2..0000000000 --- a/src/Umbraco.Web/_Legacy/Actions/ActionDisable.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using Umbraco.Web.UI.Pages; - -namespace Umbraco.Web._Legacy.Actions -{ - /// - /// This action is invoked when a document is disabled. - /// - public class ActionDisable : IAction - { - //create singleton -#pragma warning disable 612,618 - private static readonly ActionDisable m_instance = new ActionDisable(); -#pragma warning restore 612,618 - - /// - /// A public constructor exists ONLY for backwards compatibility in regards to 3rd party add-ons. - /// All Umbraco assemblies should use the singleton instantiation (this.Instance) - /// When this applicatio is refactored, this constuctor should be made private. - /// - [Obsolete("Use the singleton instantiation instead of a constructor")] - public ActionDisable() { } - - public static ActionDisable Instance - { - get { return m_instance; } - } - - #region IAction Members - - public char Letter - { - get - { - return 'E'; - } - } - - public string JsFunctionName - { - get - { - return string.Format("{0}.actionDisable()", ClientTools.Scripts.GetAppActions); - } - } - - public string JsSource - { - get - { - return null; - } - } - - public string Alias - { - get - { - - return "disable"; - } - } - - public string Icon - { - get - { - - return "remove"; - } - } - - public bool ShowInNotifier - { - get - { - - return false; - } - } - public bool CanBePermissionAssigned - { - get - { - - return false; - } - } - #endregion - } -}