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

Commit 378c1c0

Browse files
Merge branch 'enhancements/subview-is-busy' into enhancements/git-path-view
2 parents 27fba8f + 23c92e2 commit 378c1c0

21 files changed

+415
-686
lines changed

src/GitHub.Api/Git/IRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ interface IRepository : IEquatable<IRepository>
1010
{
1111
void Initialize(IRepositoryManager repositoryManager);
1212
void Refresh();
13+
ITask CommitAllFiles(string message, string body);
14+
ITask CommitFiles(List<string> files, string message, string body);
1315
ITask SetupRemote(string remoteName, string remoteUrl);
16+
ITask<List<GitLogEntry>> Log();
1417
ITask Pull();
1518
ITask Push();
1619
ITask Fetch();

src/GitHub.Api/Git/Repository.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using System.Linq;
6+
using System.Threading;
67

78
namespace GitHub.Unity
89
{
@@ -78,6 +79,24 @@ public ITask SetupRemote(string remote, string remoteUrl)
7879
}
7980
}
8081

82+
public ITask<List<GitLogEntry>> Log()
83+
{
84+
if (repositoryManager == null)
85+
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
86+
87+
return repositoryManager.Log();
88+
}
89+
90+
public ITask CommitAllFiles(string message, string body)
91+
{
92+
return repositoryManager.CommitAllFiles(message, body);
93+
}
94+
95+
public ITask CommitFiles(List<string> files, string message, string body)
96+
{
97+
return repositoryManager.CommitFiles(files, message, body);
98+
}
99+
81100
public ITask Pull()
82101
{
83102
return repositoryManager.Pull(CurrentRemote.Value.Name, CurrentBranch?.Name);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ interface IRepositoryManager : IDisposable
2828
void Start();
2929
void Stop();
3030
void Refresh();
31+
ITask CommitAllFiles(string message, string body);
3132
ITask CommitFiles(List<string> files, string message, string body);
33+
ITask<List<GitLogEntry>> Log();
3234
ITask Fetch(string remote);
3335
ITask Pull(string remote, string branch);
3436
ITask Push(string remote, string branch);
@@ -191,6 +193,15 @@ public void Refresh()
191193
UpdateGitStatus();
192194
}
193195

196+
public ITask CommitAllFiles(string message, string body)
197+
{
198+
var add = GitClient.AddAll();
199+
add.OnStart += t => IsBusy = true;
200+
return add
201+
.Then(GitClient.Commit(message, body))
202+
.Finally(() => IsBusy = false);
203+
}
204+
194205
public ITask CommitFiles(List<string> files, string message, string body)
195206
{
196207
var add = GitClient.Add(files);
@@ -200,6 +211,13 @@ public ITask CommitFiles(List<string> files, string message, string body)
200211
.Finally(() => IsBusy = false);
201212
}
202213

