From d051f850eb3be5c0bbbd5d2fab2cd35c5b6aae1c Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 16 May 2022 23:50:19 +0200 Subject: [PATCH] Support SVG icon in action menu (#12403) * Support custom SVG icon in menu item with legacy support * Update menu icons * Update action icons * Adjust icons in menu actions with legacy fallback * Don't use legacy icon * Update comments --- .../Actions/ActionAssignDomain.cs | 2 +- src/Umbraco.Core/Actions/ActionCopy.cs | 4 +- .../ActionCreateBlueprintFromContent.cs | 4 +- src/Umbraco.Core/Actions/ActionDelete.cs | 4 +- src/Umbraco.Core/Actions/ActionMove.cs | 4 +- src/Umbraco.Core/Actions/ActionNew.cs | 4 +- src/Umbraco.Core/Actions/ActionNotify.cs | 4 +- src/Umbraco.Core/Actions/ActionProtect.cs | 4 +- src/Umbraco.Core/Actions/ActionRestore.cs | 4 +- src/Umbraco.Core/Actions/ActionRights.cs | 4 +- src/Umbraco.Core/Actions/ActionRollback.cs | 4 +- src/Umbraco.Core/Actions/ActionSort.cs | 4 +- src/Umbraco.Core/Actions/ActionToPublish.cs | 4 +- src/Umbraco.Core/Actions/ActionUnpublish.cs | 4 +- src/Umbraco.Core/Actions/ActionUpdate.cs | 4 +- .../Models/Trees/CreateChildEntity.cs | 13 ++++-- src/Umbraco.Core/Models/Trees/ExportMember.cs | 5 ++- src/Umbraco.Core/Models/Trees/MenuItem.cs | 23 ++++++---- src/Umbraco.Core/Models/Trees/RefreshNode.cs | 12 ++++-- src/Umbraco.Core/Trees/MenuItemList.cs | 10 +++-- .../Trees/ContentBlueprintTreeController.cs | 6 +-- .../Trees/ContentTreeController.cs | 37 ++++++++-------- .../Trees/ContentTreeControllerBase.cs | 7 +++- .../Trees/ContentTypeTreeController.cs | 41 ++++++++++-------- .../Trees/DataTypeTreeController.cs | 20 +++++---- .../Trees/DictionaryTreeController.cs | 7 ++-- .../Trees/FileSystemTreeController.cs | 42 ++++++++++++------- .../Trees/MacrosTreeController.cs | 10 ++--- .../Trees/MediaTreeController.cs | 30 ++++++------- .../Trees/MediaTypeTreeController.cs | 19 +++++---- .../Trees/MemberGroupTreeController.cs | 1 - .../Trees/MemberTreeController.cs | 18 ++++---- .../MemberTypeAndGroupTreeControllerBase.cs | 4 +- .../Trees/RelationTypeTreeController.cs | 11 +++-- .../Trees/TemplatesTreeController.cs | 15 ++++--- .../application/umbcontextmenu.directive.js | 21 ++++++---- .../editor/umbeditormenu.directive.js | 14 ++++--- .../application/umb-contextmenu.html | 2 +- .../components/editor/umb-editor-menu.html | 7 ++-- 39 files changed, 244 insertions(+), 189 deletions(-) diff --git a/src/Umbraco.Core/Actions/ActionAssignDomain.cs b/src/Umbraco.Core/Actions/ActionAssignDomain.cs index 0638f605af..b975cf65af 100644 --- a/src/Umbraco.Core/Actions/ActionAssignDomain.cs +++ b/src/Umbraco.Core/Actions/ActionAssignDomain.cs @@ -23,7 +23,7 @@ public class ActionAssignDomain : IAction public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory; /// - public string Icon => "home"; + public string Icon => "icon-home"; /// public bool ShowInNotifier => false; diff --git a/src/Umbraco.Core/Actions/ActionCopy.cs b/src/Umbraco.Core/Actions/ActionCopy.cs index 83a855d1ff..f097388214 100644 --- a/src/Umbraco.Core/Actions/ActionCopy.cs +++ b/src/Umbraco.Core/Actions/ActionCopy.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.StructureCategory; /// - public string Icon => "documents"; + public string Icon => "icon-documents"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs b/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs index 806868af40..a3b827141e 100644 --- a/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs +++ b/src/Umbraco.Core/Actions/ActionCreateBlueprintFromContent.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -18,7 +18,7 @@ namespace Umbraco.Cms.Core.Actions public bool CanBePermissionAssigned => true; /// - public string Icon => "blueprint"; + public string Icon => Constants.Icons.Blueprint; /// public string Alias => "createblueprint"; diff --git a/src/Umbraco.Core/Actions/ActionDelete.cs b/src/Umbraco.Core/Actions/ActionDelete.cs index b31a8b9c45..88e79d472a 100644 --- a/src/Umbraco.Core/Actions/ActionDelete.cs +++ b/src/Umbraco.Core/Actions/ActionDelete.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -28,7 +28,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.ContentCategory; /// - public string Icon => "delete"; + public string Icon => "icon-delete"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionMove.cs b/src/Umbraco.Core/Actions/ActionMove.cs index 0f8b4b8305..404cfa7d36 100644 --- a/src/Umbraco.Core/Actions/ActionMove.cs +++ b/src/Umbraco.Core/Actions/ActionMove.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.StructureCategory; /// - public string Icon => "enter"; + public string Icon => "icon-enter"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionNew.cs b/src/Umbraco.Core/Actions/ActionNew.cs index 25e85cd377..6a3412c9cc 100644 --- a/src/Umbraco.Core/Actions/ActionNew.cs +++ b/src/Umbraco.Core/Actions/ActionNew.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -25,7 +25,7 @@ namespace Umbraco.Cms.Core.Actions public string Alias => ActionAlias; /// - public string Icon => "add"; + public string Icon => "icon-add"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionNotify.cs b/src/Umbraco.Core/Actions/ActionNotify.cs index 3f1e855cff..4ec2f17138 100644 --- a/src/Umbraco.Core/Actions/ActionNotify.cs +++ b/src/Umbraco.Core/Actions/ActionNotify.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -18,7 +18,7 @@ namespace Umbraco.Cms.Core.Actions public bool CanBePermissionAssigned => true; /// - public string Icon => "megaphone"; + public string Icon => "icon-megaphone"; /// public string Alias => "notify"; diff --git a/src/Umbraco.Core/Actions/ActionProtect.cs b/src/Umbraco.Core/Actions/ActionProtect.cs index 10684a69e2..d6e3e798ff 100644 --- a/src/Umbraco.Core/Actions/ActionProtect.cs +++ b/src/Umbraco.Core/Actions/ActionProtect.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory; /// - public string Icon => "lock"; + public string Icon => "icon-lock"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionRestore.cs b/src/Umbraco.Core/Actions/ActionRestore.cs index 164c93e2d5..a58d244401 100644 --- a/src/Umbraco.Core/Actions/ActionRestore.cs +++ b/src/Umbraco.Core/Actions/ActionRestore.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string? Category => null; /// - public string Icon => "undo"; + public string Icon => "icon-undo"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionRights.cs b/src/Umbraco.Core/Actions/ActionRights.cs index fff7cc8652..a186abfa06 100644 --- a/src/Umbraco.Core/Actions/ActionRights.cs +++ b/src/Umbraco.Core/Actions/ActionRights.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.ContentCategory; /// - public string Icon => "vcard"; + public string Icon => "icon-vcard"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionRollback.cs b/src/Umbraco.Core/Actions/ActionRollback.cs index 565a8469c5..46498e419e 100644 --- a/src/Umbraco.Core/Actions/ActionRollback.cs +++ b/src/Umbraco.Core/Actions/ActionRollback.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.AdministrationCategory; /// - public string Icon => "undo"; + public string Icon => "icon-undo"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionSort.cs b/src/Umbraco.Core/Actions/ActionSort.cs index 1f87bfcc3c..3a46281a46 100644 --- a/src/Umbraco.Core/Actions/ActionSort.cs +++ b/src/Umbraco.Core/Actions/ActionSort.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.StructureCategory; /// - public string Icon => "navigation-vertical"; + public string Icon => "icon-navigation-vertical"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionToPublish.cs b/src/Umbraco.Core/Actions/ActionToPublish.cs index 654b71661d..f2627edbc3 100644 --- a/src/Umbraco.Core/Actions/ActionToPublish.cs +++ b/src/Umbraco.Core/Actions/ActionToPublish.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.ContentCategory; /// - public string Icon => "outbox"; + public string Icon => "icon-outbox"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Actions/ActionUnpublish.cs b/src/Umbraco.Core/Actions/ActionUnpublish.cs index 6e9ec8506b..c79e1b934a 100644 --- a/src/Umbraco.Core/Actions/ActionUnpublish.cs +++ b/src/Umbraco.Core/Actions/ActionUnpublish.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.ContentCategory; /// - public string Icon => "circle-dotted"; + public string Icon => "icon-circle-dotted"; /// public bool ShowInNotifier => false; diff --git a/src/Umbraco.Core/Actions/ActionUpdate.cs b/src/Umbraco.Core/Actions/ActionUpdate.cs index 3f8092c1fc..18b35d805e 100644 --- a/src/Umbraco.Core/Actions/ActionUpdate.cs +++ b/src/Umbraco.Core/Actions/ActionUpdate.cs @@ -1,4 +1,4 @@ -// Copyright (c) Umbraco. +// Copyright (c) Umbraco. // See LICENSE for more details. namespace Umbraco.Cms.Core.Actions @@ -23,7 +23,7 @@ namespace Umbraco.Cms.Core.Actions public string Category => Constants.Conventions.PermissionCategories.ContentCategory; /// - public string Icon => "save"; + public string Icon => "icon-save"; /// public bool ShowInNotifier => true; diff --git a/src/Umbraco.Core/Models/Trees/CreateChildEntity.cs b/src/Umbraco.Core/Models/Trees/CreateChildEntity.cs index a8d945242e..e0b695dded 100644 --- a/src/Umbraco.Core/Models/Trees/CreateChildEntity.cs +++ b/src/Umbraco.Core/Models/Trees/CreateChildEntity.cs @@ -1,27 +1,32 @@ -using Umbraco.Cms.Core.Actions; +using Umbraco.Cms.Core.Actions; using Umbraco.Cms.Core.Services; namespace Umbraco.Cms.Core.Models.Trees { /// - /// Represents the refresh node menu item + /// Represents the refresh node menu item. /// public sealed class CreateChildEntity : ActionMenuItem { + private const string icon = "icon-add"; + public override string AngularServiceName => "umbracoMenuActions"; public CreateChildEntity(string name, bool separatorBefore = false) : base(ActionNew.ActionAlias, name) { - Icon = "add"; Name = name; + Icon = icon; + Name = name; SeparatorBefore = separatorBefore; + UseLegacyIcon = false; } public CreateChildEntity(ILocalizedTextService textService, bool separatorBefore = false) : base(ActionNew.ActionAlias, textService) { - Icon = "add"; + Icon = icon; SeparatorBefore = separatorBefore; + UseLegacyIcon = false; } } } diff --git a/src/Umbraco.Core/Models/Trees/ExportMember.cs b/src/Umbraco.Core/Models/Trees/ExportMember.cs index 30f904f952..cbaa95498b 100644 --- a/src/Umbraco.Core/Models/Trees/ExportMember.cs +++ b/src/Umbraco.Core/Models/Trees/ExportMember.cs @@ -1,9 +1,9 @@ -using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Services; namespace Umbraco.Cms.Core.Models.Trees { /// - /// Represents the export member menu item + /// Represents the export member menu item. /// public sealed class ExportMember : ActionMenuItem { @@ -12,6 +12,7 @@ namespace Umbraco.Cms.Core.Models.Trees public ExportMember(ILocalizedTextService textService) : base("export", textService) { Icon = "download-alt"; + UseLegacyIcon = false; } } } diff --git a/src/Umbraco.Core/Models/Trees/MenuItem.cs b/src/Umbraco.Core/Models/Trees/MenuItem.cs index e56a2440a8..f6c3b6b4ac 100644 --- a/src/Umbraco.Core/Models/Trees/MenuItem.cs +++ b/src/Umbraco.Core/Models/Trees/MenuItem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using System.Threading; @@ -10,7 +10,7 @@ using Umbraco.Extensions; namespace Umbraco.Cms.Core.Models.Trees { /// - /// A context menu item + /// A context menu item. /// [DataContract(Name = "menuItem", Namespace = "")] public class MenuItem @@ -19,7 +19,7 @@ namespace Umbraco.Cms.Core.Models.Trees public MenuItem() { AdditionalData = new Dictionary(); - Icon = "folder"; + Icon = Constants.Icons.Folder; } public MenuItem(string alias, string name) @@ -38,7 +38,7 @@ namespace Umbraco.Cms.Core.Models.Trees } /// - /// Create a menu item based on an definition + /// Create a menu item based on an definition. /// /// /// @@ -80,16 +80,25 @@ namespace Umbraco.Cms.Core.Models.Trees public string? TextDescription { get; set; } /// - /// Ensures a menu separator will exist before this menu item + /// Ensures a menu separator will exist before this menu item. /// [DataMember(Name = "separator")] public bool SeparatorBefore { get; set; } - [DataMember(Name = "cssclass")] + /// + /// Icon to use at action menu item. + /// + [DataMember(Name = "icon")] public string Icon { get; set; } + /// Used in the UI to indicate whether icons should be prefixed with "icon-". + /// If not legacy icon full icon name should be specified. + /// + [DataMember(Name = "useLegacyIcon")] + public bool UseLegacyIcon { get; set; } = true; + /// - /// Used in the UI to inform the user that the menu item will open a dialog/confirmation + /// Used in the UI to inform the user that the menu item will open a dialog/confirmation. /// [DataMember(Name = "opensDialog")] public bool OpensDialog { get; set; } diff --git a/src/Umbraco.Core/Models/Trees/RefreshNode.cs b/src/Umbraco.Core/Models/Trees/RefreshNode.cs index 01eb2fa34a..207ec4f6ed 100644 --- a/src/Umbraco.Core/Models/Trees/RefreshNode.cs +++ b/src/Umbraco.Core/Models/Trees/RefreshNode.cs @@ -1,27 +1,31 @@ -using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Services; namespace Umbraco.Cms.Core.Models.Trees { /// /// - /// Represents the refresh node menu item + /// Represents the refresh node menu item. /// public sealed class RefreshNode : ActionMenuItem { + private const string icon = "icon-refresh"; + public override string AngularServiceName => "umbracoMenuActions"; public RefreshNode(string name, bool separatorBefore = false) : base("refreshNode", name) { - Icon = "refresh"; + Icon = icon; SeparatorBefore = separatorBefore; + UseLegacyIcon = false; } public RefreshNode(ILocalizedTextService textService, bool separatorBefore = false) : base("refreshNode", textService) { - Icon = "refresh"; + Icon = icon; SeparatorBefore = separatorBefore; + UseLegacyIcon = false; } } } diff --git a/src/Umbraco.Core/Trees/MenuItemList.cs b/src/Umbraco.Core/Trees/MenuItemList.cs index b3fe420602..65a1535f89 100644 --- a/src/Umbraco.Core/Trees/MenuItemList.cs +++ b/src/Umbraco.Core/Trees/MenuItemList.cs @@ -38,10 +38,11 @@ namespace Umbraco.Cms.Core.Trees /// /// The used to localize the action name based on its alias /// Whether or not this action opens a dialog - public MenuItem? Add(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false) + /// Whether or not this action should use legacy icon prefixed with "icon-" or full icon name is specified. + public MenuItem? Add(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false, bool useLegacyIcon = true) where T : IAction { - var item = CreateMenuItem(textService, hasSeparator, opensDialog); + var item = CreateMenuItem(textService, hasSeparator, opensDialog, useLegacyIcon); if (item != null) { Add(item); @@ -50,7 +51,7 @@ namespace Umbraco.Cms.Core.Trees return null; } - private MenuItem? CreateMenuItem(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false) + private MenuItem? CreateMenuItem(ILocalizedTextService textService, bool hasSeparator = false, bool opensDialog = false, bool useLegacyIcon = true) where T : IAction { var item = _actionCollection.GetAction(); @@ -59,11 +60,12 @@ namespace Umbraco.Cms.Core.Trees var values = textService.GetAllStoredValues(Thread.CurrentThread.CurrentUICulture); values.TryGetValue($"visuallyHiddenTexts/{item.Alias}Description", out var textDescription); - var menuItem = new MenuItem(item, textService.Localize($"actions", item.Alias)) + var menuItem = new MenuItem(item, textService.Localize("actions", item.Alias)) { SeparatorBefore = hasSeparator, OpensDialog = opensDialog, TextDescription = textDescription, + UseLegacyIcon = useLegacyIcon, }; return menuItem; diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentBlueprintTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/ContentBlueprintTreeController.cs index 15f5839f30..02229e1348 100644 --- a/src/Umbraco.Web.BackOffice/Trees/ContentBlueprintTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/ContentBlueprintTreeController.cs @@ -135,7 +135,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { // root actions - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; } @@ -145,7 +145,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (cte != null) { var ct = _contentTypeService.Get(cte.Id); - var createItem = menu.Items.Add(LocalizedTextService, opensDialog: true); + var createItem = menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); createItem?.NavigateToRoute("/settings/contentBlueprints/edit/-1?create=true&doctype=" + ct?.Alias); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); @@ -153,7 +153,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees return menu; } - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); return menu; } diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs index 13e8a40e39..4b61ef2e17 100644 --- a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs @@ -169,8 +169,8 @@ namespace Umbraco.Cms.Web.BackOffice.Trees .Select(x => new MenuItem(x)); //these two are the standard items - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); //filter the standard items FilterUserAllowedMenuItems(menu, nodeActions); @@ -271,23 +271,24 @@ namespace Umbraco.Cms.Web.BackOffice.Trees protected MenuItemCollection GetAllNodeMenuItems(IUmbracoEntity item) { var menu = _menuItemCollectionFactory.Create(); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, true, opensDialog: true); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, true, opensDialog: true); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, opensDialog: true); - AddActionNode(item, menu, true, opensDialog: true); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, true, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, true, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, opensDialog: true, useLegacyIcon: false); + AddActionNode(item, menu, true, opensDialog: true, useLegacyIcon: false); if (_emailSender.CanSendRequiredEmail()) { menu.Items.Add(new MenuItem("notify", LocalizedTextService) { - Icon = "megaphone", + Icon = "icon-megaphone", SeparatorBefore = true, - OpensDialog = true + OpensDialog = true, + UseLegacyIcon = false, }); } @@ -307,9 +308,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees protected MenuItemCollection GetNodeMenuItemsForDeletedContent(IUmbracoEntity item) { var menu = _menuItemCollectionFactory.Create(); - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); @@ -361,10 +362,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } } - private void AddActionNode(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool opensDialog = false) + private void AddActionNode(IUmbracoEntity item, MenuItemCollection menu, bool hasSeparator = false, bool opensDialog = false, bool useLegacyIcon = true) where TAction : IAction { - var menuItem = menu.Items.Add(LocalizedTextService, hasSeparator, opensDialog); + var menuItem = menu.Items.Add(LocalizedTextService, hasSeparator, opensDialog, useLegacyIcon); } public async Task SearchAsync(string query, int pageSize, long pageIndex, string? searchFrom = null) diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs b/src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs index f0e62f8a66..3dd11e01dd 100644 --- a/src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs +++ b/src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs @@ -471,14 +471,17 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } var menu = MenuItemCollectionFactory.Create(); + // only add empty recycle bin if the current user is allowed to delete by default if (deleteAllowed) { menu.Items.Add(new MenuItem("emptyrecyclebin", LocalizedTextService) { - Icon = "trash", - OpensDialog = true + Icon = "icon-trash", + OpensDialog = true, + UseLegacyIcon = false, }); + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentTypeTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/ContentTypeTreeController.cs index aea6d8ab42..7aa0e54500 100644 --- a/src/Umbraco.Web.BackOffice/Trees/ContentTypeTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/ContentTypeTreeController.cs @@ -119,17 +119,19 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; // root actions - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new MenuItem("importdocumenttype", LocalizedTextService) { - Icon = "page-up", + Icon = "icon-page-up", SeparatorBefore = true, - OpensDialog = true + OpensDialog = true, + UseLegacyIcon = false, }); + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -138,21 +140,23 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var container = _entityService.Get(int.Parse(id, CultureInfo.InvariantCulture), UmbracoObjectTypes.DocumentTypeContainer); if (container != null) { - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new MenuItem("rename", LocalizedTextService) { - Icon = "icon icon-edit" + Icon = "icon-edit", + UseLegacyIcon = false, }); if (container.HasChildren == false) { - //can delete doc type - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + // can delete doc type + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } else @@ -160,22 +164,25 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var ct = _contentTypeService.Get(int.Parse(id, CultureInfo.InvariantCulture)); var parent = ct == null ? null : _contentTypeService.Get(ct.ParentId); - menu.Items.Add(LocalizedTextService, opensDialog: true); - //no move action if this is a child doc type + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + + // no move action if this is a child doc type if (parent == null) { - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } - menu.Items.Add(LocalizedTextService, opensDialog: true); + + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new MenuItem("export", LocalizedTextService) { - Icon = "download-alt", + Icon = "icon-download-alt", SeparatorBefore = true, - OpensDialog = true + OpensDialog = true, + UseLegacyIcon = false, }); - menu.Items.Add(LocalizedTextService, true, opensDialog: true); - menu.Items.Add(new RefreshNode(LocalizedTextService, true)); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs index 574540e428..d3ad102c5a 100644 --- a/src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs @@ -133,7 +133,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees menu.DefaultMenuAlias = ActionNew.ActionAlias; // root actions - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; } @@ -141,21 +141,23 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var container = _entityService.Get(int.Parse(id, CultureInfo.InvariantCulture), UmbracoObjectTypes.DataTypeContainer); if (container != null) { - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new MenuItem("rename", LocalizedTextService.Localize("actions", "rename")) { - Icon = "icon icon-edit" + Icon = "icon-edit", + UseLegacyIcon = false, }); if (container.HasChildren == false) { - //can delete data type - menu.Items.Add(LocalizedTextService, opensDialog: true); + // can delete data type + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); } + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } else @@ -163,9 +165,11 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var nonDeletableSystemDataTypeIds = GetNonDeletableSystemDataTypeIds(); if (nonDeletableSystemDataTypeIds.Contains(int.Parse(id, CultureInfo.InvariantCulture)) == false) - menu.Items.Add(LocalizedTextService, opensDialog: true); + { + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + } - menu.Items.Add(LocalizedTextService, hasSeparator: true, opensDialog: true); + menu.Items.Add(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false); } return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/DictionaryTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/DictionaryTreeController.cs index 2e97769ca5..d559b87d87 100644 --- a/src/Umbraco.Web.BackOffice/Trees/DictionaryTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/DictionaryTreeController.cs @@ -126,15 +126,14 @@ namespace Umbraco.Cms.Web.BackOffice.Trees { var menu = _menuItemCollectionFactory.Create(); - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); if (id != Constants.System.RootString) { - menu.Items.Add(LocalizedTextService, true, opensDialog: true); - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } - menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs index ba32715f59..559c4561ef 100644 --- a/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/FileSystemTreeController.cs @@ -65,10 +65,14 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var hasChildren = FileSystem is not null && (FileSystem.GetFiles(directory).Any() || FileSystem.GetDirectories(directory).Any()); var name = Path.GetFileName(directory); - var node = CreateTreeNode(WebUtility.UrlEncode(directory), path, queryStrings, name, "icon-folder", hasChildren); + var node = CreateTreeNode(WebUtility.UrlEncode(directory), path, queryStrings, name, Constants.Icons.Folder, hasChildren); + OnRenderFolderNode(ref node); + if (node != null) + { nodes.Add(node); + } } } @@ -94,9 +98,13 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var name = Path.GetFileName(file); var node = CreateTreeNode(WebUtility.UrlEncode(file), path, queryStrings, name, FileIcon, false); + OnRenderFileNode(ref node); + if (node != null) + { nodes.Add(node); + } } } @@ -112,8 +120,9 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } var root = rootResult.Value; - //check if there are any children + // check if there are any children var treeNodesResult = GetTreeNodes(Constants.System.RootString, queryStrings); + if (!(treeNodesResult.Result is null)) { return treeNodesResult.Result; @@ -132,11 +141,13 @@ namespace Umbraco.Cms.Web.BackOffice.Trees { var menu = MenuItemCollectionFactory.Create(); - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; - //create action - menu.Items.Add(LocalizedTextService, opensDialog: true); - //refresh action + + // create action + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + + // refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -146,21 +157,22 @@ namespace Umbraco.Cms.Web.BackOffice.Trees { var menu = MenuItemCollectionFactory.Create(); - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; - //create action - menu.Items.Add(LocalizedTextService, opensDialog: true); + + // create action + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); var hasChildren = FileSystem is not null && (FileSystem.GetFiles(path).Any() || FileSystem.GetDirectories(path).Any()); - //We can only delete folders if it doesn't have any children (folders or files) + // We can only delete folders if it doesn't have any children (folders or files) if (hasChildren == false) { - //delete action - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + // delete action + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } - //refresh action + // refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -170,8 +182,8 @@ namespace Umbraco.Cms.Web.BackOffice.Trees { var menu = MenuItemCollectionFactory.Create(); - //if it's not a directory then we only allow to delete the item - menu.Items.Add(LocalizedTextService, opensDialog: true); + // if it's not a directory then we only allow to delete the item + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); return menu; } diff --git a/src/Umbraco.Web.BackOffice/Trees/MacrosTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MacrosTreeController.cs index 4edff226f6..c7870929f5 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MacrosTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MacrosTreeController.cs @@ -75,10 +75,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { - //Create the normal create action - menu.Items.Add(LocalizedTextService); + // Create the normal create action + menu.Items.Add(LocalizedTextService, useLegacyIcon: false); - //refresh action + // refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -87,8 +87,8 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var macro = _macroService.GetById(int.Parse(id, CultureInfo.InvariantCulture)); if (macro == null) return menu; - //add delete option for all macros - menu.Items.Add(LocalizedTextService, opensDialog: true); + // add delete option for all macros + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); return menu; } diff --git a/src/Umbraco.Web.BackOffice/Trees/MediaTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MediaTreeController.cs index 2bd171b7c7..1afe16ea7b 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MediaTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MediaTreeController.cs @@ -118,9 +118,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } // root actions - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); + return menu; } @@ -134,7 +135,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees return NotFound(); } - //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 (!_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasMediaPathAccess(item, _entityService, _appCaches) ?? false) { menu.Items.Add(new RefreshNode(LocalizedTextService, true)); @@ -142,27 +143,26 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } - //if the media item is in the recycle bin, we don't have a default menu and we need to show a limited menu + // if the media item is in the recycle bin, we don't have a default menu and we need to show a limited menu if (item.Path.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries).Contains(RecycleBinId.ToInvariantString())) { - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); menu.DefaultMenuAlias = null; - } else { - //return a normal node menu: - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService, opensDialog: true); - menu.Items.Add(LocalizedTextService); + // return a normal node menu: + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); + menu.Items.Add(LocalizedTextService, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); - //set the default to create + // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; } @@ -172,7 +172,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees protected override UmbracoObjectTypes UmbracoObjectType => UmbracoObjectTypes.Media; /// - /// Returns true or false if the current user has access to the node based on the user's allowed start node (path) access + /// Returns true or false if the current user has access to the node based on the user's allowed start node (path) access. /// /// /// diff --git a/src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs index 94b0ae76a5..b70cc3dc60 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs @@ -96,7 +96,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees menu.DefaultMenuAlias = ActionNew.ActionAlias; // root actions - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService)); return menu; } @@ -107,17 +107,18 @@ namespace Umbraco.Cms.Web.BackOffice.Trees // set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new MenuItem("rename", LocalizedTextService.Localize("actions", "rename")) { - Icon = "icon icon-edit" + Icon = "icon-edit", + UseLegacyIcon = false }); if (container.HasChildren == false) { // can delete doc type - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); } menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } @@ -126,21 +127,21 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var ct = _mediaTypeService.Get(int.Parse(id, CultureInfo.InvariantCulture)); var parent = ct == null ? null : _mediaTypeService.Get(ct.ParentId); - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); // no move action if this is a child doc type if (parent == null) { - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); if(ct?.IsSystemMediaType() == false) { - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); } - menu.Items.Add(new RefreshNode(LocalizedTextService, true)); + menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs index bd5c22b147..cb1114c24d 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MemberGroupTreeController.cs @@ -53,7 +53,6 @@ namespace Umbraco.Cms.Web.BackOffice.Trees } - protected override IEnumerable GetTreeNodesFromService(string id, FormCollection queryStrings) => _memberGroupService.GetAll() .OrderBy(x => x.Name) diff --git a/src/Umbraco.Web.BackOffice/Trees/MemberTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/MemberTreeController.cs index 5cf469ded5..3c522763f6 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MemberTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MemberTreeController.cs @@ -96,7 +96,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees member.Name, Constants.Icons.Member, false, - "", + string.Empty, Udi.Create(ObjectTypes.GetUdiType(Constants.ObjectTypes.Member), member.Key)); node.AdditionalData.Add("contentType", member.ContentTypeAlias); @@ -121,9 +121,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees queryStrings.GetRequiredValue("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + memberType.Alias))); } - //There is no menu for any of these nodes + // There is no menu for any of these nodes nodes.ForEach(x => x.MenuUrl = null); - //All nodes are containers + + // All nodes are containers nodes.ForEach(x => x.AdditionalData.Add("isContainer", true)); return nodes; @@ -136,18 +137,19 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { // root actions - //set default + // set default menu.DefaultMenuAlias = ActionNew.ActionAlias; - //Create the normal create action - menu.Items.Add(LocalizedTextService, opensDialog: true); + // Create the normal create action + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); + return menu; } - //add delete option for all members - menu.Items.Add(LocalizedTextService, opensDialog: true); + // add delete option for all members + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); if (_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasAccessToSensitiveData() ?? false) { diff --git a/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs b/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs index 64e8081dec..8982f2d2f5 100644 --- a/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs +++ b/src/Umbraco.Web.BackOffice/Trees/MemberTypeAndGroupTreeControllerBase.cs @@ -80,11 +80,11 @@ namespace Umbraco.Cms.Web.BackOffice.Trees var memberType = _memberTypeService.Get(int.Parse(id)); if (memberType != null) { - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); } // delete member type/group - menu.Items.Add(LocalizedTextService, opensDialog: true); + menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); } return menu; diff --git a/src/Umbraco.Web.BackOffice/Trees/RelationTypeTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/RelationTypeTreeController.cs index 22f96fa7c8..b9f34551c2 100644 --- a/src/Umbraco.Web.BackOffice/Trees/RelationTypeTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/RelationTypeTreeController.cs @@ -43,10 +43,10 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { - //Create the normal create action - menu.Items.Add(LocalizedTextService); + // Create the normal create action + menu.Items.Add(LocalizedTextService, useLegacyIcon: false); - //refresh action + // refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -57,7 +57,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (relationType.IsSystemRelationType() == false) { - menu.Items.Add(LocalizedTextService); + menu.Items.Add(LocalizedTextService, useLegacyIcon: false); } return menu; @@ -70,8 +70,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (id == Constants.System.RootString) { nodes.AddRange(_relationService.GetAllRelationTypes() - .Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name, - "icon-trafic", false))); + .Select(rt => CreateTreeNode(rt.Id.ToString(), id, queryStrings, rt.Name, "icon-trafic", false))); } return nodes; diff --git a/src/Umbraco.Web.BackOffice/Trees/TemplatesTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/TemplatesTreeController.cs index caf976e7f2..b42312e634 100644 --- a/src/Umbraco.Web.BackOffice/Trees/TemplatesTreeController.cs +++ b/src/Umbraco.Web.BackOffice/Trees/TemplatesTreeController.cs @@ -111,13 +111,13 @@ namespace Umbraco.Cms.Web.BackOffice.Trees { var menu = _menuItemCollectionFactory.Create(); - //Create the normal create action - var item = menu.Items.Add(LocalizedTextService, opensDialog: true); + // Create the normal create action + var item = menu.Items.Add(LocalizedTextService, opensDialog: true, useLegacyIcon: false); item?.NavigateToRoute($"{queryStrings.GetRequiredValue("application")}/templates/edit/{id}?create=true"); if (id == Constants.System.RootString) { - //refresh action + // refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return menu; @@ -127,17 +127,16 @@ namespace Umbraco.Cms.Web.BackOffice.Trees if (template == null) return menu; var entity = FromTemplate(template); - //don't allow delete if it has child layouts + // don't allow delete if it has child layouts if (template.IsMasterTemplate == false) { - //add delete option if it doesn't have children - menu.Items.Add(LocalizedTextService, true, opensDialog: true); + // add delete option if it doesn't have children + menu.Items.Add(LocalizedTextService, true, opensDialog: true, useLegacyIcon: false); } - //add refresh + // add refresh menu.Items.Add(new RefreshNode(LocalizedTextService, true)); - return menu; } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbcontextmenu.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbcontextmenu.directive.js index f666e62587..7749dacdcc 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbcontextmenu.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/application/umbcontextmenu.directive.js @@ -7,7 +7,7 @@ * Handles the click events on the context menu **/ angular.module("umbraco.directives") -.directive('umbContextMenu', function (navigationService, keyboardService, backdropService) { +.directive('umbContextMenu', function (navigationService, keyboardService) { return { scope: { menuDialogTitle: "@", @@ -20,22 +20,27 @@ angular.module("umbraco.directives") templateUrl: 'views/components/application/umb-contextmenu.html', link: function (scope, element, attrs, ctrl) { + // Map action icons using legacy icon font or svg icons. + Utilities.forEach(scope.menuActions, action => { + action.icon = (action.useLegacyIcon ? 'icon-' : '') + action.icon; + }); + //adds a handler to the context menu item click, we need to handle this differently //depending on what the menu item is supposed to do. - scope.executeMenuItem = function (action) { + scope.executeMenuItem = action => { navigationService.executeMenuAction(action, scope.currentNode, scope.currentSection); }; - - scope.outSideClick = function() { + + scope.outSideClick = () => { navigationService.hideNavigation(); }; - - keyboardService.bind("esc", function() { + + keyboardService.bind("esc", () => { navigationService.hideNavigation(); }); - + //ensure to unregister from all events! - scope.$on('$destroy', function () { + scope.$on('$destroy', () => { keyboardService.unbind("esc"); }); } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditormenu.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditormenu.directive.js index 281a52e4e5..37ce9096f6 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditormenu.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditormenu.directive.js @@ -1,7 +1,7 @@ (function () { 'use strict'; - function EditorMenuDirective($injector, treeService, navigationService, umbModelMapper, appState) { + function EditorMenuDirective(treeService, navigationService, appState) { function link(scope, el, attr, ctrl) { @@ -17,7 +17,7 @@ //adds a handler to the context menu item click, we need to handle this differently //depending on what the menu item is supposed to do. - scope.executeMenuItem = function (action) { + scope.executeMenuItem = action => { //the action is called as it would be by the tree. to ensure that the action targets the correct node, //we need to set the current node in appState before calling the action. otherwise we break all actions //that use the current node (and that's pretty much all of them) @@ -34,10 +34,14 @@ } if (!scope.actions) { - treeService.getMenu({ treeNode: scope.currentNode }) - .then(function (data) { - scope.actions = data.menuItems; + treeService.getMenu({ treeNode: scope.currentNode }).then(data => { + scope.actions = data.menuItems; + + // Map action icons using legacy icon font or svg icons. + Utilities.forEach(scope.actions, action => { + action.icon = (action.useLegacyIcon ? 'icon-' : '') + action.icon; }); + }); } }; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-contextmenu.html b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-contextmenu.html index 107103b1b4..cee9da9ebc 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/application/umb-contextmenu.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/application/umb-contextmenu.html @@ -14,7 +14,7 @@ ng-class="{sep:action.separator, '-opens-dialog': action.opensDialog}" ng-repeat="action in menuActions"> diff --git a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html index f5ed572fa6..aa6ec85bc3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-menu.html @@ -8,14 +8,13 @@ show-caret="true" has-popup="true" is-expanded="dropdown.isOpen" - disabled="!actions || !actions.length || isDisabled" - > + disabled="!actions || !actions.length || isDisabled"> - +