Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2e04cf3
Functionality to add Publish to GitHub Essentials
StanleyGoldman May 22, 2019
f152a8a
Merge branch 'master' into essentials-publish
StanleyGoldman May 22, 2019
fb7b443
Merge branch 'master' into essentials-publish
StanleyGoldman May 23, 2019
3bf04a5
Hiding the publish section to favor the main package
StanleyGoldman May 23, 2019
d0a1cd8
Make publish view consistent with Azure DevOps
jcansdale May 23, 2019
befcadb
Adding a Home section that disappears in the same way
StanleyGoldman May 24, 2019
1507ada
Starting to display the RepositoryPublishView
StanleyGoldman May 30, 2019
07bbffc
Loading more of the Publish functionality
StanleyGoldman May 30, 2019
d4603a2
Adding missing references
StanleyGoldman May 30, 2019
d86fad5
Use local not global ServiceProvider
jcansdale May 31, 2019
88109fb
Factor out GetExportProvider
jcansdale May 31, 2019
e4e574d
Clean up when view is unloaded
jcansdale May 31, 2019
fe9b3f2
Remove redundant ShowNotification
jcansdale May 31, 2019
b4e809d
Locate the DefaultExportProvider using MEF
jcansdale May 31, 2019
9544e81
Expose singleton GitHub ExportProvider via MEF
jcansdale May 31, 2019
e4355cd
Factor knowledge of full extension into FullExtensionUtilities
jcansdale May 31, 2019
46c2174
Avoid putting GitHub.Resources.dll on BindingPath
jcansdale Jun 3, 2019
25878e0
Making sure the `EnsureLoad` method is not optimized away
StanleyGoldman Jun 3, 2019
2aa0881
Authenticating the user before showing the publish section view
StanleyGoldman Jun 3, 2019
b4a400b
Merge branch 'master' into essentials-publish
StanleyGoldman Jun 4, 2019
e550bad
Add option to add/change accounts from publish view
jcansdale Jun 5, 2019
c5ce8f4
Fix style of Add/Change Accounts button
jcansdale Jun 5, 2019
9137b48
Remove deleted files from .csproj
jcansdale Jun 5, 2019
2789158
Merge remote-tracking branch 'remotes/origin/essentials-publish' into…
StanleyGoldman Jun 5, 2019
edf7220
Fixing unit test
StanleyGoldman Jun 5, 2019
ae78a15
Merge branch 'essentials-publish' into essentials-home-section
StanleyGoldman Jun 5, 2019
e845cbe
Merge remote-tracking branch 'remotes/origin/essentials-publish' into…
StanleyGoldman Jun 5, 2019
0f00235
Merge branch 'essentials-publish' into essentials-home-section
StanleyGoldman Jun 5, 2019
9e6eecf
Populating the essentials HomeSectionViewModel with MEF
StanleyGoldman Jun 5, 2019
8be1fdb
Show GitHub URL in home section
jcansdale Jun 6, 2019
c57e86d
Removing argument from function that is always true
StanleyGoldman Jun 6, 2019
cb3e740
Merge branch 'small-fix' into essentials-home-section
StanleyGoldman Jun 6, 2019
a742289
Getting the icon from ISimpleApiClient
StanleyGoldman Jun 6, 2019
76cfedc
CompositionServices also accept ExportProvider from ComponentModel
jcansdale Jun 6, 2019
5f0f231
Extract HomeSectionViewModel.cs
jcansdale Jun 7, 2019
e716284
Use TextBlock instead of Label
jcansdale Jun 7, 2019
b23f71e
Check for gitExt being null
jcansdale Jun 7, 2019
5ba9ba9
Add GetMinimalExportProvider for fast loading services
jcansdale Jun 7, 2019
3c913a1
Make TeamExplorerContext available via MinimalExportProvider
jcansdale Jun 7, 2019
e936ffa
Make ISimpleApiClientFactory available via MinimalExportProvider
jcansdale Jun 7, 2019
453210b
Use GetMinimalExportProvider
jcansdale Jun 7, 2019
d36c33e
Moving UsageService from PullRequestService to PullRequestCreationVie…
StanleyGoldman Jun 12, 2019
3880401
Merge branch 'move-usage-service-usage' into essentials-home-section
StanleyGoldman Jun 12, 2019
8327c89
Removing minimal usage tracker
StanleyGoldman Jun 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/GitHub.App/SampleData/SampleViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public ReactiveCommand<Unit, ProgressState> PublishRepository
private set;
}

