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

Commit 9692b2a

Browse files
authored
Merge pull request #261 from github-for-unity/fixes/initialize-view-with-configuration
Adding functionality to configure git exec, name and email before project init
2 parents c977479 + 722363a commit 9692b2a

File tree

3 files changed

+23
-42
lines changed

3 files changed

+23
-42
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
52
using System.Text;
6-
using System.Threading.Tasks;
73
using UnityEditor;
84
using UnityEngine;
95

@@ -38,7 +34,6 @@ class GitPathView : Subview
3834
public override void OnEnable()
3935
{
4036
base.OnEnable();
41-
4237
gitExecHasChanged = true;
4338
}
4439

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
#pragma warning disable 649
2-
31
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
62
using UnityEditor;
73
using UnityEngine;
8-
using Object = UnityEngine.Object;
94

105
namespace GitHub.Unity
116
{
@@ -14,20 +9,24 @@ class InitProjectView : Subview
149
{
1510
private const string NoRepoTitle = "No Git repository found for this project";
1611
private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others.";
17-
12+
13+
[SerializeField] private UserSettingsView userSettingsView = new UserSettingsView();
14+
[SerializeField] private GitPathView gitPathView = new GitPathView();
1815
[SerializeField] private bool isBusy;
19-
[SerializeField] private bool isPublished;
2016

21-
public override void OnDataUpdate()
17+
public override void InitializeView(IView parent)
2218
{
23-
base.OnDataUpdate();
24-
MaybeUpdateData();
19+
base.InitializeView(parent);
20+
userSettingsView.InitializeView(this);
21+
gitPathView.InitializeView(this);
2522
}
2623

27-
public override void OnRepositoryChanged(IRepository oldRepository)
24+
public override void OnDataUpdate()
2825
{
29-
base.OnRepositoryChanged(oldRepository);
30-
Refresh();
26+
base.OnDataUpdate();
27+
28+
userSettingsView.OnDataUpdate();
29+
gitPathView.OnDataUpdate();
3130
}
3231

3332
public override void OnGUI()
@@ -61,6 +60,10 @@ public override void OnGUI()
6160
}
6261
EditorGUILayout.EndHorizontal();
6362

63+
gitPathView.OnGUI();
64+
65+
userSettingsView.OnGUI();
66+
6467
GUILayout.BeginVertical(Styles.GenericBoxStyle);
6568
{
6669
GUILayout.FlexibleSpace();
@@ -70,7 +73,7 @@ public override void OnGUI()
7073
GUILayout.BeginHorizontal();
7174
GUILayout.FlexibleSpace();
7275

73-
EditorGUI.BeginDisabledGroup(isBusy);
76+
EditorGUI.BeginDisabledGroup(IsBusy);
7477
{
7578
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
7679
{
@@ -90,14 +93,9 @@ public override void OnGUI()
9093
GUILayout.EndVertical();
9194
}
9295

93-
private void MaybeUpdateData()
94-
{
95-
isPublished = Repository != null && Repository.CurrentRemote.HasValue;
96-
}
97-
9896
public override bool IsBusy
9997
{
100-
get { return isBusy; }
98+
get { return isBusy || userSettingsView.IsBusy || gitPathView.IsBusy; }
10199
}
102100
}
103101
}

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
62
using UnityEditor;
73
using UnityEngine;
84

@@ -21,7 +17,6 @@ class UserSettingsView : Subview
2117

2218
[SerializeField] private string gitName;
2319
[SerializeField] private string gitEmail;
24-
2520
[SerializeField] private string newGitName;
2621
[SerializeField] private string newGitEmail;
2722
[SerializeField] private User cachedUser;
@@ -32,13 +27,6 @@ public override void OnDataUpdate()
3227
MaybeUpdateData();
3328
}
3429

35-
public override void OnRepositoryChanged(IRepository oldRepository)
36-
{
37-
base.OnRepositoryChanged(oldRepository);
38-
39-
Refresh();
40-
}
41-
4230
public override void OnGUI()
4331
{
4432
GUILayout.Label(GitConfigTitle, EditorStyles.boldLabel);
@@ -108,11 +96,6 @@ public override void OnGUI()
10896
EditorGUI.EndDisabledGroup();
10997
}
11098

111-
public override bool IsBusy
112-
{
113-
get { return isBusy; }
114-
}
115-
11699
private void MaybeUpdateData()
117100
{
118101
if (Repository == null)
@@ -154,5 +137,10 @@ private void MaybeUpdateData()
154137
newGitName = gitName = Repository.User.Name;
155138
newGitEmail = gitEmail = Repository.User.Email;
156139
}
140+
141+
public override bool IsBusy
142+
{
143+
get { return isBusy; }
144+
}
157145
}
158146
}

0 commit comments

Comments
 (0)