Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
106 changes: 31 additions & 75 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 };
Expand Down Expand Up @@ -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();
{
Expand All @@ -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;
}
Expand All @@ -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)
Expand All @@ -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; }
Expand Down