Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions src/GitHub.Api/Localization.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -286,12 +286,12 @@
<value>Branch pushed</value>
</data>
<data name="InitializeRepositoryButtonText" xml:space="preserve">
<value>Initialize repository</value>
<value>Initialize a git repository for this project</value>
</data>
<data name="SwitchBranchTitle" xml:space="preserve">
<value>Switch branch</value>
</data>
<data name="SwitchBranchFailedDescription" xml:space="preserve">
<value>Could not switch to branch {0}</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
<EmbeddedResource Include="IconsAndLogos\dot.png" />
<EmbeddedResource Include="IconsAndLogos\dropdown-list-icon%402x.png" />
<EmbeddedResource Include="IconsAndLogos\dropdown-list-icon.png" />
<EmbeddedResource Include="IconsAndLogos\empty-state-init@2x.png" />
<EmbeddedResource Include="IconsAndLogos\empty-state-init.png" />
<EmbeddedResource Include="IconsAndLogos\favorite-branch-indicator.png" />
<EmbeddedResource Include="IconsAndLogos\git-merge%402x.png" />
<EmbeddedResource Include="IconsAndLogos\git-merge-light%402x.png" />
Expand Down Expand Up @@ -207,12 +209,12 @@
</ItemGroup>
<Import Project="..\..\..\..\..\common\nativelibraries.props" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\..\..\..\..\common\build.targets" />
</Project>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Styles
commitFileAreaStyle,
commitButtonStyle,
textFieldStyle,
boldCenteredLabel,
centeredLabel,
commitDescriptionFieldStyle,
toggleMixedStyle,
Expand All @@ -94,6 +95,7 @@ class Styles
localCommitIcon,
repoIcon,
lockIcon,
emptyStateInit,
dropdownListIcon;

public static Texture2D GetFileStatusIcon(GitFileStatus status, bool isLocked)
Expand Down Expand Up @@ -556,6 +558,22 @@ public static GUIStyle CenteredLabel
}
}

public static GUIStyle BoldCenteredLabel
{
get
{
if (boldCenteredLabel == null)
{
boldCenteredLabel = new GUIStyle(EditorStyles.boldLabel);
boldCenteredLabel.name = "BoldCenteredLabelStyle";
boldCenteredLabel.alignment = TextAnchor.MiddleCenter;
boldCenteredLabel.wordWrap = true;
}
return boldCenteredLabel;
}
}


public static GUIStyle CommitDescriptionFieldStyle
{
get
Expand Down Expand Up @@ -787,6 +805,19 @@ public static Texture2D LockIcon
}
}

public static Texture2D EmptyStateInit
{
get
{
if (emptyStateInit == null)
{
emptyStateInit = Utility.GetIcon("empty-state-init.png", "empty-state-init@2x.png");
}
return emptyStateInit;
}

}

