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