Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 947340e

Browse files
committed
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.
1 parent ef2f84b commit 947340e

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static GUIStyle ErrorLabel
266266
{
267267
errorLabel = new GUIStyle(EditorStyles.label);
268268
errorLabel.name = "ErrorLabel";
269-
269+
errorLabel.wordWrap = true;
270270
errorLabel.normal.textColor = Color.red;
271271
}
272272

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationView.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ namespace GitHub.Unity
77
[Serializable]
88
class AuthenticationView : Subview
99
{
10-
const string serverLabel = "Server";
1110
const string usernameLabel = "Username";
1211
const string passwordLabel = "Password";
13-
const string twofaLabel = "Authentication code";
12+
const string twofaLabel = "2FA Code";
1413
const string loginButton = "Sign in";
1514
const string backButton = "Back";
1615
const string authTitle = "Sign in to GitHub";
17-
const string twofaTitle = "Two-factor authentication";
18-
const string twofaDescription = "Open the two-factor authentication app on your device to view your authentication code and verify your identity.";
16+
const string twofaTitle = "Two-Factor Authentication";
17+
const string twofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
1918
const string twofaButton = "Verify";
2019

2120
[SerializeField] private Vector2 scroll;
@@ -76,6 +75,8 @@ public override void OnGUI()
7675
{
7776
HandleEnterPressed();
7877

78+
EditorGUIUtility.labelWidth = 90f;
79+
7980
scroll = GUILayout.BeginScrollView(scroll);
8081
{
8182
Rect authHeader = EditorGUILayout.BeginHorizontal(Styles.AuthHeaderBoxStyle);
@@ -114,7 +115,6 @@ public override void OnGUI()
114115
}
115116

116117
GUILayout.EndVertical();
117-
GUILayout.Space(Styles.BaseSpacing);
118118
}
119119
GUILayout.EndScrollView();
120120
}
@@ -135,15 +135,15 @@ private void OnGUILogin()
135135
GUILayout.BeginHorizontal();
136136
{
137137
if (busy) GUI.enabled = false;
138-
username = EditorGUILayout.TextField("Username" ,username, Styles.TextFieldStyle);
138+
username = EditorGUILayout.TextField(usernameLabel ,username, Styles.TextFieldStyle);
139139
GUI.enabled = true;
140140
}
141141
GUILayout.EndHorizontal();
142142
GUILayout.Space(Styles.BaseSpacing);
143143
GUILayout.BeginHorizontal();
144144
{
145145
if (busy) GUI.enabled = false;
146-
password = EditorGUILayout.PasswordField("Password", password, Styles.TextFieldStyle);
146+
password = EditorGUILayout.PasswordField(passwordLabel, password, Styles.TextFieldStyle);
147147
GUI.enabled = true;
148148
}
149149
GUILayout.EndHorizontal();
@@ -196,8 +196,6 @@ private void OnGUI2FA()
196196
Redraw();
197197
}
198198

199-
GUILayout.Space(Styles.BaseSpacing);
200-
201199
if (GUILayout.Button(twofaButton) || (GUI.enabled && enterPressed))
202200
{
203201
GUI.FocusControl(null);
@@ -209,7 +207,6 @@ private void OnGUI2FA()
209207
GUI.enabled = true;
210208
GUILayout.Space(Styles.BaseSpacing);
211209
GUILayout.EndVertical();
212-
GUILayout.Space(Styles.BaseSpacing);
213210
}
214211

215212
private void DoRequire2fa(string msg)

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using UnityEditor;
33
using UnityEngine;
44

@@ -7,7 +7,7 @@ namespace GitHub.Unity
77
[Serializable]
88
class AuthenticationWindow : BaseWindow
99
{
10-
private const string Title = "Sign in";
10+
private const string Title = "Authentication";
1111

1212
[SerializeField] private AuthenticationView authView;
1313

@@ -19,10 +19,10 @@ public static void Launch()
1919

2020
public static IView Open(Action<bool> onClose = null)
2121
{
22-
AuthenticationWindow authWindow = GetWindow<AuthenticationWindow>();
22+
AuthenticationWindow authWindow = GetWindow<AuthenticationWindow>(true);
2323
if (onClose != null)
2424
authWindow.OnClose += onClose;
25-
authWindow.minSize = new Vector2(290, 290);
25+
authWindow.minSize = authWindow.maxSize = new Vector2(290, 290);
2626
authWindow.Show();
2727
return authWindow;
2828
}

0 commit comments

Comments
 (0)