public static Texture2D DropdownListIcon
{
get
Expand Down
132 changes: 44 additions & 88 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,123 +7,73 @@ namespace GitHub.Unity
[Serializable]
class InitProjectView : Subview
{
private const string NoRepoTitle = "No Git repository found for this project";
private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others.";
private const string NoUserOrEmailError = "Name and Email must be configured in Settings";

[SerializeField] private UserSettingsView userSettingsView = new UserSettingsView();
[SerializeField] private GitPathView gitPathView = new GitPathView();
private const string NoRepoTitle = "To begin using GitHub, initialize a git repository";
private const string NoUserOrEmailError = "Name and email not set in git. Go into the settings tab and enter the missing information";

[NonSerialized] private bool isBusy;

[NonSerialized] private string errorMessage;
[NonSerialized] private bool isUserDataPresent;
[NonSerialized] private bool hasCompletedInitialCheck;
[NonSerialized] private bool userDataHasChanged;

public override void InitializeView(IView parent)
{
base.InitializeView(parent);

userSettingsView.InitializeView(this);
gitPathView.InitializeView(this);

if (!string.IsNullOrEmpty(Environment.GitExecutablePath))
{
CheckForUser();
}
}

public override void OnEnable()
{
base.OnEnable();
gitPathView.OnEnable();
userDataHasChanged = Environment.GitExecutablePath != null;
}

public override void OnDataUpdate()
{
base.OnDataUpdate();
userSettingsView.OnDataUpdate();
gitPathView.OnDataUpdate();
}

public override void OnGUI()
{
var headerRect = EditorGUILayout.BeginHorizontal(Styles.HeaderBoxStyle);
GUILayout.BeginVertical(Styles.GenericBoxStyle);
{
GUILayout.Space(5);
GUILayout.BeginVertical(GUILayout.Width(16));
{
GUILayout.Space(5);

var iconRect = GUILayoutUtility.GetRect(new GUIContent(Styles.BigLogo), GUIStyle.none, GUILayout.Height(20), GUILayout.Width(20));
iconRect.y = headerRect.center.y - (iconRect.height / 2);
GUI.DrawTexture(iconRect, Styles.BigLogo, ScaleMode.ScaleToFit);

GUILayout.Space(5);
}
GUILayout.EndVertical();

GUILayout.Space(5);
GUILayout.FlexibleSpace();
GUILayout.Space(-140);

GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
{
var headerContent = new GUIContent(NoRepoTitle);
var headerTitleRect = GUILayoutUtility.GetRect(headerContent, Styles.HeaderTitleStyle);
headerTitleRect.y = headerRect.center.y - (headerTitleRect.height / 2);

GUI.Label(headerTitleRect, headerContent, Styles.HeaderTitleStyle);
GUILayout.FlexibleSpace();
GUILayout.Label(Styles.EmptyStateInit, GUILayout.MaxWidth(265), GUILayout.MaxHeight(136));
GUILayout.FlexibleSpace();
}
GUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();

gitPathView.OnGUI();

userSettingsView.OnGUI();

GUILayout.BeginVertical(Styles.GenericBoxStyle);
{
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();

GUILayout.Label(NoRepoDescription, Styles.CenteredLabel);
GUILayout.Label(NoRepoTitle, Styles.BoldCenteredLabel);
GUILayout.Space(4);

GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

EditorGUI.BeginDisabledGroup(IsBusy || !isUserDataPresent);
{
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
GUILayout.FlexibleSpace();

EditorGUI.BeginDisabledGroup(IsBusy || !isUserDataPresent);
{
isBusy = true;
Manager.InitializeRepository()
.FinallyInUI(() => isBusy = false)
.Start();
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
{
isBusy = true;
Manager.InitializeRepository()
.FinallyInUI(() => isBusy = false)
.Start();
}
}
}
EditorGUI.EndDisabledGroup();
EditorGUI.EndDisabledGroup();

GUILayout.FlexibleSpace();
GUILayout.FlexibleSpace();
}
GUILayout.EndHorizontal();

ShowErrorMessage();
if (hasCompletedInitialCheck && !isUserDataPresent)
{
EditorGUILayout.Space();
EditorGUILayout.HelpBox(NoUserOrEmailError, MessageType.Error);
}

GUILayout.FlexibleSpace();
}
GUILayout.EndVertical();
}

private void ShowErrorMessage()
public override void OnDataUpdate()
{
if (errorMessage != null)
{
GUILayout.Space(Styles.BaseSpacing);
GUILayout.BeginHorizontal();
{
GUILayout.Label(errorMessage, Styles.CenteredErrorLabel);
}
GUILayout.EndHorizontal();
}
base.OnDataUpdate();
MaybeUpdateData();
}

private void MaybeUpdateData()
Expand All @@ -137,26 +87,32 @@ private void MaybeUpdateData()

private void CheckForUser()
{
if (string.IsNullOrEmpty(Environment.GitExecutablePath))
{
Logger.Warning("No git exec cannot check for user");
return;
}

Logger.Trace("Checking for user");
isBusy = true;

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


isBusy = false;
isUserDataPresent = success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email);
errorMessage = isUserDataPresent ? null : NoUserOrEmailError;
hasCompletedInitialCheck = true;

Logger.Trace("Finally: {0}", isUserDataPresent);
Logger.Trace("User Present: {0}", isUserDataPresent);

Redraw();
}).Start();
}

public override bool IsBusy
{
get { return isBusy || userSettingsView.IsBusy || gitPathView.IsBusy; }
get { return isBusy; }
}
}
}