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

Commit 985c390

Browse files
authored
Merge pull request #387 from github-for-unity/ui/initialize-workflow
Initialize Workflow
2 parents 34b2cc8 + 39eb5da commit 985c390

File tree

6 files changed

+114
-119
lines changed

6 files changed

+114
-119
lines changed

src/GitHub.Api/Localization.resx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -286,12 +286,12 @@
286286
<value>Branch pushed</value>
287287
</data>
288288
<data name="InitializeRepositoryButtonText" xml:space="preserve">
289-
<value>Initialize repository</value>
289+
<value>Initialize a git repository for this project</value>
290290
</data>
291291
<data name="SwitchBranchTitle" xml:space="preserve">
292292
<value>Switch branch</value>
293293
</data>
294294
<data name="SwitchBranchFailedDescription" xml:space="preserve">
295295
<value>Could not switch to branch {0}</value>
296296
</data>
297-
</root>
297+
</root>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@
151151
<EmbeddedResource Include="IconsAndLogos\dot.png" />
152152
<EmbeddedResource Include="IconsAndLogos\dropdown-list-icon%402x.png" />
153153
<EmbeddedResource Include="IconsAndLogos\dropdown-list-icon.png" />
154+
<EmbeddedResource Include="IconsAndLogos\[email protected]" />
155+
<EmbeddedResource Include="IconsAndLogos\empty-state-init.png" />
154156
<EmbeddedResource Include="IconsAndLogos\favorite-branch-indicator.png" />
155157
<EmbeddedResource Include="IconsAndLogos\git-merge%402x.png" />
156158
<EmbeddedResource Include="IconsAndLogos\git-merge-light%402x.png" />
@@ -207,12 +209,12 @@
207209
</ItemGroup>
208210
<Import Project="..\..\..\..\..\common\nativelibraries.props" />
209211
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
210-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
212+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
211213
Other similar extension points exist, see Microsoft.Common.targets.
212214
<Target Name="BeforeBuild">
213215
</Target>
214216
<Target Name="AfterBuild">
215217
</Target>
216218
-->
217219
<Import Project="..\..\..\..\..\common\build.targets" />
218-
</Project>
220+
</Project>
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Styles
6969
commitFileAreaStyle,
7070
commitButtonStyle,
7171
textFieldStyle,
72+
boldCenteredLabel,
7273
centeredLabel,
7374
commitDescriptionFieldStyle,
7475
toggleMixedStyle,
@@ -94,6 +95,7 @@ class Styles
9495
localCommitIcon,
9596
repoIcon,
9697
lockIcon,
98+
emptyStateInit,
9799
dropdownListIcon;
98100

99101
public static Texture2D GetFileStatusIcon(GitFileStatus status, bool isLocked)
@@ -556,6 +558,22 @@ public static GUIStyle CenteredLabel
556558
}
557559
}
558560

561+
public static GUIStyle BoldCenteredLabel
562+
{
563+
get
564+
{
565+
if (boldCenteredLabel == null)
566+
{
567+
boldCenteredLabel = new GUIStyle(EditorStyles.boldLabel);
568+
boldCenteredLabel.name = "BoldCenteredLabelStyle";
569+
boldCenteredLabel.alignment = TextAnchor.MiddleCenter;
570+
boldCenteredLabel.wordWrap = true;
571+
}
572+
return boldCenteredLabel;
573+
}
574+
}
575+
576+
559577
public static GUIStyle CommitDescriptionFieldStyle
560578
{
561579
get
@@ -787,6 +805,19 @@ public static Texture2D LockIcon
787805
}
788806
}
789807

