mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 21:30:37 +08:00
code_style: add ViewModels.Repository.GetCustomAction(scope)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -694,17 +694,7 @@ namespace SourceGit.ViewModels
|
||||
menu.Items.Add(archive);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var actions = new List<Models.CustomAction>();
|
||||
foreach (var action in Preferences.Instance.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Commit)
|
||||
actions.Add(action);
|
||||
}
|
||||
foreach (var action in _repo.Settings.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Commit)
|
||||
actions.Add(action);
|
||||
}
|
||||
var actions = _repo.GetCustomActions(Models.CustomActionScope.Commit);
|
||||
if (actions.Count > 0)
|
||||
{
|
||||
var custom = new MenuItem();
|
||||
|
||||
@@ -943,6 +943,25 @@ namespace SourceGit.ViewModels
|
||||
_workingCopy?.AbortMerge();
|
||||
}
|
||||
|
||||
public List<Models.CustomAction> GetCustomActions(Models.CustomActionScope scope)
|
||||
{
|
||||
var actions = new List<Models.CustomAction>();
|
||||
|
||||
foreach (var act in Preferences.Instance.CustomActions)
|
||||
{
|
||||
if (act.Scope == scope)
|
||||
actions.Add(act);
|
||||
}
|
||||
|
||||
foreach (var act in _settings.CustomActions)
|
||||
{
|
||||
if (act.Scope == scope)
|
||||
actions.Add(act);
|
||||
}
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void RefreshBranches()
|
||||
{
|
||||
var branches = new Commands.QueryBranches(_fullpath).Result();
|
||||
@@ -1443,22 +1462,10 @@ namespace SourceGit.ViewModels
|
||||
|
||||
public ContextMenu CreateContextMenuForCustomAction()
|
||||
{
|
||||
var actions = new List<Models.CustomAction>();
|
||||
foreach (var action in Preferences.Instance.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Repository)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
foreach (var action in _settings.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Repository)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
|
||||
|
||||
var actions = GetCustomActions(Models.CustomActionScope.Repository);
|
||||
if (actions.Count > 0)
|
||||
{
|
||||
foreach (var action in actions)
|
||||
@@ -2355,19 +2362,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
private void TryToAddCustomActionsToBranchContextMenu(ContextMenu menu, Models.Branch branch)
|
||||
{
|
||||
var actions = new List<Models.CustomAction>();
|
||||
foreach (var action in Preferences.Instance.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Branch)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
foreach (var action in Settings.CustomActions)
|
||||
{
|
||||
if (action.Scope == Models.CustomActionScope.Branch)
|
||||
actions.Add(action);
|
||||
}
|
||||
|
||||
var actions = GetCustomActions(Models.CustomActionScope.Branch);
|
||||
if (actions.Count == 0)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user