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

Commit 440a7a4

Browse files
committed
Add links to documentation.
Adds a welcome message with a link to docs to team explorer (but only if Team Explorer isn't already displaying the "Install 3rd Party Tools" message) and a Help button to the GitHub pane.
1 parent dd0c5ea commit 440a7a4

File tree

20 files changed

+259
-14
lines changed

20 files changed

+259
-14
lines changed

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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ public StatusBarNotificationService([Import(typeof(SVsServiceProvider))] IServic
2020
this.serviceProvider = serviceProvider;
2121
}
2222

23+
public void HideNotification(Guid guid)
24+
{
25+
throw new NotImplementedException();
26+
}
27+
28+
public bool IsNotificationVisible(Guid guid)
29+
{
30+
throw new NotImplementedException();
31+
}
32+
2333
public void ShowError(string message)
2434
{
2535
ShowText(message);
@@ -30,7 +40,7 @@ public void ShowMessage(string message)
3040
ShowText(message);
3141
}
3242

33-
public void ShowMessage(string message, ICommand command)
43+
public void ShowMessage(string message, ICommand command, bool showToolTips = true, Guid guid = default(Guid))
3444
{
3545
ShowText(message);
3646
}

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,9 @@
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;
1619

1720
namespace GitHub.VisualStudio.TeamExplorer.Home
1821
{
@@ -21,22 +24,59 @@ namespace GitHub.VisualStudio.TeamExplorer.Home
2124
public class GitHubHomeSection : TeamExplorerSectionBase, IGitHubHomeSection
2225
{
2326
public const string GitHubHomeSectionId = "72008232-2104-4FA0-A189-61B0C6F91198";
24-
IVisualStudioBrowser visualStudioBrowser;
27+
const string TrainingUrl = "https://services.github.com/on-demand/windows/visual-studio";
28+
const string DocsUrl = "https://visualstudio.github.com/docs";
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("DF785C7C-8454-4836-9686-D1C4A01D0BB9"));
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("C529627F-8AA6-4FDB-82EB-4BFB7DB753C3");
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(DocsUrl));
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
}

src/GitHub.VisualStudio.UI/Resources.Designer.cs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.VisualStudio.UI/Resources.resx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,9 @@
378378
<data name="OpenPROnGitHubToolTip" xml:space="preserve">
379379
<value>View Pull Request on GitHub</value>
380380
</data>
381+
<data name="TeamExplorerWelcomeMessage" xml:space="preserve">
382+
<value>Thanks for installing GitHub for Visual Studio. Why not take a look at our [training](show-training) or [documentation](show-docs)?
383+
384+
[Don't show this again](dont-show-again)</value>
385+
</data>
381386
</root>

0 commit comments

Comments
 (0)