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

Commit 8d08c3c

Browse files
authored
Merge pull request #374 from github/fixes/356-not-a-github-repository
Display a message when project isn't a git/github repository.
2 parents c877c85 + c47d50d commit 8d08c3c

21 files changed

+369
-20
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@
197197
<Compile Include="ViewModels\BaseViewModel.cs" />
198198
<Compile Include="Models\ConnectionRepositoryHostMap.cs" />
199199
<Compile Include="ViewModels\GistCreationViewModel.cs" />
200+
<Compile Include="ViewModels\NotAGitRepositoryViewModel.cs" />
201+
<Compile Include="ViewModels\NotAGitHubRepositoryViewModel.cs" />
200202
<Compile Include="ViewModels\LoggedOutViewModel.cs" />
201203
<Compile Include="ViewModels\LogoutRequiredViewModel.cs" />
202204
<Compile Include="ViewModels\PullRequestCreationViewModel.cs" />
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using GitHub.Exports;
4+
using GitHub.Models;
5+
using GitHub.Services;
6+
using GitHub.UI;
7+
using ReactiveUI;
8+
9+
namespace GitHub.ViewModels
10+
{
11+
/// <summary>
12+
/// The view model for the "Not a GitHub repository" view in the GitHub pane.
13+
/// </summary>
14+
[ExportViewModel(ViewType = UIViewType.NotAGitHubRepository)]
15+
[PartCreationPolicy(CreationPolicy.NonShared)]
16+
public class NotAGitHubRepositoryViewModel : BaseViewModel, INotAGitHubRepositoryViewModel
17+
{
18+
ITeamExplorerServices teamExplorerServices;
19+
20+
/// <summary>
21+
/// Initializes a new instance of the <see cref="NotAGitHubRepositoryViewModel"/> class.
22+
/// </summary>
23+
[ImportingConstructor]
24+
public NotAGitHubRepositoryViewModel(ITeamExplorerServices teamExplorerServices)
25+
{
26+
this.teamExplorerServices = teamExplorerServices;
27+
Publish = ReactiveCommand.Create();
28+
Publish.Subscribe(_ => OnPublish());
29+
}
30+
31+
/// <summary>
32+
/// Gets the command executed when the user clicks the "Publish to GitHub" link.
33+
/// </summary>
34+
public IReactiveCommand<object> Publish { get; }
35+
36+
/// <summary>
37+
/// Called when the <see cref="Publish"/> command is executed.
38+
/// </summary>
39+
private void OnPublish()
40+
{
41+
teamExplorerServices.ShowPublishSection();
42+
}
43+
}
44+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using GitHub.Exports;
4+
using GitHub.Models;
5+
using GitHub.Services;
6+
using GitHub.UI;
7+
using ReactiveUI;
8+
9+
namespace GitHub.ViewModels
10+
{
11+
/// <summary>
12+
/// The view model for the "Not a Git repository" view in the GitHub pane.
13+
/// </summary>
14+
[ExportViewModel(ViewType = UIViewType.NotAGitRepository)]
15+
[PartCreationPolicy(CreationPolicy.NonShared)]
16+
public class NotAGitRepositoryViewModel : BaseViewModel, INotAGitRepositoryViewModel
17+
{
18+
}
19+
}

src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
<Compile Include="Services\IGistPublishService.cs" />
9898
<Compile Include="ViewModels\IGistCreationViewModel.cs" />
9999
<Compile Include="Services\NotificationDispatcher.cs" />
100+
<Compile Include="ViewModels\INotAGitRepositoryViewModel.cs" />
101+
<Compile Include="ViewModels\INotAGitHubRepositoryViewModel.cs" />
100102
<Compile Include="ViewModels\ILoggedOutViewModel.cs" />
101103
<Compile Include="ViewModels\ILogoutRequiredViewModel.cs" />
102104
<Compile Include="ViewModels\ILoginControlViewModel.cs" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using ReactiveUI;
2+
3+
namespace GitHub.ViewModels
4+
{
5+
/// <summary>
6+
/// Defines the view model for the "Sign in to GitHub" view in the GitHub pane.
7+
/// </summary>
8+
public interface INotAGitHubRepositoryViewModel : IViewModel
9+
{
10+
/// <summary>
11+
/// Gets the command executed when the user clicks the "Publish to GitHub" link.
12+
/// </summary>
13+
IReactiveCommand<object> Publish { get; }
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace GitHub.ViewModels
2+
{
3+
/// <summary>
4+
/// Defines the view model for the "Not a git repository" view in the GitHub pane.
5+
/// </summary>
6+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
7+
public interface INotAGitRepositoryViewModel : IViewModel
8+
{
9+
}
10+
}

src/GitHub.Exports/Exports/ExportMetadata.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public enum UIViewType
2525
PRCreation,
2626
LogoutRequired,
2727
GitHubPane,
28-
LoggedOut
28+
LoggedOut,
29+
NotAGitRepository,
30+
NotAGitHubRepository,
2931
}
3032

3133
public enum MenuType

src/GitHub.Exports/Services/ITeamExplorerServices.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace GitHub.Services
44
{
55
public interface ITeamExplorerServices : INotificationService
66
{
7+
void ShowPublishSection();
78
void ClearNotifications();
89
}
910
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using System;
22
using System.ComponentModel.Composition;
33
using System.Windows.Input;
4+
using GitHub.Extensions;
5+
using GitHub.VisualStudio.TeamExplorer.Sync;
46
using Microsoft.TeamFoundation.Controls;
57
using Microsoft.VisualStudio.Shell;
6-
using GitHub.Extensions;
78

89
namespace GitHub.Services
910
{
@@ -27,6 +28,14 @@ public TeamExplorerServices([Import(typeof(SVsServiceProvider))] IServiceProvide
2728
this.serviceProvider = serviceProvider;
2829
}
2930

31+
public void ShowPublishSection()
32+
{
33+
var te = serviceProvider.TryGetService<ITeamExplorer>();
34+
var foo = te.NavigateToPage(new Guid(TeamExplorerPageIds.GitCommits), null);
35+
var publish = foo?.GetSection(new Guid(GitHubPublishSection.GitHubPublishSectionId)) as GitHubPublishSection;
36+
publish?.ShowPublish();
37+
}
38+
3039
public void ShowMessage(string message)
3140
{
3241
manager = serviceProvider.TryGetService<ITeamExplorer>() as ITeamExplorerNotificationManager;

src/GitHub.TeamFoundation.14/Sync/GitHubPublishSection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void StartFlow(UIControllerFlow controllerFlow)
111111
uiProvider.RunUI();
112112
}
113113

114-
void ShowPublish()
114+
public void ShowPublish()
115115
{
116116
IsBusy = true;
117117
var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();

0 commit comments

Comments
 (0)