From 210e167e207f2f5fbfefffab58e25542e7220e70 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 16 Jun 2016 16:06:43 +0200 Subject: [PATCH 01/11] Started adding "Not a GitHub repository" view To GitHub pane. XAML compiler crashing on compiling the view though :( --- src/GitHub.App/GitHub.App.csproj | 3 +- .../NotAGitHubRepositoryViewModel.cs | 32 +++++++++++++++++++ .../GitHub.Exports.Reactive.csproj | 1 + .../INotAGitHubRepositoryViewModel.cs | 17 ++++++++++ src/GitHub.Exports/Exports/ExportMetadata.cs | 3 +- .../GitHub.VisualStudio.csproj | 7 ++++ .../UI/Views/GitHubPaneViewModel.cs | 8 ++--- .../UI/Views/NotAGitHubRepositoryView.xaml | 25 +++++++++++++++ .../UI/Views/NotAGitHubRepositoryView.xaml.cs | 22 +++++++++++++ 9 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs create mode 100644 src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs create mode 100644 src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml create mode 100644 src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml.cs diff --git a/src/GitHub.App/GitHub.App.csproj b/src/GitHub.App/GitHub.App.csproj index a9d7ebdbf0..bade4df885 100644 --- a/src/GitHub.App/GitHub.App.csproj +++ b/src/GitHub.App/GitHub.App.csproj @@ -30,7 +30,7 @@ DEBUG;TRACE prompt 4 - true + false ..\common\GitHubVS.ruleset true true @@ -198,6 +198,7 @@ + diff --git a/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs new file mode 100644 index 0000000000..01662dfb71 --- /dev/null +++ b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs @@ -0,0 +1,32 @@ +using System.ComponentModel.Composition; +using GitHub.Exports; +using GitHub.Services; +using ReactiveUI; + +namespace GitHub.ViewModels +{ + /// + /// The view model for the "Not a GitHub repository" view in the GitHub pane. + /// + [ExportViewModel(ViewType = UIViewType.NotAGitHubRepository)] + [PartCreationPolicy(CreationPolicy.NonShared)] + public class NotAGitHubRepositoryViewModel : BaseViewModel, INotAGitHubRepositoryViewModel + { + IUIProvider uiProvider; + + /// + /// Initializes a new instance of the class. + /// + [ImportingConstructor] + public NotAGitHubRepositoryViewModel(IUIProvider uiProvider) + { + this.uiProvider = uiProvider; + Publish = ReactiveCommand.Create(); + } + + /// + /// Gets the command executed when the user clicks the "Publish to GitHub" link. + /// + public IReactiveCommand Publish { get; } + } +} \ No newline at end of file diff --git a/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj b/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj index 8fd06bd998..ee64767703 100644 --- a/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj +++ b/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj @@ -97,6 +97,7 @@ + diff --git a/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs b/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs new file mode 100644 index 0000000000..d6ba06ffae --- /dev/null +++ b/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Reactive; +using ReactiveUI; + +namespace GitHub.ViewModels +{ + /// + /// Defines the view model for the "Sign in to GitHub" view in the GitHub pane. + /// + public interface INotAGitHubRepositoryViewModel : IViewModel + { + /// + /// Gets the command executed when the user clicks the "Publish to GitHub" link. + /// + IReactiveCommand Publish { get; } + } +} \ No newline at end of file diff --git a/src/GitHub.Exports/Exports/ExportMetadata.cs b/src/GitHub.Exports/Exports/ExportMetadata.cs index ac173af9db..d0b6c5a417 100644 --- a/src/GitHub.Exports/Exports/ExportMetadata.cs +++ b/src/GitHub.Exports/Exports/ExportMetadata.cs @@ -25,7 +25,8 @@ public enum UIViewType PRCreation, LogoutRequired, GitHubPane, - LoggedOut + LoggedOut, + NotAGitHubRepository, } public enum MenuType diff --git a/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj b/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj index 76dd288836..e8cff8106b 100644 --- a/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj +++ b/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj @@ -274,6 +274,9 @@ GitHubPaneView.xaml + + NotAGitHubRepositoryView.xaml + LoggedOutView.xaml @@ -469,6 +472,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs index 8949974b29..6ab76ef8b3 100644 --- a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs +++ b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs @@ -120,11 +120,11 @@ async Task Reload([AllowNull] ViewWithData data = null, bool navigating = false) { if (uiController != null) { - Stop(); - //var factory = ServiceProvider.GetExportedValue(); - //var c = factory.CreateViewAndViewModel(UIViewType.LoggedOut); - //Control = c.View; + var factory = ServiceProvider.GetExportedValue(); + var c = factory.CreateViewAndViewModel(UIViewType.NotAGitHubRepository); + Control = c.View; } + return; } diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml new file mode 100644 index 0000000000..a3bbaa4eff --- /dev/null +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + Not a GitHub repository. + diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml.cs b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml.cs new file mode 100644 index 0000000000..546aa29cd0 --- /dev/null +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.Composition; +using GitHub.Exports; +using GitHub.UI; +using GitHub.ViewModels; + +namespace GitHub.VisualStudio.UI.Views +{ + public class GenericNotAGitHubRepositoryView : SimpleViewUserControl + { + } + + [ExportView(ViewType = UIViewType.NotAGitHubRepository)] + [PartCreationPolicy(CreationPolicy.NonShared)] + + public partial class NotAGitHubRepositoryView : GenericNotAGitHubRepositoryView + { + public NotAGitHubRepositoryView() + { + this.InitializeComponent(); + } + } +} \ No newline at end of file From 6ffc20fb9cf4eb0a4f86fb5f8c2f81f72b0d1e20 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 16 Jun 2016 16:34:10 +0200 Subject: [PATCH 02/11] Removed check for uiController It was null on load, and works without it. --- src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs index 6ab76ef8b3..b9c609d13a 100644 --- a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs +++ b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs @@ -118,12 +118,9 @@ async Task Reload([AllowNull] ViewWithData data = null, bool navigating = false) if (!IsGitHubRepo.Value) { - if (uiController != null) - { - var factory = ServiceProvider.GetExportedValue(); - var c = factory.CreateViewAndViewModel(UIViewType.NotAGitHubRepository); - Control = c.View; - } + var factory = ServiceProvider.GetExportedValue(); + var c = factory.CreateViewAndViewModel(UIViewType.NotAGitHubRepository); + Control = c.View; return; } From 2f94c4ccb5db16b7afe820b299ffc46719b3ebd3 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 16 Jun 2016 16:34:57 +0200 Subject: [PATCH 03/11] Make WPF XAML compiler not crash. Seems you can't assign text directly to the `Content` of a subclass of `UserControl`. --- src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml index a3bbaa4eff..998065e13a 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -21,5 +21,5 @@ - Not a GitHub repository. + Not a GitHub repository. From 64ef6c6ab95fe2c3fa0d3b8fc45959eaf23f9712 Mon Sep 17 00:00:00 2001 From: Don Okuda Date: Thu, 16 Jun 2016 11:21:59 -0700 Subject: [PATCH 04/11] Add UI content --- .../UI/Views/NotAGitHubRepositoryView.xaml | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml index 998065e13a..f4d87ca93f 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -21,5 +21,35 @@ - Not a GitHub repository. + + + + + From 71b8bcf4a4fe90f76a4f7a3d626ff2ec31f15406 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 17 Jun 2016 11:57:33 +0200 Subject: [PATCH 05/11] Wire up "not a github repo" view to VM VM not actually doing anything yet though. --- .../NotAGitHubRepositoryViewModel.cs | 21 +++++++++++++++---- .../UI/Views/NotAGitHubRepositoryView.xaml | 11 +++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs index 01662dfb71..10445c64d8 100644 --- a/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs +++ b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs @@ -1,6 +1,8 @@ +using System; using System.ComponentModel.Composition; using GitHub.Exports; using GitHub.Services; +using GitHub.UI; using ReactiveUI; namespace GitHub.ViewModels @@ -12,21 +14,32 @@ namespace GitHub.ViewModels [PartCreationPolicy(CreationPolicy.NonShared)] public class NotAGitHubRepositoryViewModel : BaseViewModel, INotAGitHubRepositoryViewModel { - IUIProvider uiProvider; - /// /// Initializes a new instance of the class. /// [ImportingConstructor] - public NotAGitHubRepositoryViewModel(IUIProvider uiProvider) + public NotAGitHubRepositoryViewModel() { - this.uiProvider = uiProvider; Publish = ReactiveCommand.Create(); + Publish.Subscribe(_ => OnPublish()); } /// /// Gets the command executed when the user clicks the "Publish to GitHub" link. /// public IReactiveCommand Publish { get; } + + /// + /// Gets or sets a value indicating whether the repository publish dialog will be opened + /// with the private option checked. + /// + public bool PublishPrivate { get; set; } + + /// + /// Called when the command is executed. + /// + private void OnPublish() + { + } } } \ No newline at end of file diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml index f4d87ca93f..0978e30231 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -43,10 +43,15 @@ HorizontalAlignment="Center" Orientation="Vertical"> - Publish as a private repository + + Publish as a private repository + - From bd791b9806b7e959214ac76e2ced66dfcb9dd7a9 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 17 Jun 2016 18:05:41 +0200 Subject: [PATCH 06/11] Make the "not a github repos" button work. Shows the Team Explorer Sync page and opens the GitHub publish section. --- .../NotAGitHubRepositoryViewModel.cs | 13 +++++------ .../Services/ITeamExplorerServices.cs | 1 + .../Services/TeamExplorerServices.cs | 11 ++++++++- .../Sync/GitHubPublishSection.cs | 2 +- .../UI/Views/NotAGitHubRepositoryView.xaml | 23 +++++-------------- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs index 10445c64d8..4f373d5ac7 100644 --- a/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs +++ b/src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel.Composition; using GitHub.Exports; +using GitHub.Models; using GitHub.Services; using GitHub.UI; using ReactiveUI; @@ -14,12 +15,15 @@ namespace GitHub.ViewModels [PartCreationPolicy(CreationPolicy.NonShared)] public class NotAGitHubRepositoryViewModel : BaseViewModel, INotAGitHubRepositoryViewModel { + ITeamExplorerServices teamExplorerServices; + /// /// Initializes a new instance of the class. /// [ImportingConstructor] - public NotAGitHubRepositoryViewModel() + public NotAGitHubRepositoryViewModel(ITeamExplorerServices teamExplorerServices) { + this.teamExplorerServices = teamExplorerServices; Publish = ReactiveCommand.Create(); Publish.Subscribe(_ => OnPublish()); } @@ -29,17 +33,12 @@ public NotAGitHubRepositoryViewModel() /// public IReactiveCommand Publish { get; } - /// - /// Gets or sets a value indicating whether the repository publish dialog will be opened - /// with the private option checked. - /// - public bool PublishPrivate { get; set; } - /// /// Called when the command is executed. /// private void OnPublish() { + teamExplorerServices.ShowPublishSection(); } } } \ No newline at end of file diff --git a/src/GitHub.Exports/Services/ITeamExplorerServices.cs b/src/GitHub.Exports/Services/ITeamExplorerServices.cs index 7b4b10fc2a..8b5657d309 100644 --- a/src/GitHub.Exports/Services/ITeamExplorerServices.cs +++ b/src/GitHub.Exports/Services/ITeamExplorerServices.cs @@ -4,6 +4,7 @@ namespace GitHub.Services { public interface ITeamExplorerServices : INotificationService { + void ShowPublishSection(); void ClearNotifications(); } } \ No newline at end of file diff --git a/src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs b/src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs index 04f7cd35a9..51739d75ef 100644 --- a/src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs +++ b/src/GitHub.TeamFoundation.14/Services/TeamExplorerServices.cs @@ -1,9 +1,10 @@ using System; using System.ComponentModel.Composition; using System.Windows.Input; +using GitHub.Extensions; +using GitHub.VisualStudio.TeamExplorer.Sync; using Microsoft.TeamFoundation.Controls; using Microsoft.VisualStudio.Shell; -using GitHub.Extensions; namespace GitHub.Services { @@ -27,6 +28,14 @@ public TeamExplorerServices([Import(typeof(SVsServiceProvider))] IServiceProvide this.serviceProvider = serviceProvider; } + public void ShowPublishSection() + { + var te = serviceProvider.TryGetService(); + var foo = te.NavigateToPage(new Guid(TeamExplorerPageIds.GitCommits), null); + var publish = foo?.GetSection(new Guid(GitHubPublishSection.GitHubPublishSectionId)) as GitHubPublishSection; + publish?.ShowPublish(); + } + public void ShowMessage(string message) { manager = serviceProvider.TryGetService() as ITeamExplorerNotificationManager; diff --git a/src/GitHub.TeamFoundation.14/Sync/GitHubPublishSection.cs b/src/GitHub.TeamFoundation.14/Sync/GitHubPublishSection.cs index bc5d7bf0cc..b01b7301dc 100644 --- a/src/GitHub.TeamFoundation.14/Sync/GitHubPublishSection.cs +++ b/src/GitHub.TeamFoundation.14/Sync/GitHubPublishSection.cs @@ -111,7 +111,7 @@ void StartFlow(UIControllerFlow controllerFlow) uiProvider.RunUI(); } - void ShowPublish() + public void ShowPublish() { IsBusy = true; var uiProvider = ServiceProvider.GetExportedValue(); diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml index 0978e30231..8da08109f0 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -38,23 +38,12 @@ TextAlignment="Center" HorizontalAlignment="Center" Text="Publish this repository to GitHub and get powerful collaboration, code review, and code management for open source and private projects." /> - - - - Publish as a private repository - - - - - + From a30727c3c91e2554fd99868749da19c0cb4ffec3 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 17 Jun 2016 19:39:24 +0200 Subject: [PATCH 07/11] 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. --- src/GitHub.App/GitHub.App.csproj | 1 + .../ViewModels/NotAGitRepositoryViewModel.cs | 19 ++++++++ .../GitHub.Exports.Reactive.csproj | 1 + .../INotAGitHubRepositoryViewModel.cs | 4 +- .../ViewModels/INotAGitRepositoryViewModel.cs | 10 +++++ src/GitHub.Exports/Exports/ExportMetadata.cs | 1 + .../Base/TeamExplorerItemBase.cs | 30 ++++++++++--- .../GitHub.VisualStudio.UI.csproj | 1 + .../RepositoryOrigin.cs | 10 +++++ .../GitHub.VisualStudio.csproj | 7 +++ .../UI/Views/GitHubPaneViewModel.cs | 35 ++++++++++----- .../UI/Views/NotAGitRepositoryView.xaml | 43 +++++++++++++++++++ .../UI/Views/NotAGitRepositoryView.xaml.cs | 22 ++++++++++ 13 files changed, 165 insertions(+), 19 deletions(-) create mode 100644 src/GitHub.App/ViewModels/NotAGitRepositoryViewModel.cs create mode 100644 src/GitHub.Exports.Reactive/ViewModels/INotAGitRepositoryViewModel.cs create mode 100644 src/GitHub.VisualStudio.UI/RepositoryOrigin.cs create mode 100644 src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml create mode 100644 src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml.cs diff --git a/src/GitHub.App/GitHub.App.csproj b/src/GitHub.App/GitHub.App.csproj index bade4df885..3422bdc0a7 100644 --- a/src/GitHub.App/GitHub.App.csproj +++ b/src/GitHub.App/GitHub.App.csproj @@ -198,6 +198,7 @@ + diff --git a/src/GitHub.App/ViewModels/NotAGitRepositoryViewModel.cs b/src/GitHub.App/ViewModels/NotAGitRepositoryViewModel.cs new file mode 100644 index 0000000000..cc63ceb8ba --- /dev/null +++ b/src/GitHub.App/ViewModels/NotAGitRepositoryViewModel.cs @@ -0,0 +1,19 @@ +using System; +using System.ComponentModel.Composition; +using GitHub.Exports; +using GitHub.Models; +using GitHub.Services; +using GitHub.UI; +using ReactiveUI; + +namespace GitHub.ViewModels +{ + /// + /// The view model for the "Not a Git repository" view in the GitHub pane. + /// + [ExportViewModel(ViewType = UIViewType.NotAGitRepository)] + [PartCreationPolicy(CreationPolicy.NonShared)] + public class NotAGitRepositoryViewModel : BaseViewModel, INotAGitRepositoryViewModel + { + } +} \ No newline at end of file diff --git a/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj b/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj index ee64767703..3f7d374e3b 100644 --- a/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj +++ b/src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj @@ -97,6 +97,7 @@ + diff --git a/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs b/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs index d6ba06ffae..2fb562e65f 100644 --- a/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs +++ b/src/GitHub.Exports.Reactive/ViewModels/INotAGitHubRepositoryViewModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Reactive; -using ReactiveUI; +using ReactiveUI; namespace GitHub.ViewModels { diff --git a/src/GitHub.Exports.Reactive/ViewModels/INotAGitRepositoryViewModel.cs b/src/GitHub.Exports.Reactive/ViewModels/INotAGitRepositoryViewModel.cs new file mode 100644 index 0000000000..6ee8569e75 --- /dev/null +++ b/src/GitHub.Exports.Reactive/ViewModels/INotAGitRepositoryViewModel.cs @@ -0,0 +1,10 @@ +namespace GitHub.ViewModels +{ + /// + /// Defines the view model for the "Not a git repository" view in the GitHub pane. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")] + public interface INotAGitRepositoryViewModel : IViewModel + { + } +} \ No newline at end of file diff --git a/src/GitHub.Exports/Exports/ExportMetadata.cs b/src/GitHub.Exports/Exports/ExportMetadata.cs index d0b6c5a417..b9f6a6026d 100644 --- a/src/GitHub.Exports/Exports/ExportMetadata.cs +++ b/src/GitHub.Exports/Exports/ExportMetadata.cs @@ -26,6 +26,7 @@ public enum UIViewType LogoutRequired, GitHubPane, LoggedOut, + NotAGitRepository, NotAGitHubRepository, } diff --git a/src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs b/src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs index a714183c3b..40420fc160 100644 --- a/src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs +++ b/src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs @@ -8,6 +8,7 @@ using GitHub.VisualStudio.Helpers; using NullGuard; using GitHub.ViewModels; +using GitHub.VisualStudio.UI; namespace GitHub.VisualStudio.Base { @@ -98,22 +99,41 @@ protected virtual void RepoChanged(bool changed) } } - protected async Task IsAGitHubRepo() + protected async Task GetRepositoryOrigin() { + if (ActiveRepo == null) + return RepositoryOrigin.NonGitRepository; + var uri = ActiveRepoUri; if (uri == null) - return false; + return RepositoryOrigin.Other; Debug.Assert(apiFactory != null, "apiFactory cannot be null. Did you call the right constructor?"); SimpleApiClient = apiFactory.Create(uri); var isdotcom = HostAddress.IsGitHubDotComUri(uri.ToRepositoryUrl()); - if (!isdotcom) + + if (isdotcom) + { + return RepositoryOrigin.DotCom; + } + else { var repo = await SimpleApiClient.GetRepository(); - return (repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise(); + + if ((repo.FullName == ActiveRepoName || repo.Id == 0) && SimpleApiClient.IsEnterprise()) + { + return RepositoryOrigin.Enterprise; + } } - return isdotcom; + + return RepositoryOrigin.Other; + } + + protected async Task IsAGitHubRepo() + { + var origin = await GetRepositoryOrigin(); + return origin == RepositoryOrigin.DotCom || origin == RepositoryOrigin.Enterprise; } bool disposed; diff --git a/src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj b/src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj index 55c66e86b9..04ec2d04eb 100644 --- a/src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj +++ b/src/GitHub.VisualStudio.UI/GitHub.VisualStudio.UI.csproj @@ -79,6 +79,7 @@ + Resources.resx True diff --git a/src/GitHub.VisualStudio.UI/RepositoryOrigin.cs b/src/GitHub.VisualStudio.UI/RepositoryOrigin.cs new file mode 100644 index 0000000000..1a9207663b --- /dev/null +++ b/src/GitHub.VisualStudio.UI/RepositoryOrigin.cs @@ -0,0 +1,10 @@ +namespace GitHub.VisualStudio.UI +{ + public enum RepositoryOrigin + { + DotCom, + Enterprise, + Other, + NonGitRepository, + } +} diff --git a/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj b/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj index e8cff8106b..6e04327db6 100644 --- a/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj +++ b/src/GitHub.VisualStudio/GitHub.VisualStudio.csproj @@ -274,6 +274,9 @@ GitHubPaneView.xaml + + NotAGitRepositoryView.xaml + NotAGitHubRepositoryView.xaml @@ -472,6 +475,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs index b1eb3d4983..f7d466acbc 100644 --- a/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs +++ b/src/GitHub.VisualStudio/UI/Views/GitHubPaneViewModel.cs @@ -19,6 +19,7 @@ using ReactiveUI; using System.Collections.Generic; using System.Threading.Tasks; +using GitHub.VisualStudio.UI; namespace GitHub.VisualStudio.UI.Views { @@ -109,7 +110,7 @@ protected override void RepoChanged(bool changed) return; Stop(); - IsGitHubRepo = null; + RepositoryOrigin = null; Reload().Forget(); } @@ -129,13 +130,13 @@ async Task Reload([AllowNull] ViewWithData data = null, bool navigating = false) navigatingViaArrows = navigating; - if (!IsGitHubRepo.HasValue) + if (!RepositoryOrigin.HasValue) { - var isGitHubRepo = await IsAGitHubRepo(); + var origin = await GetRepositoryOrigin(); if (reloadCallId != latestReloadCallId) return; - IsGitHubRepo = isGitHubRepo; + RepositoryOrigin = origin; } var connection = await connectionManager.LookupConnection(ActiveRepo); @@ -153,16 +154,18 @@ async Task Reload([AllowNull] ViewWithData data = null, bool navigating = false) IsLoggedIn = isLoggedIn; } - if (!IsGitHubRepo.Value) + if (RepositoryOrigin.Value == UI.RepositoryOrigin.NonGitRepository) + { + LoadView(UIViewType.NotAGitRepository); + } + else if (RepositoryOrigin.Value == UI.RepositoryOrigin.Other) { LoadView(UIViewType.NotAGitHubRepository); } - else if (!IsLoggedIn) { LoadView(UIViewType.LoggedOut); } - else { LoadView(data?.ActiveFlow ?? DefaultControllerFlow, connection, data); @@ -337,13 +340,23 @@ public bool IsLoggedIn set { isLoggedIn = value; this.RaisePropertyChange(); } } - bool? isGitHubRepo; - public bool? IsGitHubRepo + RepositoryOrigin? repositoryOrigin; + public RepositoryOrigin? RepositoryOrigin { - get { return isGitHubRepo; } - set { isGitHubRepo = value; this.RaisePropertyChange(); } + get { return repositoryOrigin; } + private set { repositoryOrigin = value; } } + public bool? IsGitHubRepo + { + get + { + return repositoryOrigin.HasValue ? + repositoryOrigin.Value == UI.RepositoryOrigin.DotCom || + repositoryOrigin.Value == UI.RepositoryOrigin.Enterprise : + (bool?)null; + } + } public ReactiveCommand CancelCommand { get; private set; } public ICommand Cancel => CancelCommand; diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml new file mode 100644 index 0000000000..5f6e0b82aa --- /dev/null +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml.cs b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml.cs new file mode 100644 index 0000000000..0d6ffb2a6a --- /dev/null +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml.cs @@ -0,0 +1,22 @@ +using System.ComponentModel.Composition; +using GitHub.Exports; +using GitHub.UI; +using GitHub.ViewModels; + +namespace GitHub.VisualStudio.UI.Views +{ + public class GenericNotAGitRepositoryView : SimpleViewUserControl + { + } + + [ExportView(ViewType = UIViewType.NotAGitRepository)] + [PartCreationPolicy(CreationPolicy.NonShared)] + + public partial class NotAGitRepositoryView : GenericNotAGitRepositoryView + { + public NotAGitRepositoryView() + { + this.InitializeComponent(); + } + } +} \ No newline at end of file From a3d471e07486745cf5444cfc1f1c2df0a53ca28b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 20 Jun 2016 14:14:55 +0200 Subject: [PATCH 08/11] Updated message. --- src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml index 5f6e0b82aa..fdc8b18376 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitRepositoryView.xaml @@ -36,8 +36,10 @@ + HorizontalAlignment="Center"> + We couldn't find a git repository here. Open a git project or click "File -> Add to Source Control" + in a project to get started + From ef3c597c74bb9c15172a3b27ad2c52b16af18cee Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 22 Jun 2016 12:30:30 +0200 Subject: [PATCH 09/11] Place messages in Resources.resx. --- .../Resources.Designer.cs | 36 +++++++++++++++++++ src/GitHub.VisualStudio.UI/Resources.resx | 12 +++++++ .../UI/Views/NotAGitHubRepositoryView.xaml | 5 +-- .../UI/Views/NotAGitRepositoryView.xaml | 11 +++--- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/GitHub.VisualStudio.UI/Resources.Designer.cs b/src/GitHub.VisualStudio.UI/Resources.Designer.cs index 5babff65d7..8533c6bc63 100644 --- a/src/GitHub.VisualStudio.UI/Resources.Designer.cs +++ b/src/GitHub.VisualStudio.UI/Resources.Designer.cs @@ -438,6 +438,42 @@ public static string noRepositoriesMessageText { } } + /// + /// Looks up a localized string similar to This repository is not on GitHub. + /// + public static string NotAGitHubRepository { + get { + return ResourceManager.GetString("NotAGitHubRepository", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Publish this repository to GitHub and get powerful collaboration, code review, and code management for open source and private projects.. + /// + public static string NotAGitHubRepositoryMessage { + get { + return ResourceManager.GetString("NotAGitHubRepositoryMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No repository. + /// + public static string NotAGitRepository { + get { + return ResourceManager.GetString("NotAGitRepository", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to We couldn't find a git repository here. Open a git project or click "File -> Add to Source Control" in a project to get started.. + /// + public static string NotAGitRepositoryMessage { + get { + return ResourceManager.GetString("NotAGitRepositoryMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to You are not logged in to {0}, so certain git operations may fail. [Login now]({1}). /// diff --git a/src/GitHub.VisualStudio.UI/Resources.resx b/src/GitHub.VisualStudio.UI/Resources.resx index 7345b76214..ab68d55312 100644 --- a/src/GitHub.VisualStudio.UI/Resources.resx +++ b/src/GitHub.VisualStudio.UI/Resources.resx @@ -315,4 +315,16 @@ Open in Browser + + Publish this repository to GitHub and get powerful collaboration, code review, and code management for open source and private projects. + + + This repository is not on GitHub + + + No repository + + + We couldn't find a git repository here. Open a git project or click "File -> Add to Source Control" in a project to get started. + \ No newline at end of file diff --git a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml index 8da08109f0..75adf90bc9 100644 --- a/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml +++ b/src/GitHub.VisualStudio/UI/Views/NotAGitHubRepositoryView.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:GitHub.VisualStudio.UI.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI" + xmlns:prop="clr-namespace:GitHub.VisualStudio.UI;assembly=GitHub.VisualStudio.UI" DataContext="{Binding ViewModel}" d:DesignHeight="300" d:DesignWidth="300" @@ -32,12 +33,12 @@ Foreground="{DynamicResource GitHubVsWindowText}" HorizontalAlignment="Center" FontSize="16" - Content="This repository is not on GitHub" /> + Content="{x:Static prop:Resources.NotAGitHubRepository}" /> + Text="{x:Static prop:Resources.NotAGitHubRepositoryMessage}" />