From fa9cc6f585126fede455d9904bb8a291ebd43bd5 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 13 Oct 2017 11:06:59 -0400 Subject: [PATCH 01/12] Shortening the error message for 'too many private repos' --- .../Editor/GitHub.Unity/UI/PublishView.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index addb84e63..0d0529d69 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -21,6 +21,7 @@ class PublishView : Subview private const string RepositoryNameLabel = "Repository Name"; private const string DescriptionLabel = "Description"; private const string CreatePrivateRepositoryLabel = "Create as a private repository"; + private const string PublishLimtPrivateRepositoriesError = "You are currently at your limt of private repositories"; [SerializeField] private string username; [SerializeField] private string[] owners = { OwnersDefaultText }; @@ -235,11 +236,11 @@ public override void OnGUI() Description = cleanRepoDescription }, (repository, ex) => { - Logger.Trace("Create Repository Callback"); - if (ex != null) { - error = ex.Message; + Logger.Error(ex, "Repository Create Error Type:{0}", ex.GetType().ToString()); + + error = GetPublishErrorMessage(ex); isBusy = false; return; } @@ -251,6 +252,8 @@ public override void OnGUI() return; } + Logger.Trace("Repository Created"); + GitClient.RemoteAdd("origin", repository.CloneUrl) .Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name)) .ThenInUI(Finish) @@ -265,6 +268,16 @@ public override void OnGUI() EditorGUI.EndDisabledGroup(); } + private string GetPublishErrorMessage(Exception ex) + { + if (ex.Message.StartsWith(PublishLimtPrivateRepositoriesError)) + { + return PublishLimtPrivateRepositoriesError; + } + + return ex.Message; + } + public override bool IsBusy { get { return isBusy; } From 9af0497e8b9d43d371fd92ac761b1dedd75c7651 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 13 Oct 2017 11:29:58 -0400 Subject: [PATCH 02/12] Changing the size of the PublishView and displaying the error after the button --- .../Editor/GitHub.Unity/UI/PublishView.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 0d0529d69..a2cb54df6 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -9,7 +9,7 @@ namespace GitHub.Unity { class PublishView : Subview { - private static readonly Vector2 viewSize = new Vector2(300, 250); + private static readonly Vector2 viewSize = new Vector2(400, 350); private const string WindowTitle = "Publish"; private const string Header = "Publish this repository to GitHub"; @@ -211,11 +211,6 @@ public override void OnGUI() GUILayout.Space(Styles.PublishViewSpacingHeight); - if (error != null) - GUILayout.Label(error, Styles.ErrorLabel); - - GUILayout.FlexibleSpace(); - GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); @@ -240,7 +235,7 @@ public override void OnGUI() { Logger.Error(ex, "Repository Create Error Type:{0}", ex.GetType().ToString()); - error = GetPublishErrorMessage(ex); + error = ex.Message; isBusy = false; return; } @@ -264,18 +259,13 @@ public override void OnGUI() } GUILayout.EndHorizontal(); GUILayout.Space(10); - } - EditorGUI.EndDisabledGroup(); - } - private string GetPublishErrorMessage(Exception ex) - { - if (ex.Message.StartsWith(PublishLimtPrivateRepositoriesError)) - { - return PublishLimtPrivateRepositoriesError; - } + if (error != null) + GUILayout.Label(error, Styles.ErrorLabel); - return ex.Message; + GUILayout.FlexibleSpace(); + } + EditorGUI.EndDisabledGroup(); } public override bool IsBusy From 6cd68a7720491f14a2a9146c4f05af3b5338f522 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 10:26:56 -0700 Subject: [PATCH 03/12] :fire: Header --- .../Editor/GitHub.Unity/UI/PublishView.cs | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index a2cb54df6..13c24e7f5 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -140,26 +140,6 @@ private void LoadOrganizations() public override void OnGUI() { - GUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle); - { - GUILayout.BeginVertical(GUILayout.Width(16)); - { - GUILayout.Space(9); - GUILayout.Label(Styles.BigLogo, GUILayout.Height(20), GUILayout.Width(20)); - } - GUILayout.EndVertical(); - - GUILayout.BeginVertical(); - { - GUILayout.Space(11); - GUILayout.Label(Title, EditorStyles.boldLabel); - } - GUILayout.EndVertical(); - } - GUILayout.EndHorizontal(); - - GUILayout.Space(Styles.PublishViewSpacingHeight); - EditorGUI.BeginDisabledGroup(isBusy); { GUILayout.BeginHorizontal(); From c673100d731ce9843f0fce8bd351520c7c2012a7 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 10:38:21 -0700 Subject: [PATCH 04/12] :fire: Fancy layout --- .../Editor/GitHub.Unity/UI/PublishView.cs | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 13c24e7f5..770918e29 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -142,33 +142,10 @@ public override void OnGUI() { EditorGUI.BeginDisabledGroup(isBusy); { - GUILayout.BeginHorizontal(); - { - GUILayout.BeginVertical(); - { - GUILayout.Label(SelectedOwnerLabel); - selectedOwner = EditorGUILayout.Popup(selectedOwner, owners); - } - GUILayout.EndVertical(); - - GUILayout.BeginVertical(GUILayout.Width(8)); - { - GUILayout.Space(20); - GUILayout.Label("/"); - } - GUILayout.EndVertical(); - - GUILayout.BeginVertical(); - { - GUILayout.Label(RepositoryNameLabel); - repoName = EditorGUILayout.TextField(repoName); - } - GUILayout.EndVertical(); - } - GUILayout.EndHorizontal(); + selectedOwner = EditorGUILayout.Popup(SelectedOwnerLabel, selectedOwner, owners); + repoName = EditorGUILayout.TextField(RepositoryNameLabel, repoName); + repoDescription = EditorGUILayout.TextField(DescriptionLabel, repoDescription); - GUILayout.Label(DescriptionLabel); - repoDescription = EditorGUILayout.TextField(repoDescription); GUILayout.Space(Styles.PublishViewSpacingHeight); GUILayout.BeginVertical(); From 8312a720a7960a6990d396c82c732f4b496a58db Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 10:51:44 -0700 Subject: [PATCH 05/12] :fire: Toggle layout --- .../Editor/GitHub.Unity/UI/PublishView.cs | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 770918e29..c06285d06 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -146,27 +146,8 @@ public override void OnGUI() repoName = EditorGUILayout.TextField(RepositoryNameLabel, repoName); repoDescription = EditorGUILayout.TextField(DescriptionLabel, repoDescription); - GUILayout.Space(Styles.PublishViewSpacingHeight); - - GUILayout.BeginVertical(); - { - GUILayout.BeginHorizontal(); - { - togglePrivate = GUILayout.Toggle(togglePrivate, CreatePrivateRepositoryLabel); - } - GUILayout.EndHorizontal(); - - GUILayout.BeginHorizontal(); - { - GUILayout.Space(Styles.PublishViewSpacingHeight); - var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; - GUILayout.Label(repoPrivacyExplanation, Styles.LongMessageStyle); - } - GUILayout.EndHorizontal(); - } - GUILayout.EndVertical(); - - GUILayout.Space(Styles.PublishViewSpacingHeight); + togglePrivate = EditorGUILayout.Toggle(CreatePrivateRepositoryLabel, togglePrivate); + var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; GUILayout.BeginHorizontal(); { From ffffb9a71bc1242fec1960d4fe9c2b9c7c88e656 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 10:55:17 -0700 Subject: [PATCH 06/12] Update create private repo label --- src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index c06285d06..3327c9c8b 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -20,7 +20,7 @@ class PublishView : Subview private const string SelectedOwnerLabel = "Owner"; private const string RepositoryNameLabel = "Repository Name"; private const string DescriptionLabel = "Description"; - private const string CreatePrivateRepositoryLabel = "Create as a private repository"; + private const string CreatePrivateRepositoryLabel = "Make repository private"; private const string PublishLimtPrivateRepositoriesError = "You are currently at your limt of private repositories"; [SerializeField] private string username; From 6cdbe9db1471346a11ef9523901057524c3dc287 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 11:10:02 -0700 Subject: [PATCH 07/12] Add title --- src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 3327c9c8b..31de223a7 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -140,6 +140,8 @@ private void LoadOrganizations() public override void OnGUI() { + GUILayout.Label("Publish to GitHub", EditorStyles.boldLabel); + EditorGUI.BeginDisabledGroup(isBusy); { selectedOwner = EditorGUILayout.Popup(SelectedOwnerLabel, selectedOwner, owners); From fb6b1d9bc7715c7c8c7f382bdd0da7f3b9d5760a Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 11:45:47 -0700 Subject: [PATCH 08/12] Halp --- src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 31de223a7..326efc849 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -201,7 +201,7 @@ public override void OnGUI() GUILayout.Space(10); if (error != null) - GUILayout.Label(error, Styles.ErrorLabel); + EditorGUILayout.HelpBox(error, MessageType.Error); GUILayout.FlexibleSpace(); } From 45a08b36c0fa2e8eee106e663d0807364645f40d Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Fri, 13 Oct 2017 13:50:02 -0700 Subject: [PATCH 09/12] More halp --- src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 326efc849..37db9c2fb 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -149,7 +149,9 @@ public override void OnGUI() repoDescription = EditorGUILayout.TextField(DescriptionLabel, repoDescription); togglePrivate = EditorGUILayout.Toggle(CreatePrivateRepositoryLabel, togglePrivate); + var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; + EditorGUILayout.HelpBox(repoPrivacyExplanation, MessageType.None); GUILayout.BeginHorizontal(); { From d18ae814a37bb39f8abfb0f0feda16c4bf07a7e4 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 16 Oct 2017 17:31:24 -0400 Subject: [PATCH 10/12] IsBusy should be NonSerialized --- .../Assets/Editor/GitHub.Unity/UI/InitProjectView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs index c8ee372a3..9f5bf67d2 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs @@ -15,7 +15,7 @@ class InitProjectView : Subview private const string NoRepoTitle = "No Git repository found for this project"; private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others."; - [SerializeField] private bool isBusy; + [NonSerialized] private bool isBusy; [SerializeField] private bool isPublished; public override void OnDataUpdate() From 80e392b43fa3cd3dbf471e3bb66bf9d838be6e5c Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 23 Oct 2017 10:37:45 -0400 Subject: [PATCH 11/12] Restoring code to change the error message --- .../Assets/Editor/GitHub.Unity/UI/PublishView.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 37db9c2fb..7039ccadc 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -21,7 +21,7 @@ class PublishView : Subview private const string RepositoryNameLabel = "Repository Name"; private const string DescriptionLabel = "Description"; private const string CreatePrivateRepositoryLabel = "Make repository private"; - private const string PublishLimtPrivateRepositoriesError = "You are currently at your limt of private repositories"; + private const string PublishLimitPrivateRepositoriesError = "You are currently at your limit of private repositories"; [SerializeField] private string username; [SerializeField] private string[] owners = { OwnersDefaultText }; @@ -177,7 +177,7 @@ public override void OnGUI() { Logger.Error(ex, "Repository Create Error Type:{0}", ex.GetType().ToString()); - error = ex.Message; + error = GetPublishErrorMessage(ex); isBusy = false; return; } @@ -210,6 +210,16 @@ public override void OnGUI() EditorGUI.EndDisabledGroup(); } + private string GetPublishErrorMessage(Exception ex) + { + if (ex.Message.StartsWith(PublishLimitPrivateRepositoriesError)) + { + return PublishLimitPrivateRepositoriesError; + } + + return ex.Message; + } + public override bool IsBusy { get { return isBusy; } From 2dad14481a0ea2b0b4edd931389b36ade1ecba02 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 23 Oct 2017 10:42:19 -0400 Subject: [PATCH 12/12] Adding another constant for text --- .../Assets/Editor/GitHub.Unity/UI/PublishView.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index 7039ccadc..14f7ed227 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs @@ -22,6 +22,7 @@ class PublishView : Subview private const string DescriptionLabel = "Description"; private const string CreatePrivateRepositoryLabel = "Make repository private"; private const string PublishLimitPrivateRepositoriesError = "You are currently at your limit of private repositories"; + private const string PublishToGithubLabel = "Publish to GitHub"; [SerializeField] private string username; [SerializeField] private string[] owners = { OwnersDefaultText }; @@ -140,7 +141,7 @@ private void LoadOrganizations() public override void OnGUI() { - GUILayout.Label("Publish to GitHub", EditorStyles.boldLabel); + GUILayout.Label(PublishToGithubLabel, EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(isBusy); {