From 947340e45b99cae70dd40fff9101e62871fd48ab Mon Sep 17 00:00:00 2001 From: Shawn White Date: Thu, 29 Jun 2017 23:35:36 +0200 Subject: [PATCH] Additional cleanup to the authentication window. - Make authentication window into a utility window (non-dockable). - Force constant size. - Shrink gap between label and text field. - Rename authentication window title to Authentication to match menu item. - Remove unused fields. - Enable wordwrap for errors. - Use title capitalization for labels. --- .../Assets/Editor/GitHub.Unity/Misc/Styles.cs | 2 +- .../GitHub.Unity/UI/AuthenticationView.cs | 17 +++++++---------- .../GitHub.Unity/UI/AuthenticationWindow.cs | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs index fcde9948f..6912478e5 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs @@ -266,7 +266,7 @@ public static GUIStyle ErrorLabel { errorLabel = new GUIStyle(EditorStyles.label); errorLabel.name = "ErrorLabel"; - + errorLabel.wordWrap = true; errorLabel.normal.textColor = Color.red; } diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs index 546a402d9..bbd8282f7 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs @@ -7,15 +7,14 @@ namespace GitHub.Unity [Serializable] class AuthenticationView : Subview { - const string serverLabel = "Server"; const string usernameLabel = "Username"; const string passwordLabel = "Password"; - const string twofaLabel = "Authentication code"; + const string twofaLabel = "2FA Code"; const string loginButton = "Sign in"; const string backButton = "Back"; const string authTitle = "Sign in to GitHub"; - const string twofaTitle = "Two-factor authentication"; - const string twofaDescription = "Open the two-factor authentication app on your device to view your authentication code and verify your identity."; + const string twofaTitle = "Two-Factor Authentication"; + const string twofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity."; const string twofaButton = "Verify"; [SerializeField] private Vector2 scroll; @@ -76,6 +75,8 @@ public override void OnGUI() { HandleEnterPressed(); + EditorGUIUtility.labelWidth = 90f; + scroll = GUILayout.BeginScrollView(scroll); { Rect authHeader = EditorGUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle); @@ -114,7 +115,6 @@ public override void OnGUI() } GUILayout.EndVertical(); - GUILayout.Space(Styles.BaseSpacing); } GUILayout.EndScrollView(); } @@ -135,7 +135,7 @@ private void OnGUILogin() GUILayout.BeginHorizontal(); { if (busy) GUI.enabled = false; - username = EditorGUILayout.TextField("Username" ,username, Styles.TextFieldStyle); + username = EditorGUILayout.TextField(usernameLabel ,username, Styles.TextFieldStyle); GUI.enabled = true; } GUILayout.EndHorizontal(); @@ -143,7 +143,7 @@ private void OnGUILogin() GUILayout.BeginHorizontal(); { if (busy) GUI.enabled = false; - password = EditorGUILayout.PasswordField("Password", password, Styles.TextFieldStyle); + password = EditorGUILayout.PasswordField(passwordLabel, password, Styles.TextFieldStyle); GUI.enabled = true; } GUILayout.EndHorizontal(); @@ -196,8 +196,6 @@ private void OnGUI2FA() Redraw(); } - GUILayout.Space(Styles.BaseSpacing); - if (GUILayout.Button(twofaButton) || (GUI.enabled && enterPressed)) { GUI.FocusControl(null); @@ -209,7 +207,6 @@ private void OnGUI2FA() GUI.enabled = true; GUILayout.Space(Styles.BaseSpacing); GUILayout.EndVertical(); - GUILayout.Space(Styles.BaseSpacing); } private void DoRequire2fa(string msg) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs index 2b11f5b40..fbfbb6fc8 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEditor; using UnityEngine; @@ -7,7 +7,7 @@ namespace GitHub.Unity [Serializable] class AuthenticationWindow : BaseWindow { - private const string Title = "Sign in"; + private const string Title = "Authentication"; [SerializeField] private AuthenticationView authView; @@ -19,10 +19,10 @@ public static void Launch() public static IView Open(Action onClose = null) { - AuthenticationWindow authWindow = GetWindow(); + AuthenticationWindow authWindow = GetWindow(true); if (onClose != null) authWindow.OnClose += onClose; - authWindow.minSize = new Vector2(290, 290); + authWindow.minSize = authWindow.maxSize = new Vector2(290, 290); authWindow.Show(); return authWindow; }