public ReactiveCommand<Unit, Unit> LoginAsDifferentUser
{
get;
private set;
}

public IReadOnlyObservableCollection<IConnection> Connections
{
get;
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.App/Services/GitHubCredentialProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace GitHub.Services
{
[Export(typeof(IGitHubCredentialProvider))]
[PartCreationPolicy(CreationPolicy.Shared)]
class GitHubCredentialProvider : IGitHubCredentialProvider
public class GitHubCredentialProvider : IGitHubCredentialProvider
{
static readonly ILogger log = LogManager.ForContext<GitHubCredentialProvider>();
readonly IKeychain keychain;
Expand Down
6 changes: 1 addition & 5 deletions src/GitHub.App/Services/PullRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class PullRequestService : IssueishService, IPullRequestService, IStaticR
readonly IVSGitExt gitExt;
readonly IGraphQLClientFactory graphqlFactory;
readonly IOperatingSystem os;
readonly IUsageTracker usageTracker;

readonly IDictionary<string, (string commitId, string repoPath)> tempFileMappings;

Expand All @@ -71,16 +70,14 @@ public PullRequestService(
IVSGitExt gitExt,
IApiClientFactory apiClientFactory,
IGraphQLClientFactory graphqlFactory,
IOperatingSystem os,
IUsageTracker usageTracker)
IOperatingSystem os)
: base(apiClientFactory, graphqlFactory)
{
this.gitClient = gitClient;
this.gitService = gitService;
this.gitExt = gitExt;
this.graphqlFactory = graphqlFactory;
this.os = os;
this.usageTracker = usageTracker;
this.tempFileMappings = new Dictionary<string, (string commitId, string repoPath)>(StringComparer.OrdinalIgnoreCase);
}

Expand Down Expand Up @@ -1011,7 +1008,6 @@ async Task<IPullRequestModel> PushAndCreatePR(IModelService modelService,
var ret = await modelService.CreatePullRequest(sourceRepository, targetRepository, sourceBranch, targetBranch, title, body);
await MarkBranchAsPullRequest(repo, sourceBranch.Name, targetRepository.CloneUrl.Owner, ret.Number);
gitExt.RefreshActiveRepositories();
await usageTracker.IncrementCounter(x => x.NumberOfUpstreamPullRequests);
return ret;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class PullRequestCreationViewModel : PanePageViewModelBase, IPullRequestC
readonly IMessageDraftStore draftStore;
readonly IGitService gitService;
readonly IScheduler timerScheduler;
readonly IUsageTracker usageTracker;
readonly CompositeDisposable disposables = new CompositeDisposable();
LocalRepositoryModel activeLocalRepo;
ObservableAsPropertyHelper<RemoteRepositoryModel> githubRepository;
Expand All @@ -53,8 +54,9 @@ public PullRequestCreationViewModel(
INotificationService notifications,
IMessageDraftStore draftStore,
IGitService gitService,
IAutoCompleteAdvisor autoCompleteAdvisor)
: this(modelServiceFactory, service, notifications, draftStore, gitService, autoCompleteAdvisor, DefaultScheduler.Instance)
IAutoCompleteAdvisor autoCompleteAdvisor,
IUsageTracker usageTracker)
: this(modelServiceFactory, service, notifications, draftStore, gitService, autoCompleteAdvisor, usageTracker, DefaultScheduler.Instance)
{
}

Expand All @@ -65,6 +67,7 @@ public PullRequestCreationViewModel(
IMessageDraftStore draftStore,
IGitService gitService,
IAutoCompleteAdvisor autoCompleteAdvisor,
IUsageTracker usageTracker,
IScheduler timerScheduler)
{
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
Expand All @@ -81,6 +84,7 @@ public PullRequestCreationViewModel(
this.gitService = gitService;
this.AutoCompleteAdvisor = autoCompleteAdvisor;
this.timerScheduler = timerScheduler;
this.usageTracker = usageTracker;

this.WhenAnyValue(x => x.Branches)
.WhereNotNull()
Expand All @@ -107,8 +111,16 @@ public PullRequestCreationViewModel(
.Subscribe(x => notifications.ShowError(BranchValidator.ValidationResult.Message));

CreatePullRequest = ReactiveCommand.CreateFromObservable(
() => service
.CreatePullRequest(modelService, activeLocalRepo, TargetBranch.Repository, SourceBranch, TargetBranch, PRTitle, Description ?? String.Empty)
() => Observable.FromAsync(async () =>
{
var pullRequestModel = await service
.CreatePullRequest(modelService, activeLocalRepo, TargetBranch.Repository, SourceBranch,
TargetBranch, PRTitle, Description ?? String.Empty);

await usageTracker.IncrementCounter(x => x.NumberOfUpstreamPullRequests);

return pullRequestModel;
})
.Catch<IPullRequestModel, Exception>(ex =>
{
log.Error(ex, "Error creating pull request");
Expand All @@ -120,6 +132,7 @@ public PullRequestCreationViewModel(
return Observable.Empty<IPullRequestModel>();
}),
whenAnyValidationResultChanges);

CreatePullRequest.Subscribe(pr =>
{
notifications.ShowMessage(String.Format(CultureInfo.CurrentCulture, Resources.PRCreatedUpstream, SourceBranch.DisplayName, TargetBranch.Repository.Owner + "/" + TargetBranch.Repository.Name + "#" + pr.Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using GitHub.App;
using System.Threading.Tasks;
using GitHub.Extensions;
using GitHub.Extensions.Reactive;
using GitHub.Factories;
Expand All @@ -29,6 +29,7 @@ public class RepositoryPublishViewModel : RepositoryFormViewModel, IRepositoryPu
readonly IRepositoryPublishService repositoryPublishService;
readonly INotificationService notificationService;
readonly IModelServiceFactory modelServiceFactory;
readonly IDialogService dialogService;
readonly ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
readonly ObservableAsPropertyHelper<bool> isHostComboBoxVisible;
readonly IUsageTracker usageTracker;
Expand All @@ -39,17 +40,20 @@ public RepositoryPublishViewModel(
INotificationService notificationService,
IConnectionManager connectionManager,
IModelServiceFactory modelServiceFactory,
IDialogService dialogService,
IUsageTracker usageTracker)
{
Guard.ArgumentNotNull(repositoryPublishService, nameof(repositoryPublishService));
Guard.ArgumentNotNull(notificationService, nameof(notificationService));
Guard.ArgumentNotNull(connectionManager, nameof(connectionManager));
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
Guard.ArgumentNotNull(dialogService, nameof(dialogService));

this.notificationService = notificationService;
this.usageTracker = usageTracker;
this.modelServiceFactory = modelServiceFactory;
this.dialogService = dialogService;

Connections = connectionManager.Connections;
this.repositoryPublishService = repositoryPublishService;
Expand Down Expand Up @@ -83,6 +87,8 @@ public RepositoryPublishViewModel(
PublishRepository = InitializePublishRepositoryCommand();
PublishRepository.IsExecuting.Subscribe(x => IsBusy = x);

LoginAsDifferentUser = ReactiveCommand.CreateFromTask(LoginAsDifferentUserAsync);

var defaultRepositoryName = repositoryPublishService.LocalRepositoryName;
if (!string.IsNullOrEmpty(defaultRepositoryName))
RepositoryName = defaultRepositoryName;
Expand All @@ -101,6 +107,9 @@ public RepositoryPublishViewModel(
}

public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }

public ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; private set; }

public IReadOnlyObservableCollection<IConnection> Connections { get; private set; }

bool isBusy;
Expand All @@ -127,6 +136,11 @@ public bool IsHostComboBoxVisible
get { return isHostComboBoxVisible.Value; }
}

Task LoginAsDifferentUserAsync()
{
return dialogService.ShowLoginDialog();
}

ReactiveCommand<Unit, ProgressState> InitializePublishRepositoryCommand()
{
var canCreate = this.WhenAny(x => x.RepositoryNameValidator.ValidationResult.IsValid, x => x.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public interface IRepositoryPublishViewModel : IViewModel, IRepositoryForm
/// </summary>
ReactiveCommand<Unit, ProgressState> PublishRepository { get; }

/// <summary>
/// Command that shows login dialog.
/// </summary>
ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }

/// <summary>
/// Determines whether the host combo box is visible. Only true if the user is logged into more than one host.
/// </summary>
Expand Down
14 changes: 9 additions & 5 deletions src/GitHub.TeamFoundation.14/Home/GitHubHomeSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using GitHub.VisualStudio.UI;
using GitHub.VisualStudio.UI.Views;
using Microsoft.TeamFoundation.Controls;
using Octokit;

namespace GitHub.VisualStudio.TeamExplorer.Home
{
Expand Down Expand Up @@ -70,7 +71,7 @@ protected async override void RepoChanged()
{
RepoName = ActiveRepoName;
RepoUrl = ActiveRepoUri.ToString();
Icon = GetIcon(false, true, false);
Icon = GetIcon();

// We want to display a welcome message but only if Team Explorer isn't
// already displaying the "Install 3rd Party Tools" message and the current repo is hosted on GitHub.
Expand All @@ -82,7 +83,8 @@ protected async override void RepoChanged()
Debug.Assert(SimpleApiClient != null,
"If we're in this block, simpleApiClient cannot be null. It was created by UpdateStatus");
var repo = await SimpleApiClient.GetRepository();
Icon = GetIcon(repo.Private, true, repo.Fork);
var octicon = GetIcon(repo);
Icon = octicon;
IsLoggedIn = await IsUserAuthenticated();
}
else
Expand All @@ -102,10 +104,12 @@ public override async void Refresh()
base.Refresh();
}

static Octicon GetIcon(bool isPrivate, bool isHosted, bool isFork)
static Octicon GetIcon(Repository repo = null)
{
return !isHosted ? Octicon.device_desktop
: isPrivate ? Octicon.@lock
var isPrivate = repo?.Private ?? false;
var isFork = repo?.Fork ?? false;

return isPrivate ? Octicon.@lock
: isFork ? Octicon.repo_forked : Octicon.repo;
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.TeamFoundation.14/Services/VSGitExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public VSGitExt(IServiceProvider serviceProvider, IVSUIContextFactory factory, I
async Task InitializeAsync()
{
gitExt = await GetServiceAsync<IGitExt>();
if (gitService == null)
if (gitExt == null)
{
log.Error("Couldn't find IGitExt service");
return;
Expand Down
10 changes: 10 additions & 0 deletions src/GitHub.VisualStudio.16.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio.TestApp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio.UI.16", "GitHub.VisualStudio.UI.16\GitHub.VisualStudio.UI.16.csproj", "{00423E7A-0838-4BE1-9263-181006DFF96B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio.16.UnitTests", "..\test\GitHub.VisualStudio.16.UnitTests\GitHub.VisualStudio.16.UnitTests.csproj", "{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -41,6 +43,14 @@ Global
{00423E7A-0838-4BE1-9263-181006DFF96B}.Release|Any CPU.Build.0 = Release|Any CPU
{00423E7A-0838-4BE1-9263-181006DFF96B}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
{00423E7A-0838-4BE1-9263-181006DFF96B}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.DebugWithoutVsix|Any CPU.ActiveCfg = Debug|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.DebugWithoutVsix|Any CPU.Build.0 = Debug|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.Release|Any CPU.Build.0 = Release|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
{1EE77BE9-821D-46A0-9A4F-DE1B714F5691}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions src/GitHub.VisualStudio.16.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CheckNamespace/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
Loading