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

A dedicated view to initialize the project #252

Merged
merged 29 commits into from
Sep 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
19a7059
Start of an InitProjectView
StanleyGoldman Aug 30, 2017
5811cef
Merge branch 'fixes/remove-unused-code' into enhancements/initialize-…
StanleyGoldman Aug 30, 2017
627ae7e
Fixing some formatting
StanleyGoldman Aug 30, 2017
1818a69
Some refactoring and some changes that don't work yet
StanleyGoldman Aug 30, 2017
d20642b
Merge branch 'fixes/refactor-window' into enhancements/initialize-view
StanleyGoldman Sep 6, 2017
de938b3
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 6, 2017
0be9c3d
Getting the initialize project display working
StanleyGoldman Aug 31, 2017
1737049
Removing unused variable
StanleyGoldman Aug 31, 2017
0a64264
Fixing Window.MaybeUpdateData not to return true every time when Repo…
StanleyGoldman Aug 31, 2017
14a24cf
Changing activeTab using nextTab at the right time
StanleyGoldman Aug 31, 2017
bb5494c
Merge branch 'fixes/refactor-window' into enhancements/initialize-view
StanleyGoldman Sep 6, 2017
025dc19
Spacing fix after rebase
StanleyGoldman Sep 6, 2017
ea6234d
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 6, 2017
c16ae0c
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 8, 2017
750dcc7
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 11, 2017
a843dca
Adding missing IsBusy property
StanleyGoldman Sep 11, 2017
0164af3
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 14, 2017
594d6e6
Updating Window to give InitializeView its own tab
StanleyGoldman Sep 14, 2017
df2e7ee
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 18, 2017
517ae58
Merge remote-tracking branch 'remotes/origin/master' into enhancement…
StanleyGoldman Sep 18, 2017
24aa102
Update after merge
StanleyGoldman Sep 18, 2017
5a2be0e
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 19, 2017
19d18f7
Relayout file
shana Sep 20, 2017
62bc3b6
Removing extra spaces
StanleyGoldman Sep 20, 2017
f9bd4fc
Making nextTab not nullable
StanleyGoldman Sep 20, 2017
d47246d
Changing where the tabs get swtiched; Inlining some methods for clarity
StanleyGoldman Sep 20, 2017
d4f96d9
Cleanup the switching of the tabs
shana Sep 20, 2017
1326949
Merge pull request #332 from github-for-unity/shana/more-of-the-initi…
StanleyGoldman Sep 20, 2017
5dc3f6d
Merge branch 'master' into enhancements/initialize-view
StanleyGoldman Sep 20, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="UI\IView.cs" />
<Compile Include="UI\LoadingView.cs" />
<Compile Include="UI\PublishView.cs" />
<Compile Include="UI\InitProjectView.cs" />
<Compile Include="UI\UserSettingsView.cs" />
<Compile Include="UI\GitPathView.cs" />
<Compile Include="UI\SettingsView.cs" />
Expand Down
30 changes: 10 additions & 20 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BaseWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ public virtual void Initialize(IApplicationManager applicationManager)
Logger.Trace("Initialize ApplicationManager:{0} Initialized:{1}", applicationManager, initialized);
}

public void InitializeWindow(IApplicationManager applicationManager)
public void InitializeWindow(IApplicationManager applicationManager, bool requiresRedraw = true)
{
if (inLayout)
{
initializeWasCalled = true;
cachedManager = applicationManager;
return;
}

initialized = true;
initializeWasCalled = true;
Manager = applicationManager;
cachedRepository = Environment.Repository;
initialized = true;
Initialize(applicationManager);
OnRepositoryChanged(null);
Redraw();
if (requiresRedraw)
Redraw();
}

public virtual void Redraw()
Expand All @@ -51,14 +45,14 @@ public virtual void Awake()
{
Logger.Trace("Awake Initialized:{0}", initialized);
if (!initialized)
InitializeWindow(EntryPoint.ApplicationManager);
InitializeWindow(EntryPoint.ApplicationManager, false);
}

public virtual void OnEnable()
{
Logger.Trace("OnEnable Initialized:{0}", initialized);
if (!initialized)
InitializeWindow(EntryPoint.ApplicationManager);
InitializeWindow(EntryPoint.ApplicationManager, false);
}

public virtual void OnDisable()
Expand All @@ -81,8 +75,9 @@ private void OnGUI()
{
if (Event.current.type == EventType.layout)
{
if (cachedRepository != Environment.Repository)
if (cachedRepository != Environment.Repository || initializeWasCalled)
{
initializeWasCalled = false;
OnRepositoryChanged(cachedRepository);
cachedRepository = Environment.Repository;
}
Expand All @@ -95,11 +90,6 @@ private void OnGUI()
if (Event.current.type == EventType.repaint)
{
inLayout = false;
if (initializeWasCalled)
{
initializeWasCalled = false;
InitializeWindow(cachedManager);
}
}
}

Expand All @@ -113,7 +103,7 @@ public virtual void OnSelectionChange()
public IApplicationManager Manager { get; private set; }
public abstract bool IsBusy { get; }
public IRepository Repository { get { return inLayout ? cachedRepository : Environment.Repository; } }
public bool HasRepository { get { return Environment.RepositoryPath != null; } }
public bool HasRepository { get { return Repository != null; } }

protected ITaskManager TaskManager { get { return Manager.TaskManager; } }
protected IGitClient GitClient { get { return Manager.GitClient; } }
Expand Down
68 changes: 0 additions & 68 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class HistoryView : Subview
private const string PushConfirmCancel = "Cancel";
private const string CommitDetailsTitle = "Commit details";
private const string ClearSelectionButton = "×";
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 PublishButton = "Publish";
private const string FetchActionTitle = "Fetch Changes";
private const string FetchButtonText = "Fetch";
Expand Down Expand Up @@ -116,12 +114,6 @@ public override void OnSelectionChange()

public override void OnGUI()
{
if (!HasRepository)
{
DoOfferToInitializeRepositoryGUI();
return;
}

OnEmbeddedGUI();
}

Expand Down Expand Up @@ -223,66 +215,6 @@ private void MaybeUpdateData()
}
}

private void DoOfferToInitializeRepositoryGUI()
{
var headerRect = EditorGUILayout.BeginHorizontal(Styles.HeaderBoxStyle);
{
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.BeginVertical();
{
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.EndVertical();
}
EditorGUILayout.EndHorizontal();

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

GUILayout.Label(NoRepoDescription, Styles.CenteredLabel);

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

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

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

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

public void OnEmbeddedGUI()
{
// History toolbar
Expand Down
103 changes: 103 additions & 0 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/InitProjectView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#pragma warning disable 649

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;

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.";

[SerializeField] private bool isBusy;
[SerializeField] private bool isPublished;

public override void OnDataUpdate()
{
base.OnDataUpdate();
MaybeUpdateData();
}

public override void OnRepositoryChanged(IRepository oldRepository)
{
base.OnRepositoryChanged(oldRepository);
Refresh();
}

public override void OnGUI()
{
var headerRect = EditorGUILayout.BeginHorizontal(Styles.HeaderBoxStyle);
{
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.BeginVertical();
{
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.EndVertical();
}
EditorGUILayout.EndHorizontal();

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

GUILayout.Label(NoRepoDescription, Styles.CenteredLabel);

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

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

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

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

private void MaybeUpdateData()
{
isPublished = Repository != null && Repository.CurrentRemote.HasValue;
}

public override bool IsBusy
{
get { return isBusy; }
}
}
}
Loading