Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit c4d3adc

Browse files
authored
Merge pull request #941 from github/feature/docs-links
WIP: Add links to documentation.
2 parents dd0c5ea + fc39aab commit c4d3adc

File tree

22 files changed

+269
-16
lines changed

22 files changed

+269
-16
lines changed

src/GitHub.App/Info/GitHubUrls.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,10 @@ public static string Billing(this IAccount account)
9494
: string.Format(CultureInfo.InvariantCulture,
9595
GitHub + "/organizations/{0}/settings/billing", account.Login);
9696
}
97+
98+
/// <summary>
99+
/// The URL for the GitHub for Visual Studio documentation.
100+
/// </summary>
101+
public const string Documentation = "https://github.com/github/VisualStudio/tree/master/docs";
97102
}
98103
}

src/GitHub.Exports.Reactive/Services/NotificationDispatcher.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ public void ShowMessage(string message)
5454
handler?.ShowMessage(message);
5555
}
5656

57-
public void ShowMessage(string message, ICommand command)
57+
public void ShowMessage(string message, ICommand command, bool showToolTips = true, Guid guid = default(Guid))
5858
{
5959
notifications.OnNext(new Notification(message, Notification.NotificationType.Message, command));
6060
var handler = notificationHandlers.TryPeek();
61-
handler?.ShowMessage(message, command);
61+
handler?.ShowMessage(message, command, showToolTips, guid);
6262
}
6363

6464
public void ShowWarning(string message)
6565
{
6666
notifications.OnNext(new Notification(message, Notification.NotificationType.Warning));
6767
var handler = notificationHandlers.TryPeek();
68-
handler.ShowWarning(message);
68+
handler?.ShowWarning(message);
6969
}
7070

7171
public void ShowError(string message)
@@ -75,6 +75,18 @@ public void ShowError(string message)
7575
handler?.ShowError(message);
7676
}
7777

78+
public void HideNotification(Guid guid)
79+
{
80+
var handler = notificationHandlers.TryPeek();
81+
handler?.HideNotification(guid);
82+
}
83+
84+
public bool IsNotificationVisible(Guid guid)
85+
{
86+
var handler = notificationHandlers.TryPeek();
87+
return handler?.IsNotificationVisible(guid) ?? false;
88+
}
89+
7890
bool disposed; // To detect redundant calls
7991
void Dispose(bool disposing)
8092
{

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class UsageModel
2727
public int NumberOfForkPullRequestsCheckedOut { get; set; }
2828
public int NumberOfForkPullRequestPulls { get; set; }
2929
public int NumberOfForkPullRequestPushes { get; set; }
30+
public int NumberOfWelcomeDocsClicks { get; set; }
31+
public int NumberOfWelcomeTrainingClicks { get; set; }
32+
public int NumberOfGitHubPaneHelpClicks { get; set; }
3033

3134
public UsageModel Clone(bool includeWeekly, bool includeMonthly)
3235
{
@@ -55,6 +58,9 @@ public UsageModel Clone(bool includeWeekly, bool includeMonthly)
5558
NumberOfForkPullRequestsCheckedOut = NumberOfForkPullRequestsCheckedOut,
5659
NumberOfForkPullRequestPulls = NumberOfForkPullRequestPulls,
5760
NumberOfForkPullRequestPushes = NumberOfForkPullRequestPushes,
61+
NumberOfWelcomeDocsClicks = NumberOfWelcomeDocsClicks,
62+
NumberOfWelcomeTrainingClicks = NumberOfWelcomeTrainingClicks,
63+
NumberOfGitHubPaneHelpClicks = NumberOfGitHubPaneHelpClicks,
5864
};
5965
}
6066
}

src/GitHub.Exports/Services/INotificationService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Windows.Input;
23

34
namespace GitHub.Services
@@ -9,8 +10,10 @@ namespace GitHub.Services
910
public interface INotificationService
1011
{
1112
void ShowMessage(string message);
12-
void ShowMessage(string message, ICommand command);
13+
void ShowMessage(string message, ICommand command, bool showToolTips = true, Guid guid = default(Guid));
1314
void ShowWarning(string message);
1415
void ShowError(string message);
16+
void HideNotification(Guid guid);
17+
bool IsNotificationVisible(Guid guid);
1518
}
1619
}

src/GitHub.Exports/Services/IUsageTracker.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ public interface IUsageTracker
1919
Task IncrementPullRequestCheckOutCount(bool fork);
2020
Task IncrementPullRequestPullCount(bool fork);
2121
Task IncrementPullRequestPushCount(bool fork);
22+
Task IncrementWelcomeDocsClicks();
23+
Task IncrementWelcomeTrainingClicks();
24+
Task IncrementGitHubPaneHelpClicks();
2225
}
2326
}

