diff --git a/src/Models/CustomAction.cs b/src/Models/CustomAction.cs index ec500d3c0..1f88c7b47 100644 --- a/src/Models/CustomAction.cs +++ b/src/Models/CustomAction.cs @@ -25,6 +25,23 @@ public record CustomActionTargetFile(string File, Commit Revision); public class CustomActionControl : ObservableObject { + public CustomActionControl() + { + } + + public CustomActionControl(CustomActionControl cac) + { + if (cac != null) + { + Type = cac.Type; + Description = cac.Description; + Label = cac.Label; + Description = cac.Description; + StringValue = cac.StringValue; + BoolValue = cac.BoolValue; + } + } + public CustomActionControlType Type { get => _type; @@ -64,6 +81,24 @@ public bool BoolValue public class CustomAction : ObservableObject { + public CustomAction() + { + } + + public CustomAction(CustomAction action) + { + if (action != null) + { + Name = action.Name; + Scope = action.Scope; + Executable = action.Executable; + Arguments = action.Arguments; + WaitForExit = action.WaitForExit; + foreach (var control in action.Controls) + Controls.Add(new CustomActionControl(control)); + } + } + public string Name { get => _name; diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index b0d52d50a..2cb10a508 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -259,6 +259,16 @@ public CustomAction AddNewCustomAction() return act; } + public CustomAction DuplicateCustomAction(CustomAction baseAct) + { + var act = new CustomAction(baseAct) + { + Name = baseAct.Name + " - (Copy)" + }; + CustomActions.Add(act); + return act; + } + public void RemoveCustomAction(CustomAction act) { if (act != null) diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index bc1e59b36..ab6addc6c 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -266,6 +266,11 @@ public void RemoveSelectedCustomAction() SelectedCustomAction = null; } + public void DuplicateSelectedCustomAction() + { + SelectedCustomAction = _repo.Settings.DuplicateCustomAction(_selectedCustomAction); + } + public void MoveSelectedCustomActionUp() { if (_selectedCustomAction != null) diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index 37d83012f..00a26b400 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -677,7 +677,7 @@ - + - + - - + -