This commit is contained in:
Andreia Gaita 2015-02-12 17:52:20 +01:00
Родитель 3dface7e29
Коммит 017a23d496
8 изменённых файлов: 33 добавлений и 63 удалений

Просмотреть файл

@ -3,6 +3,7 @@ using GitHub.Extensions;
using GitHub.Services;
using Octokit;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
@ -45,6 +46,7 @@ namespace GitHub.Api
}
catch // TODO: if the repo is private, then it'll throw
{
repositoryCache = new Repository() { HtmlUrl = String.Empty };
}
}
return repositoryCache;
@ -57,12 +59,14 @@ namespace GitHub.Api
return WikiProbeResult.NotFound;
var probe = wikiProbe.Value;
Debug.Assert(probe != null, "Lazy<Wiki> probe is not set, something is wrong.");
return await probe.AsyncProbe(repo);
}
public async Task<EnterpriseProbeResult> IsEnterprise()
{
var probe = enterpriseProbe.Value;
Debug.Assert(probe != null, "Lazy<Enterprise> probe is not set, something is wrong.");
return await probe.AsyncProbe(HostAddress.WebUri);
}
}

Просмотреть файл

@ -12,6 +12,7 @@ using Microsoft.TeamFoundation.Client;
using GitHub.Api;
using Microsoft.VisualStudio;
using System.Diagnostics;
using GitHub.Services;
namespace GitHub.VisualStudio
{
@ -76,12 +77,29 @@ namespace GitHub.VisualStudio
{
// enterprise probe
var ret = await SimpleApiClient.IsEnterprise();
visible = (ret == GitHub.Services.EnterpriseProbeResult.Ok);
visible = (ret == EnterpriseProbeResult.Ok);
}
}
return visible;
}
protected async void OpenInBrowser(Lazy<IBrowser> browser, string endpoint)
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
if (b == null)
return;
var repo = await SimpleApiClient.GetRepository();
var url = repo.HtmlUrl;
Debug.Assert(!string.IsNullOrEmpty(repo.HtmlUrl), "Could not get repository information");
if (string.IsNullOrEmpty(repo.HtmlUrl))
return;
var wiki = new Uri(repo.HtmlUrl + "/" + endpoint);
b.OpenUrl(wiki);
}
protected override void Dispose(bool disposing)
{

Просмотреть файл

@ -71,7 +71,6 @@ namespace GitHub.Exports
{
//log.Error("Really can't open the URL, even in IE", ex);
}
}
}
}

Просмотреть файл

@ -40,20 +40,9 @@ namespace GitHub.VisualStudio
base.ContextChanged(sender, e);
}
public override async void Execute()
public override void Execute()
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
var repo = await SimpleApiClient.GetRepository();
Debug.Assert(repo != null, "Could not load repository information.");
if (b == null || repo == null)
return;
var wiki = new Uri(repo.HtmlUrl + "/graphs");
b.OpenUrl(wiki);
OpenInBrowser(browser, "graphs");
base.Execute();
}

Просмотреть файл

@ -40,19 +40,9 @@ namespace GitHub.VisualStudio
base.ContextChanged(sender, e);
}
public override async void Execute()
public override void Execute()
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
var repo = await SimpleApiClient.GetRepository();
Debug.Assert(repo != null, "Could not load repository information.");
if (b == null || repo == null)
return;
var wiki = new Uri(repo.HtmlUrl + "/issues");
b.OpenUrl(wiki);
OpenInBrowser(browser, "issues");
base.Execute();
}

Просмотреть файл

@ -40,19 +40,9 @@ namespace GitHub.VisualStudio
base.ContextChanged(sender, e);
}
public override async void Execute()
public override void Execute()
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
var repo = await SimpleApiClient.GetRepository();
Debug.Assert(repo != null, "Could not load repository information.");
if (b == null || repo == null)
return;
var wiki = new Uri(repo.HtmlUrl + "/pulls");
b.OpenUrl(wiki);
OpenInBrowser(browser, "pulls");
base.Execute();
}

Просмотреть файл

@ -40,19 +40,9 @@ namespace GitHub.VisualStudio
base.ContextChanged(sender, e);
}
public override async void Execute()
public override void Execute()
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
var repo = await SimpleApiClient.GetRepository();
Debug.Assert(repo != null, "Could not load repository information.");
if (b == null || repo == null)
return;
var wiki = new Uri(repo.HtmlUrl + "/pulse");
b.OpenUrl(wiki);
OpenInBrowser(browser, "pulse");
base.Execute();
}

Просмотреть файл

@ -40,19 +40,9 @@ namespace GitHub.VisualStudio
base.ContextChanged(sender, e);
}
public override async void Execute()
public override void Execute()
{
var b = browser.Value;
Debug.Assert(b != null, "Could not create a browser helper instance.");
var repo = await SimpleApiClient.GetRepository();
Debug.Assert(repo != null, "Could not load repository information.");
if (b == null || repo == null)
return;
var wiki = new Uri(repo.HtmlUrl + "/wiki");
b.OpenUrl(wiki);
OpenInBrowser(browser, "wiki");
base.Execute();
}