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

@ -0,0 +1,42 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.Models
{
public enum CustomActionScope
{
Repository,
Commit,
}
public class CustomAction : ObservableObject
{
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public CustomActionScope Scope
{
get => _scope;
set => SetProperty(ref _scope, value);
}
public string Executable
{
get => _executable;
set => SetProperty(ref _executable, value);
}
public string Arguments
{
get => _arguments;
set => SetProperty(ref _arguments, value);
}
private string _name = string.Empty;
private CustomActionScope _scope = CustomActionScope.Repository;
private string _executable = string.Empty;
private string _arguments = string.Empty;
}
}

View file

@ -100,6 +100,12 @@ namespace SourceGit.Models
set;
} = new AvaloniaList<IssueTrackerRule>();
public AvaloniaList<CustomAction> CustomActions
{
get;
set;
} = new AvaloniaList<CustomAction>();
public bool EnableAutoFetch
{
get;
@ -230,5 +236,22 @@ namespace SourceGit.Models
if (rule != null)
IssueTrackerRules.Remove(rule);
}
public CustomAction AddNewCustomAction()
{
var act = new CustomAction()
{
Name = "Unnamed Custom Action",
};
CustomActions.Add(act);
return act;
}
public void RemoveCustomAction(CustomAction act)
{
if (act != null)
CustomActions.Remove(act);
}
}
}