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

Commit 1868d98

Browse files
Merge pull request #273 from github-for-unity/enhancements/subview-is-busy
Adding IsBusy to IView
2 parents 08a7dbd + f06ff6e commit 1868d98

File tree

13 files changed

+96
-42
lines changed

13 files changed

+96
-42
lines changed

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

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,8 @@ class AuthenticationView : Subview
2929
[NonSerialized] private string errorMessage;
3030
[NonSerialized] private bool enterPressed;
3131
[NonSerialized] private string password = "";
32-
3332
[NonSerialized] private AuthenticationService authenticationService;
34-
private AuthenticationService AuthenticationService
35-
{
36-
get
37-
{
38-
if (authenticationService == null)
39-
{
40-
UriString host;
41-
if (Repository != null && Repository.CloneUrl != null && Repository.CloneUrl.IsValidUri)
42-
{
43-
host = new UriString(Repository.CloneUrl.ToRepositoryUri()
44-
.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped));
45-
}
46-
else
47-
{
48-
host = UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
49-
}
5033

51-
AuthenticationService = new AuthenticationService(host, Platform.Keychain);
52-
}
53-
return authenticationService;
54-
}
55-
set
56-
{
57-
authenticationService = value;
58-
}
59-
}
6034

6135
public override void InitializeView(IView parent)
6236
{
@@ -250,5 +224,37 @@ private void ShowErrorMessage()
250224
GUILayout.Label(errorMessage, Styles.ErrorLabel);
251225
}
252226
}
227+
228+
private AuthenticationService AuthenticationService
229+
{
230+
get
231+
{
232+
if (authenticationService == null)
233+
{
234+
UriString host;
235+
if (Repository != null && Repository.CloneUrl != null && Repository.CloneUrl.IsValidUri)
236+
{
237+
host = new UriString(Repository.CloneUrl.ToRepositoryUri()
238+
.GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped));
239+
}
240+
else
241+
{
242+
host = UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
243+
}
244+
245+
AuthenticationService = new AuthenticationService(host, Platform.Keychain);
246+
}
247+
return authenticationService;
248+
}
249+
set
250+
{
251+
authenticationService = value;
252+
}
253+
}
254+
255+
public override bool IsBusy
256+
{
257+
get { return isBusy; }
258+
}
253259
}
254260
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public virtual void OnSelectionChange()
111111

112112
public Rect Position { get { return position; } }
113113
public IApplicationManager Manager { get; private set; }
114+
public abstract bool IsBusy { get; }
114115
public IRepository Repository { get { return inLayout ? cachedRepository : Environment.Repository; } }
115116
public bool HasRepository { get { return Environment.RepositoryPath != null; } }
116117

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,11 @@ private void OnTreeNodeChildrenGUI(BranchTreeNode node)
751751
}
752752
}
753753

754+
public override bool IsBusy
755+
{
756+
get { return false; }
757+
}
758+
754759
private enum NodeType
755760
{
756761
Folder,

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class ChangesView : Subview
1919
private const string OneChangedFileLabel = "1 changed file";
2020
private const string NoChangedFilesLabel = "No changed files";
2121

22-
[NonSerialized] private bool busy = true;
23-
[SerializeField] private string commitBody = "";
22+
[NonSerialized] private bool isBusy = true;
2423

24+
[SerializeField] private string commitBody = "";
2525
[SerializeField] private string commitMessage = "";
2626
[SerializeField] private string currentBranch = "[unknown]";
2727
[SerializeField] private Vector2 horizontalScroll;
@@ -72,10 +72,9 @@ private void OnStatusUpdate(GitStatus update)
7272
// (Re)build tree
7373
tree.UpdateEntries(update.Entries.Where(x => x.Status != GitFileStatus.Ignored).ToList());
7474

75-
busy = false;
75+
isBusy = false;
7676
}
7777

