@@ -27,6 +27,10 @@ class BranchesView : Subview
27
27
private const string LocalTitle = "Local branches" ;
28
28
private const string RemoteTitle = "Remote branches" ;
29
29
private const string CreateBranchButton = "New Branch" ;
30
+ private const string DeleteBranchMessageFormatString = "Are you sure you want to delete the branch: {0}?" ;
31
+ private const string DeleteBranchTitle = "Delete Branch?" ;
32
+ private const string DeleteBranchButton = "Delete" ;
33
+ private const string CancelButtonLabel = "Cancel" ;
30
34
31
35
private bool showLocalBranches = true ;
32
36
private bool showRemoteBranches = true ;
@@ -151,7 +155,7 @@ public void OnEmbeddedGUI()
151
155
152
156
GUILayout . BeginHorizontal ( ) ;
153
157
{
154
- OnCreateGUI ( ) ;
158
+ OnButtonBarGUI ( ) ;
155
159
}
156
160
GUILayout . EndHorizontal ( ) ;
157
161
@@ -312,6 +316,9 @@ private void OnRemoteBranchesUpdate(IEnumerable<GitBranch> list)
312
316
313
317
private void BuildTree ( IEnumerable < GitBranch > local , IEnumerable < GitBranch > remote )
314
318
{
319
+ //Clear the selected node
320
+ selectedNode = null ;
321
+
315
322
// Sort
316
323
var localBranches = new List < GitBranch > ( local ) ;
317
324
var remoteBranches = new List < GitBranch > ( remote ) ;
@@ -455,28 +462,28 @@ private void SetFavourite(BranchTreeNode branch, bool favourite)
455
462
}
456
463
}
457
464
458
- private void OnCreateGUI ( )
465
+ private void OnButtonBarGUI ( )
459
466
{
460
- // Create button
461
467
if ( mode == BranchesMode . Default )
462
468
{
469
+ // Delete button
463
470
// If the current branch is selected, then do not enable the Delete button
464
- var disableDelete = activeBranchNode == selectedNode ;
471
+ var disableDelete = selectedNode == null || selectedNode . Type == NodeType . Folder || activeBranchNode == selectedNode ;
465
472
EditorGUI . BeginDisabledGroup ( disableDelete ) ;
466
473
{
467
- if ( GUILayout . Button ( "Delete" , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
474
+ if ( GUILayout . Button ( DeleteBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
468
475
{
469
476
var selectedBranchName = selectedNode . Name ;
470
- var dialogTitle = "Delete Branch: " + selectedBranchName ;
471
- var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?" ;
472
- if ( EditorUtility . DisplayDialog ( "Delete Branch?" , dialogMessage , "Delete" , "Cancel" ) )
477
+ var dialogMessage = string . Format ( DeleteBranchMessageFormatString , selectedBranchName ) ;
478
+ if ( EditorUtility . DisplayDialog ( DeleteBranchTitle , dialogMessage , DeleteBranchButton , CancelButtonLabel ) )
473
479
{
474
480
GitClient . DeleteBranch ( selectedBranchName , true ) . Start ( ) ;
475
481
}
476
482
}
477
483
}
478
484
EditorGUI . EndDisabledGroup ( ) ;
479
485
486
+ // Create button
480
487
GUILayout . FlexibleSpace ( ) ;
481
488
if ( GUILayout . Button ( CreateBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
482
489
{
0 commit comments