214+
public ITask<List<GitLogEntry>> Log()
215+
{
216+
var task = GitClient.Log();
217+
HookupHandlers(task);
218+
return task;
219+
}
220+
203221
public ITask Fetch(string remote)
204222
{
205223
var task = GitClient.Fetch(remote);

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<Compile Include="OutputProcessors\LfsVersionOutputProcessor.cs" />
115115
<Compile Include="OutputProcessors\SoftwareVersion.cs" />
116116
<Compile Include="OutputProcessors\VersionOutputProcessor.cs" />
117+
<Compile Include="Helpers\TaskHelpers.cs" />
117118
<Compile Include="Platform\DefaultEnvironment.cs" />
118119
<Compile Include="Extensions\EnvironmentExtensions.cs" />
119120
<Compile Include="Extensions\FileEventExtensions.cs" />

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Threading.Tasks;
2+
3+
namespace GitHub.Unity
4+
{
5+
static class TaskHelpers
6+
{
7+
public static Task<T> GetCompletedTask<T>(T result)
8+
{
9+
return TaskEx.FromResult(result);
10+
}
11+
}
12+
}

src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<Compile Include="EntryPoint.cs" />
8686
<Compile Include="Misc\Installer.cs" />
8787
<Compile Include="UI\BaseWindow.cs" />
88-
<Compile Include="UI\PublishWindow.cs" />
88+
<Compile Include="UI\PopupWindow.cs" />
8989
<Compile Include="UI\ProjectWindowInterface.cs" />
9090
<Compile Include="Misc\Styles.cs" />
9191
<Compile Include="Misc\Utility.cs" />
@@ -95,12 +95,12 @@
9595
<Compile Include="Tasks\TaskException.cs" />
9696
<Compile Include="Tools\MozRoots.cs" />
9797
<Compile Include="UI\AuthenticationView.cs" />
98-
<Compile Include="UI\AuthenticationWindow.cs" />
9998
<Compile Include="UI\BranchesView.cs" />
10099
<Compile Include="UI\ChangesetTreeView.cs" />
101100
<Compile Include="UI\ChangesView.cs" />
102101
<Compile Include="UI\HistoryView.cs" />
103102
<Compile Include="UI\IView.cs" />
103+
<Compile Include="UI\LoadingView.cs" />
104104
<Compile Include="UI\PublishView.cs" />
105105
<Compile Include="UI\GitPathView.cs" />
106106
<Compile Include="UI\SettingsView.cs" />

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ namespace GitHub.Unity
77
[Serializable]
88
class AuthenticationView : Subview
99
{
10-
const string usernameLabel = "Username";
11-
const string passwordLabel = "Password";
12-
const string twofaLabel = "2FA Code";
13-
const string loginButton = "Sign in";
14-
const string backButton = "Back";
15-
const string authTitle = "Sign in to GitHub";
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.";
18-
const string twofaButton = "Verify";
10+
private static readonly Vector2 viewSize = new Vector2(290, 290);
11+
12+
private const string WindowTitle = "Authenticate";
13+
private const string UsernameLabel = "Username";
14+
private const string PasswordLabel = "Password";
15+
private const string TwofaLabel = "2FA Code";
16+
private const string LoginButton = "Sign in";
17+
private const string BackButton = "Back";
18+
private const string AuthTitle = "Sign in to GitHub";
19+
private const string TwofaTitle = "Two-Factor Authentication";
20+
private const string TwofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
21+
private const string TwofaButton = "Verify";
1922

2023
[SerializeField] private Vector2 scroll;
2124
[SerializeField] private string username = "";
@@ -59,6 +62,8 @@ public override void InitializeView(IView parent)
5962
{
6063
base.InitializeView(parent);
6164
need2fa = isBusy = false;
65+
Title = WindowTitle;
66+
Size = viewSize;
6267
}
6368

6469
public override void OnEnable()
@@ -91,7 +96,7 @@ public override void OnGUI()
9196
GUILayout.BeginVertical();
9297
{
9398
GUILayout.Space(11);
94-
GUILayout.Label(authTitle, Styles.HeaderRepoLabelStyle);
99+
GUILayout.Label(AuthTitle, Styles.HeaderRepoLabelStyle);
95100
}
96101
GUILayout.EndVertical();
97102
}
@@ -141,14 +146,14 @@ private void OnGUILogin()
141146
GUILayout.Space(3);
142147
GUILayout.BeginHorizontal();
143148
{
144-
username = EditorGUILayout.TextField(usernameLabel, username, Styles.TextFieldStyle);
149+
username = EditorGUILayout.TextField(UsernameLabel ,username, Styles.TextFieldStyle);
145150
}
146151
GUILayout.EndHorizontal();
147152

148153
GUILayout.Space(Styles.BaseSpacing);
149154
GUILayout.BeginHorizontal();
150155
{
151-
password = EditorGUILayout.PasswordField(passwordLabel, password, Styles.TextFieldStyle);
156+
password = EditorGUILayout.PasswordField(PasswordLabel, password, Styles.TextFieldStyle);
152157
}
153158
GUILayout.EndHorizontal();
154159

@@ -158,7 +163,7 @@ private void OnGUILogin()
158163
GUILayout.BeginHorizontal();
159164
{
160165
GUILayout.FlexibleSpace();
161-
if (GUILayout.Button(loginButton) || (!isBusy && enterPressed))
166+
if (GUILayout.Button(LoginButton) || (!isBusy && enterPressed))
162167
{
163168
GUI.FocusControl(null);
164169
isBusy = true;
@@ -174,15 +179,15 @@ private void OnGUI2FA()
174179
{
175180
GUILayout.BeginVertical();
176181
{
177-
GUILayout.Label(twofaTitle, EditorStyles.boldLabel);
178-
GUILayout.Label(twofaDescription, EditorStyles.wordWrappedLabel);
182+
GUILayout.Label(TwofaTitle, EditorStyles.boldLabel);
183+
GUILayout.Label(TwofaDescription, EditorStyles.wordWrappedLabel);
179184

180185
EditorGUI.BeginDisabledGroup(isBusy);
181186
{
182187
GUILayout.Space(Styles.BaseSpacing);
183188
GUILayout.BeginHorizontal();
184189
{
185-
two2fa = EditorGUILayout.TextField(twofaLabel, two2fa, Styles.TextFieldStyle);
190+
two2fa = EditorGUILayout.TextField(TwofaLabel, two2fa, Styles.TextFieldStyle);
186191
}
187192
GUILayout.EndHorizontal();
188193

@@ -193,14 +198,14 @@ private void OnGUI2FA()
193198
GUILayout.BeginHorizontal();
194199
{
195200
GUILayout.FlexibleSpace();
196-
if (GUILayout.Button(backButton))
201+
if (GUILayout.Button(BackButton))
197202
{
198203
GUI.FocusControl(null);
199204
need2fa = false;
200205
Redraw();
201206
}
202207

203-
if (GUILayout.Button(twofaButton) || (!isBusy && enterPressed))
208+
if (GUILayout.Button(TwofaButton) || (!isBusy && enterPressed))
204209
{
205210
GUI.FocusControl(null);
206211
isBusy = true;

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

Lines changed: 0 additions & 82 deletions
This file was deleted.

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ namespace GitHub.Unity
66
{
77
abstract class BaseWindow : EditorWindow, IView
88
{
9-
[NonSerialized] private bool finishCalled = false;
109
[NonSerialized] private bool initialized = false;
11-
1210
[NonSerialized] private IApplicationManager cachedManager;
1311
[NonSerialized] private IRepository cachedRepository;
1412
[NonSerialized] private bool initializeWasCalled;
1513
[NonSerialized] private bool inLayout;
1614

17-
public event Action<bool> OnClose;
18-
1915
public virtual void Initialize(IApplicationManager applicationManager)
2016
{
2117
Logger.Trace("Initialize ApplicationManager:{0} Initialized:{1}", applicationManager, initialized);
@@ -49,15 +45,7 @@ public virtual void Refresh()
4945
}
5046

5147
public virtual void Finish(bool result)
52-
{
53-
finishCalled = true;
54-
RaiseOnClose(result);
55-
}
56-
57-
protected void RaiseOnClose(bool result)
58-
{
59-
OnClose.SafeInvoke(result);
60-
}
48+
{}
6149

6250
public virtual void Awake()
6351
{
@@ -73,9 +61,11 @@ public virtual void OnEnable()
7361
InitializeWindow(EntryPoint.ApplicationManager);
7462
}
7563

76-
public virtual void OnDisable() {}
64+
public virtual void OnDisable()
65+
{}
7766

78-
public virtual void Update() {}
67+
public virtual void Update()
68+
{}
7969

8070
public virtual void OnDataUpdate()
8171
{}
@@ -114,17 +104,12 @@ private void OnGUI()
114104
}
115105

116106
public virtual void OnDestroy()
117-
{
118-
if (!finishCalled)
119-
{
120-
RaiseOnClose(false);
121-
}
122-
}
107+
{}
123108

124109
public virtual void OnSelectionChange()
125110
{}
126111

127-
public virtual Rect Position { get { return position; } }
112+
public Rect Position { get { return position; } }
128113
public IApplicationManager Manager { get; private set; }
129114
public abstract bool IsBusy { get; }
130115
public IRepository Repository { get { return inLayout ? cachedRepository : Environment.Repository; } }

0 commit comments

Comments
 (0)