mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
code_style: add ViewModels.Repository.GetCustomAction(scope)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
5c279b4b56
commit
cf8cff6b64
2 changed files with 22 additions and 37 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue