diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs index aae40290b..f21c7c93b 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs @@ -13,7 +13,8 @@ class InitProjectView : Subview [SerializeField] private UserSettingsView userSettingsView = new UserSettingsView(); [SerializeField] private GitPathView gitPathView = new GitPathView(); - [SerializeField] private bool isBusy; + + [NonSerialized] private bool isBusy; [NonSerialized] private string errorMessage; [NonSerialized] private bool isUserDataPresent; diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs index addb84e63..14f7ed227 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"; @@ -20,7 +20,9 @@ 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 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 }; @@ -139,81 +141,18 @@ 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); + GUILayout.Label(PublishToGithubLabel, EditorStyles.boldLabel); 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(); - - GUILayout.Label(DescriptionLabel); - repoDescription = EditorGUILayout.TextField(repoDescription); - GUILayout.Space(Styles.PublishViewSpacingHeight); - - GUILayout.BeginVertical(); - { - GUILayout.BeginHorizontal(); - { - togglePrivate = GUILayout.Toggle(togglePrivate, CreatePrivateRepositoryLabel); - } - GUILayout.EndHorizontal(); + selectedOwner = EditorGUILayout.Popup(SelectedOwnerLabel, selectedOwner, owners); + repoName = EditorGUILayout.TextField(RepositoryNameLabel, repoName); + repoDescription = EditorGUILayout.TextField(DescriptionLabel, repoDescription); - GUILayout.BeginHorizontal(); - { - GUILayout.Space(Styles.PublishViewSpacingHeight); - var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; - GUILayout.Label(repoPrivacyExplanation, Styles.LongMessageStyle); - } - GUILayout.EndHorizontal(); - } - GUILayout.EndVertical(); + togglePrivate = EditorGUILayout.Toggle(CreatePrivateRepositoryLabel, togglePrivate); - GUILayout.Space(Styles.PublishViewSpacingHeight); - - if (error != null) - GUILayout.Label(error, Styles.ErrorLabel); - - GUILayout.FlexibleSpace(); + var repoPrivacyExplanation = togglePrivate ? PrivateRepoMessage : PublicRepoMessage; + EditorGUILayout.HelpBox(repoPrivacyExplanation, MessageType.None); GUILayout.BeginHorizontal(); { @@ -235,11 +174,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 +190,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) @@ -261,10 +202,25 @@ public override void OnGUI() } GUILayout.EndHorizontal(); GUILayout.Space(10); + + if (error != null) + EditorGUILayout.HelpBox(error, MessageType.Error); + + GUILayout.FlexibleSpace(); } EditorGUI.EndDisabledGroup(); } + private string GetPublishErrorMessage(Exception ex) + { + if (ex.Message.StartsWith(PublishLimitPrivateRepositoriesError)) + { + return PublishLimitPrivateRepositoriesError; + } + + return ex.Message; + } + public override bool IsBusy { get { return isBusy; }