mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
feature: support add custom actions for selected branch (#980)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
9b07034846
commit
9104060d79
7 changed files with 73 additions and 22 deletions
|
@ -1439,7 +1439,7 @@ namespace SourceGit.ViewModels
|
|||
item.Click += (_, e) =>
|
||||
{
|
||||
if (CanCreatePopup())
|
||||
ShowAndStartPopup(new ExecuteCustomAction(this, dup, null));
|
||||
ShowAndStartPopup(new ExecuteCustomAction(this, dup));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
@ -1698,6 +1698,7 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(createBranch);
|
||||
menu.Items.Add(createTag);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
TryToAddCustomActionsToBranchContextMenu(menu, branch);
|
||||
|
||||
if (!IsBare)
|
||||
{
|
||||
|
@ -1968,7 +1969,9 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(archive);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
TryToAddCustomActionsToBranchContextMenu(menu, branch);
|
||||
menu.Items.Add(copy);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
@ -2319,6 +2322,43 @@ namespace SourceGit.ViewModels
|
|||
return null;
|
||||
}
|
||||
|
||||
private void TryToAddCustomActionsToBranchContextMenu(ContextMenu menu, Models.Branch branch)
|
||||
{
|
||||
var actions = new List<Models.CustomAction>();
|
||||
foreach (var action in Settings.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Branch)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
if (actions.Count == 0)
|
||||
return;
|
||||
|
||||
var custom = new MenuItem();
|
||||
custom.Header = App.Text("BranchCM.CustomAction");
|
||||
custom.Icon = App.CreateMenuIcon("Icons.Action");
|
||||
|
||||
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 (CanCreatePopup())
|
||||
ShowAndStartPopup(new ExecuteCustomAction(this, dup, branch));
|
||||
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
custom.Items.Add(item);
|
||||
}
|
||||
|
||||
menu.Items.Add(custom);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
private void UpdateCurrentRevisionFilesForSearchSuggestion()
|
||||
{
|
||||
_revisionFiles.Clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue