mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-22 05:40:43 +08:00
ux: add badge for global custom actions (#1490)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
8
src/ViewModels/CustomActionContextMenuLabel.cs
Normal file
8
src/ViewModels/CustomActionContextMenuLabel.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user