@@ -77,12 +77,7 @@ public class CustomActionControlComboBox : ObservableObject, ICustomActionContro
7777 public string Label { get ; set ; }
7878 public string Description { get ; set ; }
7979 public List < string > Options { get ; set ; } = [ ] ;
80-
81- public string Value
82- {
83- get => _value ;
84- set => SetProperty ( ref _value , value ) ;
85- }
80+ public string Value { get ; set ; }
8681
8782 public CustomActionControlComboBox ( string label , string description , string options )
8883 {
@@ -93,13 +88,45 @@ public CustomActionControlComboBox(string label, string description, string opti
9388 if ( parts . Length > 0 )
9489 {
9590 Options . AddRange ( parts ) ;
96- _value = parts [ 0 ] ;
91+ Value = parts [ 0 ] ;
9792 }
9893 }
9994
100- public string GetValue ( ) => _value ;
95+ public string GetValue ( ) => Value ;
96+ }
97+
98+ public class CustomActionControlBranchSelector : ObservableObject , ICustomActionControlParameter
99+ {
100+ public string Label { get ; set ; }
101+ public string Description { get ; set ; }
102+ public List < Models . Branch > Branches { get ; set ; } = [ ] ;
103+ public Models . Branch SelectedBranch { get ; set ; }
104+
105+ public CustomActionControlBranchSelector ( string label , string description , Repository repo , bool isLocal , bool useFriendlyName )
106+ {
107+ Label = label ;
108+ Description = description ;
109+ _useFriendlyName = useFriendlyName ;
101110
102- private string _value = string . Empty ;
111+ foreach ( var b in repo . Branches )
112+ {
113+ if ( b . IsLocal == isLocal && ! b . IsDetachedHead )
114+ Branches . Add ( b ) ;
115+ }
116+
117+ if ( Branches . Count > 0 )
118+ SelectedBranch = Branches [ 0 ] ;
119+ }
120+
121+ public string GetValue ( )
122+ {
123+ if ( SelectedBranch == null )
124+ return string . Empty ;
125+
126+ return _useFriendlyName ? SelectedBranch . FriendlyName : SelectedBranch . Name ;
127+ }
128+
129+ private bool _useFriendlyName = false ;
103130 }
104131
105132 public class ExecuteCustomAction : Popup
@@ -171,6 +198,12 @@ private void PrepareControlParameters()
171198 case Models . CustomActionControlType . ComboBox :
172199 ControlParameters . Add ( new CustomActionControlComboBox ( ctl . Label , ctl . Description , PrepareStringByTarget ( ctl . StringValue ) ) ) ;
173200 break ;
201+ case Models . CustomActionControlType . LocalBranchSelector :
202+ ControlParameters . Add ( new CustomActionControlBranchSelector ( ctl . Label , ctl . Description , _repo , true , false ) ) ;
203+ break ;
204+ case Models . CustomActionControlType . RemoteBranchSelector :
205+ ControlParameters . Add ( new CustomActionControlBranchSelector ( ctl . Label , ctl . Description , _repo , false , ctl . BoolValue ) ) ;
206+ break ;
174207 }
175208 }
176209 }
0 commit comments