src/GitHub.Exports/Services/StatusBarNotificationService.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ public StatusBarNotificationService([Import(typeof(SVsServiceProvider))] IServic
2020
this.serviceProvider = serviceProvider;
2121
}
2222

23+
public void HideNotification(Guid guid)
24+
{
25+
// status bar only shows text, this is a noop
26+
}
27+
28+
public bool IsNotificationVisible(Guid guid)
29+
{
30+
// it's only text, there's no way of checking
31+
return false;
32+
}
33+
2334
public void ShowError(string message)
2435
{
2536
ShowText(message);
@@ -30,7 +41,7 @@ public void ShowMessage(string message)
3041
ShowText(message);
3142
}
3243

33-
public void ShowMessage(string message, ICommand command)
44+
public void ShowMessage(string message, ICommand command, bool showToolTips = true, Guid guid = default(Guid))
3445
{
3546
ShowText(message);
3647
}

src/GitHub.Exports/Settings/Guids.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public static class Guids
1212
public const string GitHubServiceProviderId = "76909E1A-9D58-41AB-8957-C26B9550787B";
1313
public const string StartPagePackageId = "3b764d23-faf7-486f-94c7-b3accc44a70e";
1414
public const string CodeContainerProviderId = "6CE146CB-EF57-4F2C-A93F-5BA685317660";
15+
public const string TeamExplorerWelcomeMessage = "C529627F-8AA6-4FDB-82EB-4BFB7DB753C3";
1516

1617
// VisualStudio IDs
1718
public const string GitSccProviderId = "11B8E6D7-C08B-4385-B321-321078CDD1F8";
19+
public const string TeamExplorerInstall3rdPartyGitTools = "DF785C7C-8454-4836-9686-D1C4A01D0BB9";
1820
}
1921
}

src/GitHub.Exports/Settings/generated/IPackageSettings.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"type": "object",
1313
"typename": "UIState",
1414
"default": 'null'
15-
}
15+
},
16+
{
17+
"name": "HideTeamExplorerWelcomeMessage",
18+
"type": "bool",
19+
"default": 'false'
20+
}
1621
]
1722
}
1823
*/
@@ -26,5 +31,6 @@ public interface IPackageSettings : INotifyPropertyChanged
2631
void Save();
2732
bool CollectMetrics { get; set; }
2833
UIState UIState { get; set; }
34+
bool HideTeamExplorerWelcomeMessage { get; set; }
2935
}
3036
}

src/GitHub.TeamFoundation.14/Home/GitHubHomeSection.cs

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
using GitHub.Extensions;
1414
using System.Windows.Input;
1515
using ReactiveUI;
16+
using GitHub.VisualStudio.UI;
17+
using GitHub.Settings;
18+
using System.Windows.Threading;
19+
using GitHub.Info;
1620

1721
namespace GitHub.VisualStudio.TeamExplorer.Home
1822
{
@@ -21,22 +25,58 @@ namespace GitHub.VisualStudio.TeamExplorer.Home
2125
public class GitHubHomeSection : TeamExplorerSectionBase, IGitHubHomeSection
2226
{
2327
public const string GitHubHomeSectionId = "72008232-2104-4FA0-A189-61B0C6F91198";
24-
IVisualStudioBrowser visualStudioBrowser;
28+
const string TrainingUrl = "https://services.github.com/on-demand/windows/visual-studio";
29+
30+
readonly IVisualStudioBrowser visualStudioBrowser;
31+
readonly ITeamExplorerServices teamExplorerServices;
32+
readonly IPackageSettings settings;
33+
readonly IUsageTracker usageTracker;
2534

2635
[ImportingConstructor]
2736
public GitHubHomeSection(IGitHubServiceProvider serviceProvider,
28-
ISimpleApiClientFactory apiFactory, ITeamExplorerServiceHolder holder,
29-
IVisualStudioBrowser visualStudioBrowser)
37+
ISimpleApiClientFactory apiFactory,
38+
ITeamExplorerServiceHolder holder,
39+
IVisualStudioBrowser visualStudioBrowser,
40+
ITeamExplorerServices teamExplorerServices,
41+
IPackageSettings settings,
42+
IUsageTracker usageTracker)
3043
: base(serviceProvider, apiFactory, holder)
3144
{
3245
Title = "GitHub";
3346
View = new GitHubHomeContent();
3447
View.DataContext = this;
3548
this.visualStudioBrowser = visualStudioBrowser;
49+
this.teamExplorerServices = teamExplorerServices;
50+
this.settings = settings;
51+
this.usageTracker = usageTracker;
3652

3753
var openOnGitHub = ReactiveCommand.Create();
3854
openOnGitHub.Subscribe(_ => DoOpenOnGitHub());
3955
OpenOnGitHub = openOnGitHub;
56+
57+
// We want to display a welcome message but only if Team Explorer isn't
58+
// already displaying the "Install 3rd Party Tools" message. To do this
59+
// we need to set a timer and check in the tick as at this point the message
60+
// won't be initialized.
61+
if (!settings.HideTeamExplorerWelcomeMessage)
62+
{
63+
var timer = new DispatcherTimer();
64+
timer.Interval = new TimeSpan(10);
65+
timer.Tick += (s, e) =>
66+
{
67+
timer.Stop();
68+
if (!IsGitToolsMessageVisible())
69+
{
70+
ShowWelcomeMessage();
71+
}
72+
};
73+
timer.Start();
74+
}
75+
}
76+
77+
bool IsGitToolsMessageVisible()
78+
{
79+
return teamExplorerServices.IsNotificationVisible(new Guid(Guids.TeamExplorerInstall3rdPartyGitTools));
4080
}
4181

4282
protected async override void RepoChanged(bool changed)
@@ -107,6 +147,36 @@ void DoOpenOnGitHub()
107147
visualStudioBrowser?.OpenUrl(ActiveRepo.CloneUrl.ToRepositoryUrl());
108148
}
109149

