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

Commit a30727c

Browse files
committed
Display message when project is not a repository
When the GitHub pane is open and the project is not a git repository, display a (placeholder) message.
1 parent bd791b9 commit a30727c

File tree

13 files changed

+165
-19
lines changed

13 files changed

+165
-19
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
<Compile Include="ViewModels\BaseViewModel.cs" />
199199
<Compile Include="Models\ConnectionRepositoryHostMap.cs" />
200200
<Compile Include="ViewModels\GistCreationViewModel.cs" />
201+
<Compile Include="ViewModels\NotAGitRepositoryViewModel.cs" />
201202
<Compile Include="ViewModels\NotAGitHubRepositoryViewModel.cs" />
202203
<Compile Include="ViewModels\LoggedOutViewModel.cs" />
203204
<Compile Include="ViewModels\LogoutRequiredViewModel.cs" />
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<Compile Include="Services\IGistPublishService.cs" />
9898
<Compile Include="ViewModels\IGistCreationViewModel.cs" />
9999
<Compile Include="Services\NotificationDispatcher.cs" />
100+
<Compile Include="ViewModels\INotAGitRepositoryViewModel.cs" />
100101
<Compile Include="ViewModels\INotAGitHubRepositoryViewModel.cs" />
101102
<Compile Include="ViewModels\ILoggedOutViewModel.cs" />
102103
<Compile Include="ViewModels\ILogoutRequiredViewModel.cs" />

src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Reactive;
3-
using ReactiveUI;
1+
using ReactiveUI;
42

53
namespace GitHub.ViewModels
64
{
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public enum UIViewType
2626
LogoutRequired,
2727
GitHubPane,
2828
LoggedOut,
29+
NotAGitRepository,
2930
NotAGitHubRepository,
3031
}
3132

src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using GitHub.VisualStudio.Helpers;
99
using NullGuard;
1010
using GitHub.ViewModels;
11+
using GitHub.VisualStudio.UI;
1112

1213
namespace GitHub.VisualStudio.Base
1314
{
@@ -98,22 +99,41 @@ protected virtual void RepoChanged(bool changed)
9899
}
99100
}
100101

101-
protected async Task<bool> IsAGitHubRepo()
102+
protected async Task<RepositoryOrigin> GetRepositoryOrigin()
102103
{
104+
if (ActiveRepo == null)
105+
return RepositoryOrigin.NonGitRepository;
106+
103107
var uri = ActiveRepoUri;
104108
if (uri == null)
105-
return false;
109+
return RepositoryOrigin.Other;
106110

107111
Debug.Assert(apiFactory != null, "apiFactory cannot be null. Did you call the right constructor?");
108112
SimpleApiClient = apiFactory.Create(uri);
109113

110114
var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl());
111-
if (!isdotcom)
115+
116+
if (isdotcom)
117+
{
118+
return RepositoryOrigin.DotCom;
119+
}
120+
else
112121
{
113122
var repo = await SimpleApiClient.GetRepository();
114-
return (repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise();
123+
124+
if ((repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise())
125+
{
126+
return RepositoryOrigin.Enterprise;
127+
}
115128
}
116-
return isdotcom;
129+
130+
return RepositoryOrigin.Other;
131+
}
132+
133+
protected async Task<bool> IsAGitHubRepo()
134+
{
135+
var origin = await GetRepositoryOrigin();
136+
return origin == RepositoryOrigin.DotCom || origin == RepositoryOrigin.Enterprise;
117137
}
118138

119139
bool disposed;

src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<Compile Include="Base\TeamExplorerItemBase.cs" />
8080
<Compile Include="Colors.cs" />
8181
<Compile Include="Constants.cs" />
82+
<Compile Include="RepositoryOrigin.cs" />
8283
<Compile Include="Resources.Designer.cs">
8384
<DependentUpon>Resources.resx</DependentUpon>
8485
<AutoGen>True</AutoGen>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace GitHub.VisualStudio.UI
2+
{
3+
public enum RepositoryOrigin
4+
{
5+
DotCom,
6+
Enterprise,
7+
Other,
8+
NonGitRepository,
9+
}
10+
}

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@
274274
<DependentUpon>GitHubPaneView.xaml</DependentUpon>
275275
</Compile>
276276
<Compile Include="UI\Views\GitHubPaneViewModel.cs" />
277+
<Compile Include="UI\Views\NotAGitRepositoryView.xaml.cs">
278+
<DependentUpon>NotAGitRepositoryView.xaml</DependentUpon>
279+
</Compile>
277280
<Compile Include="UI\Views\NotAGitHubRepositoryView.xaml.cs">
278281
<DependentUpon>NotAGitHubRepositoryView.xaml</DependentUpon>
279282
</Compile>
@@ -472,6 +475,10 @@
472475
<SubType>Designer</SubType>
473476
<Generator>MSBuild:Compile</Generator>
474477
</Page>
478+
<Page Include="UI\Views\NotAGitRepositoryView.xaml">
479+
<Generator>MSBuild:Compile</Generator>
480+
<SubType>Designer</SubType>
481+
</Page>
475482
<Page Include="UI\Views\NotAGitHubRepositoryView.xaml">
476483
<Generator>MSBuild:Compile</Generator>
477484
<SubType>Designer</SubType>

0 commit comments

Comments
 (0)