From 48df3bbb9e01334ba7c7e6634b284c8b9a3d7adb Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Thu, 27 Apr 2017 23:05:30 -0700 Subject: [PATCH 1/4] Add a button and a dialog --- .../Assets/Editor/GitHub.Unity/UI/BranchesView.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs index 12bf15ae0..e645d8218 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs @@ -436,6 +436,10 @@ private void OnCreateGUI() // Create button if (mode == BranchesMode.Default) { + if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) + { + EditorUtility.DisplayDialog("Delete Branch?", "Are you sure you want to delete the branch: BRANCHNAME", "Delete", "Cancel"); + } GUILayout.FlexibleSpace(); if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { From bcca94087674060acf9dad4a91d0cf5b3e69e8ca Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 28 Apr 2017 11:12:11 -0700 Subject: [PATCH 2/4] Enable delete button based on selected branch state Not perfect yet --- .../Assets/Editor/GitHub.Unity/UI/BranchesView.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs index e645d8218..427c8af4e 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs @@ -436,10 +436,16 @@ private void OnCreateGUI() // Create button if (mode == BranchesMode.Default) { + // If the current branch is selected, then do not enable the Delete button + GUI.enabled = activeBranchNode != selectedNode; if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { - EditorUtility.DisplayDialog("Delete Branch?", "Are you sure you want to delete the branch: BRANCHNAME", "Delete", "Cancel"); + var selectedBranchName = selectedNode.Name; + var dialogTitle = "Delete Branch: " + selectedBranchName; + var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?"; + EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel"); } + GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { From 199482ff8e180a64e66287694ad3839868830fc3 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 28 Apr 2017 11:35:04 -0700 Subject: [PATCH 3/4] Move everything into a BeginDisabledGroup --- .../Editor/GitHub.Unity/UI/BranchesView.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs index 427c8af4e..486b84833 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs @@ -437,15 +437,19 @@ private void OnCreateGUI() if (mode == BranchesMode.Default) { // If the current branch is selected, then do not enable the Delete button - GUI.enabled = activeBranchNode != selectedNode; - if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) + var disableDelete = activeBranchNode == selectedNode; + EditorGUI.BeginDisabledGroup(disableDelete); { - var selectedBranchName = selectedNode.Name; - var dialogTitle = "Delete Branch: " + selectedBranchName; - var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?"; - EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel"); + if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) + { + var selectedBranchName = selectedNode.Name; + var dialogTitle = "Delete Branch: " + selectedBranchName; + var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?"; + EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel"); + } } - GUI.enabled = true; + EditorGUI.EndDisabledGroup(); + GUILayout.FlexibleSpace(); if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { From 39fd1f987461c153d7a38c096df815de12f9fa46 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 12 Jun 2017 16:31:12 -0400 Subject: [PATCH 4/4] Adding call to GitClient.DeleteBranch(...) --- .../Assets/Editor/GitHub.Unity/UI/BranchesView.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs index 486b84833..5d7e8d8b2 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs @@ -445,7 +445,10 @@ private void OnCreateGUI() var selectedBranchName = selectedNode.Name; var dialogTitle = "Delete Branch: " + selectedBranchName; var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?"; - EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel"); + if (EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel")) + { + GitClient.DeleteBranch(selectedBranchName, true).Start(); + } } } EditorGUI.EndDisabledGroup();