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

Commit c14943c

Browse files
committed
Add progress reporting to the locks view and cleanup the code
1 parent eded777 commit c14943c

File tree

11 files changed

+42
-32
lines changed

11 files changed

+42
-32
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ public virtual void OnDataUpdate()
6565
public virtual void OnRepositoryChanged(IRepository oldRepository)
6666
{}
6767

68-
public virtual void DoEmptyGUI()
69-
{}
70-
7168
// OnGUI calls this everytime, so override it to render as you would OnGUI
7269
public virtual void OnUI() {}
7370

@@ -120,6 +117,13 @@ public virtual void DoneRefreshing()
120117
IsRefreshing = false;
121118
}
122119

120+
public virtual void DoEmptyGUI()
121+
{}
122+
public virtual void DoProgressGUI()
123+
{}
124+
public virtual void UpdateProgress(IProgress progress)
125+
{}
126+
123127
public Rect Position { get { return position; } }
124128
public IApplicationManager Manager { get; private set; }
125129
public abstract bool IsBusy { get; }

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ private void Render()
221221
Redraw();
222222
}
223223
}
224-
if (ProgressRenderer != null)
225-
ProgressRenderer.DoProgressGUI();
224+
DoProgressGUI();
226225
}
227226

228227
private void BuildTree()

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ public override void OnGUI()
9292
}
9393
EditorGUI.BeginDisabledGroup(isBusy);
9494

95-
if (ProgressRenderer != null)
96-
ProgressRenderer.DoProgressGUI();
95+
DoProgressGUI();
9796

9897
// Do the commit details area
9998
DoCommitGUI();
@@ -381,6 +380,7 @@ private void SelectNone()
381380

382381
private void Commit()
383382
{
383+
isBusy = true;
384384
var files = treeChanges.GetCheckedFiles().ToList();
385385
ITask addTask;
386386

@@ -403,6 +403,7 @@ private void Commit()
403403
commitMessage = "";
404404
commitBody = "";
405405
}
406+
isBusy = false;
406407
}).Start();
407408
}
408409

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private void ValidateAndSetGitInstallPath()
268268
newState.GitExecutablePath = gitPath.ToNPath();
269269
newState.GitLfsExecutablePath = gitLfsPath.ToNPath();
270270
var installer = new GitInstaller(Environment, Manager.ProcessManager, TaskManager.Token);
271-
installer.Progress.OnProgress += ProgressRenderer.UpdateProgress;
271+
installer.Progress.OnProgress += UpdateProgress;
272272

273273
new FuncTask<GitInstaller.GitInstallationState>(TaskManager.Token, () =>
274274
{
@@ -285,7 +285,7 @@ private void ValidateAndSetGitInstallPath()
285285
})
286286
.FinallyInUI((success, ex, state) =>
287287
{
288-
installer.Progress.OnProgress -= ProgressRenderer.UpdateProgress;
288+
installer.Progress.OnProgress -= UpdateProgress;
289289
if (!success)
290290
{
291291
Logger.Error(ex, ErrorValidatingGitPath);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ public override void OnGUI()
391391
Redraw();
392392
}
393393

394-
if (ProgressRenderer != null)
395-
ProgressRenderer.DoProgressGUI();
394+
DoProgressGUI();
396395

397396
if (!selectedEntry.Equals(GitLogEntry.Default))
398397
{

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace GitHub.Unity
55
{
6-
interface IView : ICanRenderEmpty
6+
interface IView : IUIEmpty, IUIProgress
77
{
88
void OnEnable();
99
void OnDisable();
@@ -23,8 +23,14 @@ interface IView : ICanRenderEmpty
2323
bool HasFocus { get; }
2424
}
2525

26-
interface ICanRenderEmpty
26+
interface IUIEmpty
2727
{
2828
void DoEmptyGUI();
2929
}
30+
31+
interface IUIProgress
32+
{
33+
void DoProgressGUI();
34+
void UpdateProgress(IProgress progress);
35+
}
3036
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,8 @@ public override void OnGUI()
429429
var lockControlRect = new Rect(rect.x, rect.y, Position.width, Position.height - rect.height);
430430

431431
var requiresRepaint = locksControl.Render(lockControlRect,
432-
entry =>
433-
{
434-
},
435-
entry => { },
432+
entry => {},
433+
entry => {},
436434
entry =>
437435
{
438436
var menu = new GenericMenu();
@@ -453,6 +451,7 @@ public override void OnGUI()
453451
}
454452

455453
EditorGUI.EndDisabledGroup();
454+
DoProgressGUI();
456455
}
457456

458457
private void UnlockSelectedEntry()
@@ -464,7 +463,7 @@ private void UnlockSelectedEntry()
464463
{
465464
if (success)
466465
{
467-
TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock);
466+
TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock, null);
468467
}
469468
else
470469
{
@@ -487,7 +486,7 @@ private void ForceUnlockSelectedEntry()
487486
{
488487
if (success)
489488
{
490-
TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock);
489+
TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock, null);
491490
}
492491
else
493492
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private static void ContextMenu_UnlockForce()
210210
{
211211
if (success)
212212
{
213-
EntryPoint.ApplicationManager.TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock);
213+
EntryPoint.ApplicationManager.TaskManager.Run(EntryPoint.ApplicationManager.UsageTracker.IncrementUnityProjectViewContextLfsUnlock, null);
214214
}
215215
else
216216
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public override void OnGUI()
107107

108108
GUILayout.EndScrollView();
109109

110-
if (ProgressRenderer != null)
111-
ProgressRenderer.DoProgressGUI();
110+
DoProgressGUI();
112111
}
113112

114113
private void AttachHandlers(IRepository repository)

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ public void DoEmptyGUI()
5656
Parent.DoEmptyGUI();
5757
}
5858

59+
public void DoProgressGUI()
60+
{
61+
Parent.DoProgressGUI();
62+
}
63+
64+
public void UpdateProgress(IProgress progress)
65+
{
66+
Parent.UpdateProgress(progress);
67+
}
68+
5969
protected void Refresh(CacheType type)
6070
{
6171
if (Repository == null)
@@ -87,7 +97,6 @@ public void DoneRefreshing()
8797
}
8898

8999
protected IView Parent { get; private set; }
90-
protected IUIProgress ProgressRenderer { get { return Parent is Subview ? ((Subview)Parent).ProgressRenderer : Parent as IUIProgress; } }
91100
public IApplicationManager Manager { get { return Parent.Manager; } }
92101
public IRepository Repository { get { return Parent.Repository; } }
93102
public bool HasRepository { get { return Parent.HasRepository; } }

0 commit comments

Comments
 (0)