feature: supports custom actions (#638)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-01 17:23:31 +08:00
parent 7c5de7e48c
commit a36058ec51
No known key found for this signature in database
17 changed files with 478 additions and 2 deletions

View file

@ -1287,6 +1287,45 @@ namespace SourceGit.ViewModels
return menu;
}
public ContextMenu CreateContextMenuForCustomAction()
{
var actions = new List<Models.CustomAction>();
foreach (var action in _settings.CustomActions)
{
if (action.Scope == Models.CustomActionScope.Repository)
actions.Add(action);
}
var menu = new ContextMenu();
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
if (actions.Count > 0)
{
foreach (var action in actions)
{
var dup = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Header = dup.Name;
item.Click += (_, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowAndStartPopup(new ExecuteCustomAction(this, action, null));
e.Handled = true;
};
menu.Items.Add(item);
}
}
else
{
menu.Items.Add(new MenuItem() { Header = App.Text("Repository.CustomActions.Empty") });
}
return menu;
}
public ContextMenu CreateContextMenuForLocalBranch(Models.Branch branch)
{
var menu = new ContextMenu();