150+
void ShowWelcomeMessage()
151+
{
152+
var welcomeMessageGuid = new Guid(Guids.TeamExplorerWelcomeMessage);
153+
teamExplorerServices.ShowMessage(
154+
Resources.TeamExplorerWelcomeMessage,
155+
new RelayCommand(o =>
156+
{
157+
var str = o.ToString();
158+
159+
switch (str)
160+
{
161+
case "show-training":
162+
visualStudioBrowser.OpenUrl(new Uri(TrainingUrl));
163+
usageTracker.IncrementWelcomeTrainingClicks().Forget();
164+
break;
165+
case "show-docs":
166+
visualStudioBrowser.OpenUrl(new Uri(GitHubUrls.Documentation));
167+
usageTracker.IncrementWelcomeDocsClicks().Forget();
168+
break;
169+
case "dont-show-again":
170+
teamExplorerServices.HideNotification(welcomeMessageGuid);
171+
settings.HideTeamExplorerWelcomeMessage = true;
172+
settings.Save();
173+
break;
174+
}
175+
}),
176+
false,
177+
welcomeMessageGuid);
178+
}
179+
110180
protected GitHubHomeContent View
111181
{
112182
get { return SectionContent as GitHubHomeContent; }

src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ public void ShowMessage(string message)
4343
manager?.ShowNotification(message, NotificationType.Information, NotificationFlags.None, null, default(Guid));
4444
}
4545

46-
public void ShowMessage(string message, ICommand command)
46+
public void ShowMessage(string message, ICommand command, bool showToolTips = true, Guid guid = default(Guid))
4747
{
4848
manager = serviceProvider.GetService<ITeamExplorer, ITeamExplorerNotificationManager>();
49-
manager?.ShowNotification(message, NotificationType.Information, NotificationFlags.None, command, default(Guid));
49+
manager?.ShowNotification(
50+
message,
51+
NotificationType.Information,
52+
showToolTips ? NotificationFlags.None : NotificationFlags.NoTooltips,
53+
command,
54+
guid);
5055
}
5156

5257
public void ShowWarning(string message)
@@ -61,10 +66,22 @@ public void ShowError(string message)
6166
manager?.ShowNotification(message, NotificationType.Error, NotificationFlags.None, null, default(Guid));
6267
}
6368

69+
public void HideNotification(Guid guid)
70+
{
71+
manager = serviceProvider.GetService<ITeamExplorer, ITeamExplorerNotificationManager>();
72+
manager?.HideNotification(guid);
73+
}
74+
6475
public void ClearNotifications()
6576
{
6677
manager = serviceProvider.GetService<ITeamExplorer, ITeamExplorerNotificationManager>();
6778
manager?.ClearNotifications();
6879
}
80+
81+
public bool IsNotificationVisible(Guid guid)
82+
{
83+
manager = serviceProvider.GetService<ITeamExplorer, ITeamExplorerNotificationManager>();
84+
return manager?.IsNotificationVisible(guid) ?? false;
85+
}
6986
}
7087
}

0 commit comments

Comments
 (0)