"Actions" drop down options do not give context to the user (#6301)

This commit is contained in:
Jan Skovgaard
2020-05-26 17:45:39 +02:00
committed by GitHub
parent 78a7785256
commit 32a0c3b075
7 changed files with 56 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
using System.Threading;
namespace Umbraco.Web.Models.Trees
{
@@ -28,12 +29,15 @@ namespace Umbraco.Web.Models.Trees
Name = name;
}
public MenuItem(string alias, ILocalizedTextService textService)
: this()
{
var values = textService.GetAllStoredValues(Thread.CurrentThread.CurrentUICulture);
values.TryGetValue($"visuallyHiddenTexts/{alias}_description", out var textDescription);
Alias = alias;
Name = textService.Localize($"actions/{Alias}");
TextDescription = textDescription;
}
/// <summary>
@@ -74,6 +78,9 @@ namespace Umbraco.Web.Models.Trees
[Required]
public string Alias { get; set; }
[DataMember(Name = "textDescription")]
public string TextDescription { get; set; }
/// <summary>
/// Ensures a menu separator will exist before this menu item
/// </summary>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Umbraco.Core;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
@@ -75,7 +76,7 @@ namespace Umbraco.Web.Models.Trees
}
return null;
}
internal MenuItem CreateMenuItem<T>(string name, bool hasSeparator = false, bool opensDialog = false)
where T : IAction
{
@@ -96,14 +97,18 @@ namespace Umbraco.Web.Models.Trees
var item = Current.Actions.GetAction<T>();
if (item == null) return null;
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}"))
{
SeparatorBefore = hasSeparator,
OpensDialog = opensDialog
OpensDialog = opensDialog,
TextDescription = textDescription,
};
return menuItem;
}
}
}