ux: add badge for global custom actions (#1490)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-07-02 16:24:48 +08:00
parent 3a1827eb3d
commit 945c63c78a
4 changed files with 29 additions and 12 deletions

View File

@@ -843,6 +843,15 @@
<DataTemplate DataType="vm:FilterModeInGraph">
<v:FilterModeInGraph/>
</DataTemplate>
<DataTemplate DataType="vm:CustomActionContextMenuLabel">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
<Border Margin="4,0,0,0" Height="16" Background="Green" CornerRadius="8" VerticalAlignment="Center" IsVisible="{Binding IsGlobal}">
<TextBlock Classes="primary" Text="GLOBAL" Margin="8,0" FontSize="10" Foreground="White"/>
</Border>
</StackPanel>
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>

View File

@@ -0,0 +1,8 @@
namespace SourceGit.ViewModels
{
public class CustomActionContextMenuLabel(string name, bool isGlobal)
{
public string Name { get; set; } = name;
public bool IsGlobal { get; set; } = isGlobal;
}
}

View File

@@ -800,10 +800,10 @@ namespace SourceGit.ViewModels
foreach (var action in actions)
{
var dup = action;
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Header = dup.Name;
item.Header = label;
item.Click += (_, e) =>
{
_repo.ExecCustomAction(dup, commit);

View File

@@ -1077,20 +1077,20 @@ namespace SourceGit.ViewModels
_workingCopy?.AbortMerge();
}
public List<Models.CustomAction> GetCustomActions(Models.CustomActionScope scope)
public List<(Models.CustomAction, CustomActionContextMenuLabel)> GetCustomActions(Models.CustomActionScope scope)
{
var actions = new List<Models.CustomAction>();
var actions = new List<(Models.CustomAction, CustomActionContextMenuLabel)>();
foreach (var act in Preferences.Instance.CustomActions)
{
if (act.Scope == scope)
actions.Add(act);
actions.Add((act, new CustomActionContextMenuLabel(act.Name, true)));
}
foreach (var act in _settings.CustomActions)
{
if (act.Scope == scope)
actions.Add(act);
actions.Add((act, new CustomActionContextMenuLabel(act.Name, false)));
}
return actions;
@@ -1748,10 +1748,10 @@ namespace SourceGit.ViewModels
{
foreach (var action in actions)
{
var dup = action;
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Header = dup.Name;
item.Header = label;
item.Click += (_, e) =>
{
ExecCustomAction(dup, null);
@@ -2437,10 +2437,10 @@ namespace SourceGit.ViewModels
foreach (var action in actions)
{
var dup = action;
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Header = dup.Name;
item.Header = label;
item.Click += (_, e) =>
{
ExecCustomAction(dup, tag);
@@ -2872,10 +2872,10 @@ namespace SourceGit.ViewModels
foreach (var action in actions)
{
var dup = action;
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Header = dup.Name;
item.Header = label;
item.Click += (_, e) =>
{
ExecCustomAction(dup, branch);