808+
public static Texture2D EmptyStateInit
809+
{
810+
get
811+
{
812+
if (emptyStateInit == null)
813+
{
814+
emptyStateInit = Utility.GetIcon("empty-state-init.png", "[email protected]");
815+
}
816+
return emptyStateInit;
817+
}
818+
819+
}
820+
790821
public static Texture2D DropdownListIcon
791822
{
792823
get

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

Lines changed: 44 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,123 +7,73 @@ namespace GitHub.Unity
77
[Serializable]
88
class InitProjectView : Subview
99
{
10-
private const string NoRepoTitle = "No Git repository found for this project";
11-
private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others.";
12-
private const string NoUserOrEmailError = "Name and Email must be configured in Settings";
13-
14-
[SerializeField] private UserSettingsView userSettingsView = new UserSettingsView();
15-
[SerializeField] private GitPathView gitPathView = new GitPathView();
10+
private const string NoRepoTitle = "To begin using GitHub, initialize a git repository";
11+
private const string NoUserOrEmailError = "Name and email not set in git. Go into the settings tab and enter the missing information";
1612

1713
[NonSerialized] private bool isBusy;
18-
19-
[NonSerialized] private string errorMessage;
2014
[NonSerialized] private bool isUserDataPresent;
15+
[NonSerialized] private bool hasCompletedInitialCheck;
2116
[NonSerialized] private bool userDataHasChanged;
2217

23-
public override void InitializeView(IView parent)
24-
{
25-
base.InitializeView(parent);
26-
27-
userSettingsView.InitializeView(this);
28-
gitPathView.InitializeView(this);
29-
30-
if (!string.IsNullOrEmpty(Environment.GitExecutablePath))
31-
{
32-
CheckForUser();
33-
}
34-
}
35-
3618
public override void OnEnable()
3719
{
3820
base.OnEnable();
39-
gitPathView.OnEnable();
4021
userDataHasChanged = Environment.GitExecutablePath != null;
4122
}
4223

43-
public override void OnDataUpdate()
44-
{
45-
base.OnDataUpdate();
46-
userSettingsView.OnDataUpdate();
47-
gitPathView.OnDataUpdate();
48-
}
49-
5024
public override void OnGUI()
5125
{
52-
var headerRect = EditorGUILayout.BeginHorizontal(Styles.HeaderBoxStyle);
26+
GUILayout.BeginVertical(Styles.GenericBoxStyle);
5327
{
54-
GUILayout.Space(5);
55-
GUILayout.BeginVertical(GUILayout.Width(16));
56-
{
57-
GUILayout.Space(5);
58-
59-
var iconRect = GUILayoutUtility.GetRect(new GUIContent(Styles.BigLogo), GUIStyle.none, GUILayout.Height(20), GUILayout.Width(20));
60-
iconRect.y = headerRect.center.y - (iconRect.height / 2);
61-
GUI.DrawTexture(iconRect, Styles.BigLogo, ScaleMode.ScaleToFit);
62-
63-
GUILayout.Space(5);
64-
}
65-
GUILayout.EndVertical();
66-
67-
GUILayout.Space(5);
28+
GUILayout.FlexibleSpace();
29+
GUILayout.Space(-140);
6830

69-
GUILayout.BeginVertical();
31+
GUILayout.BeginHorizontal();
7032
{
71-
var headerContent = new GUIContent(NoRepoTitle);
72-
var headerTitleRect = GUILayoutUtility.GetRect(headerContent, Styles.HeaderTitleStyle);
73-
headerTitleRect.y = headerRect.center.y - (headerTitleRect.height / 2);
74-
75-
GUI.Label(headerTitleRect, headerContent, Styles.HeaderTitleStyle);
33+
GUILayout.FlexibleSpace();
34+
GUILayout.Label(Styles.EmptyStateInit, GUILayout.MaxWidth(265), GUILayout.MaxHeight(136));
35+
GUILayout.FlexibleSpace();
7636
}
77-
GUILayout.EndVertical();
78-
}
79-
EditorGUILayout.EndHorizontal();
80-
81-
gitPathView.OnGUI();
82-
83-
userSettingsView.OnGUI();
84-
85-
GUILayout.BeginVertical(Styles.GenericBoxStyle);
86-
{
87-
GUILayout.FlexibleSpace();
37+
GUILayout.EndHorizontal();
8838

89-
GUILayout.Label(NoRepoDescription, Styles.CenteredLabel);
39+
GUILayout.Label(NoRepoTitle, Styles.BoldCenteredLabel);
40+
GUILayout.Space(4);
9041

9142
GUILayout.BeginHorizontal();
92-
GUILayout.FlexibleSpace();
93-
94-
EditorGUI.BeginDisabledGroup(IsBusy || !isUserDataPresent);
9543
{
96-
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
44+
GUILayout.FlexibleSpace();
45+
46+
EditorGUI.BeginDisabledGroup(IsBusy || !isUserDataPresent);
9747
{
98-
isBusy = true;
99-
Manager.InitializeRepository()
100-
.FinallyInUI(() => isBusy = false)
101-
.Start();
48+
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
49+
{
50+
isBusy = true;
51+
Manager.InitializeRepository()
52+
.FinallyInUI(() => isBusy = false)
53+
.Start();
54+
}
10255
}
103-
}
104-
EditorGUI.EndDisabledGroup();
56+
EditorGUI.EndDisabledGroup();
10557

106-
GUILayout.FlexibleSpace();
58+
GUILayout.FlexibleSpace();
59+
}
10760
GUILayout.EndHorizontal();
10861

109-
ShowErrorMessage();
62+
if (hasCompletedInitialCheck && !isUserDataPresent)
63+
{
64+
EditorGUILayout.Space();
65+
EditorGUILayout.HelpBox(NoUserOrEmailError, MessageType.Error);
66+
}
11067

11168
GUILayout.FlexibleSpace();
11269
}
11370
GUILayout.EndVertical();
11471
}
11572

116-
private void ShowErrorMessage()
73+
public override void OnDataUpdate()
11774
{
118-
if (errorMessage != null)
119-
{
120-
GUILayout.Space(Styles.BaseSpacing);
121-
GUILayout.BeginHorizontal();
122-
{
123-
GUILayout.Label(errorMessage, Styles.CenteredErrorLabel);
124-
}
125-
GUILayout.EndHorizontal();
126-
}
75+
base.OnDataUpdate();
76+
MaybeUpdateData();
12777
}
12878

12979
private void MaybeUpdateData()
@@ -137,26 +87,32 @@ private void MaybeUpdateData()
13787

13888
private void CheckForUser()
13989
{
90+
if (string.IsNullOrEmpty(Environment.GitExecutablePath))
91+
{
92+
Logger.Warning("No git exec cannot check for user");
93+
return;
94+
}
95+
96+
Logger.Trace("Checking for user");
14097
isBusy = true;
14198

14299
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, strings) => {
143100
var username = strings[0];
144101
var email = strings[1];
145102

146-
147103
isBusy = false;
148104
isUserDataPresent = success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email);
149-
errorMessage = isUserDataPresent ? null : NoUserOrEmailError;
105+
hasCompletedInitialCheck = true;
150106

151-
Logger.Trace("Finally: {0}", isUserDataPresent);
107+
Logger.Trace("User Present: {0}", isUserDataPresent);
152108

153109
Redraw();
154110
}).Start();
155111
}
156112

157113
public override bool IsBusy
158114
{
159-
get { return isBusy || userSettingsView.IsBusy || gitPathView.IsBusy; }
115+
get { return isBusy; }
160116
}
161117
}
162118
}

0 commit comments

Comments
 (0)