78-
7978
public override void OnGUI()
8079
{
8180
GUILayout.BeginHorizontal();
@@ -144,7 +143,7 @@ private void OnCommitDetailsAreaGUI()
144143
GUILayout.Space(Styles.CommitAreaPadding);
145144

146145
// Disable committing when already committing or if we don't have all the data needed
147-
EditorGUI.BeginDisabledGroup(busy || string.IsNullOrEmpty(commitMessage) || !tree.CommitTargets.Any(t => t.Any));
146+
EditorGUI.BeginDisabledGroup(isBusy || string.IsNullOrEmpty(commitMessage) || !tree.CommitTargets.Any(t => t.Any));
148147
{
149148
GUILayout.BeginHorizontal();
150149
{
@@ -187,7 +186,7 @@ private void SelectNone()
187186
private void Commit()
188187
{
189188
// Do not allow new commits before we have received one successful update
190-
busy = true;
189+
isBusy = true;
191190

192191
var files = Enumerable.Range(0, tree.Entries.Count)
193192
.Where(i => tree.CommitTargets[i].All)
@@ -210,8 +209,13 @@ private void Commit()
210209
{
211210
commitMessage = "";
212211
commitBody = "";
213-
busy = false;
212+
isBusy = false;
214213
}).Start();
215214
}
215+
216+
public override bool IsBusy
217+
{
218+
get { return isBusy; }
219+
}
216220
}
217221
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ public override void OnGUI()
8686
GUILayout.EndVertical();
8787
}
8888

89-
private void OnCommitTreeChange()
90-
{
91-
Height = 0f;
92-
Redraw();
93-
}
94-
9589
public void UpdateEntries(IList<GitStatusEntry> newEntries)
9690
{
9791
// Handle the empty list scenario
@@ -112,6 +106,12 @@ public void UpdateEntries(IList<GitStatusEntry> newEntries)
112106
OnCommitTreeChange();
113107
}
114108

109+
private void OnCommitTreeChange()
110+
{
111+
Height = 0f;
112+
Redraw();
113+
}
114+
115115
private void TreeNode(FileTreeNode node)
116116
{
117117
GUILayout.Space(Styles.TreeVerticalSpacing);
@@ -275,7 +275,13 @@ private void TreeNode(FileTreeNode node)
275275
GUILayout.EndHorizontal();
276276
}
277277

278+
public override bool IsBusy
279+
{
280+
get { return false; }
281+
}
282+
278283
public float Height { get; protected set; }
284+
279285
public bool Readonly { get; set; }
280286

281287
public IList<GitStatusEntry> Entries

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class HistoryView : Subview
4747
[NonSerialized] private int selectionIndex;
4848
[NonSerialized] private bool updated = true;
4949
[NonSerialized] private bool useScrollTime;
50+
[NonSerialized] private bool isBusy;
5051

5152
[SerializeField] private Vector2 detailsScroll;
5253
[SerializeField] private Object historyTarget;
@@ -57,7 +58,6 @@ class HistoryView : Subview
5758

5859
[SerializeField] private ChangesetTreeView changesetTree = new ChangesetTreeView();
5960
[SerializeField] private List<GitLogEntry> history = new List<GitLogEntry>();
60-
[SerializeField] private bool isBusy;
6161
[SerializeField] private string currentRemote;
6262
[SerializeField] private bool isPublished;
6363

@@ -124,6 +124,7 @@ public override void OnGUI()
124124

125125
OnEmbeddedGUI();
126126
}
127+
127128
private void AttachHandlers(IRepository repository)
128129
{
129130
if (repository == null)
@@ -745,6 +746,11 @@ private void DrawTimelineRectAroundIconRect(Rect parentRect, Rect iconRect)
745746
EditorGUI.DrawRect(bottomTimelineRect, timelineBarColor);
746747
}
747748

749+
public override bool IsBusy
750+
{
751+
get { return isBusy; }
752+
}
753+
748754
private float EntryHeight
749755
{
750756
get { return Styles.HistoryEntryHeight + Styles.HistoryEntryPadding; }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ interface IView
1515
IRepository Repository { get; }
1616
bool HasRepository { get; }
1717
IApplicationManager Manager { get; }
18+
bool IsBusy { get; }
1819
}
1920
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ public override void InitializeView(IView parent)
2525

2626
public override void OnGUI()
2727
{}
28+
29+
public override bool IsBusy
30+
{
31+
get { return false; }
32+
}
2833
}
2934
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public override void OnDestroy()
108108
OnClose = null;
109109
}
110110

111+
public override bool IsBusy
112+
{
113+
get { return ActiveView.IsBusy; }
114+
}
115+
111116
private Subview ActiveView
112117
{
113118
get

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ public override void OnGUI()
235235
EditorGUI.EndDisabledGroup();
236236
}
237237

238+
public override bool IsBusy
239+
{
240+
get { return isBusy; }
241+
}
242+
238243
private bool IsFormValid
239244
{
240245
get { return !string.IsNullOrEmpty(repoName) && !isBusy && selectedOwner != 0; }

0 commit comments

Comments
 (0)