From 9e4d7f963de1410aec2c62c4383a1a8f5675feb7 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 4 Jan 2019 10:47:51 -0500 Subject: [PATCH 1/9] Starting to implement autocomplete functionality --- .../GitHubPane/PullRequestCreationView.xaml | 41 +++++++++++++------ .../PullRequestCreationViewModelTests.cs | 21 ++++++---- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml b/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml index ba748d1eef..e3d1c4b224 100644 --- a/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml +++ b/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml @@ -149,18 +149,35 @@ SpellCheck.IsEnabled="True" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.PullRequestCreationTitleTextBox}"/> - - + + + + + + + + + + + + + (); var api = Substitute.For(); var ms = Substitute.For(); + var autoCompleteAdvisor = Substitute.For(); connection.HostAddress.Returns(HostAddress.Create("https://github.com")); @@ -121,7 +123,8 @@ static TestData PrepareTestData( NotificationService = notifications, Connection = connection, ApiClient = api, - ModelService = ms + ModelService = ms, + AutoCompleteAdvisor = autoCompleteAdvisor }; } @@ -147,7 +150,7 @@ public async Task TargetBranchDisplayNameIncludesRepoOwnerWhenForkAsync() var prservice = new PullRequestService(data.GitClient, data.GitService, Substitute.For(), Substitute.For(), data.ServiceProvider.GetOperatingSystem(), Substitute.For()); prservice.GetPullRequestTemplate(data.ActiveRepo).Returns(Observable.Empty()); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - Substitute.For(), data.GitService); + Substitute.For(), data.GitService, data.AutoCompleteAdvisor); await vm.InitializeAsync(data.ActiveRepo, data.Connection); Assert.That("octokit/master", Is.EqualTo(vm.TargetBranch.DisplayName)); } @@ -183,7 +186,7 @@ public async Task CreatingPRsAsync( var prservice = new PullRequestService(data.GitClient, data.GitService, Substitute.For(), Substitute.For(), data.ServiceProvider.GetOperatingSystem(), Substitute.For()); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - Substitute.For(), data.GitService); + Substitute.For(), data.GitService, data.AutoCompleteAdvisor); await vm.InitializeAsync(data.ActiveRepo, data.Connection); // the TargetBranch property gets set to whatever the repo default is (we assume master here), @@ -226,7 +229,7 @@ public async Task TemplateIsUsedIfPresentAsync() prservice.GetPullRequestTemplate(data.ActiveRepo).Returns(Observable.Return("Test PR template")); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - Substitute.For(), data.GitService); + Substitute.For(), data.GitService, data.AutoCompleteAdvisor); await vm.InitializeAsync(data.ActiveRepo, data.Connection); Assert.That("Test PR template", Is.EqualTo(vm.Description)); @@ -246,7 +249,7 @@ public async Task LoadsDraft() var prservice = Substitute.For(); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - draftStore, data.GitService); + draftStore, data.GitService, data.AutoCompleteAdvisor); await vm.InitializeAsync(data.ActiveRepo, data.Connection); Assert.That(vm.PRTitle, Is.EqualTo("This is a Title.")); @@ -261,7 +264,7 @@ public async Task UpdatesDraftWhenDescriptionChanges() var draftStore = Substitute.For(); var prservice = Substitute.For(); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - draftStore, data.GitService, scheduler); + draftStore, data.GitService, data.AutoCompleteAdvisor, scheduler); await vm.InitializeAsync(data.ActiveRepo, data.Connection); vm.Description = "Body changed."; @@ -284,7 +287,7 @@ public async Task UpdatesDraftWhenTitleChanges() var draftStore = Substitute.For(); var prservice = Substitute.For(); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, - draftStore, data.GitService, scheduler); + draftStore, data.GitService, data.AutoCompleteAdvisor, scheduler); await vm.InitializeAsync(data.ActiveRepo, data.Connection); vm.PRTitle = "Title changed."; @@ -307,7 +310,7 @@ public async Task DeletesDraftWhenPullRequestSubmitted() var draftStore = Substitute.For(); var prservice = Substitute.For(); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, draftStore, - data.GitService, scheduler); + data.GitService, data.AutoCompleteAdvisor, scheduler); await vm.InitializeAsync(data.ActiveRepo, data.Connection); await vm.CreatePullRequest.Execute(); @@ -323,7 +326,7 @@ public async Task DeletesDraftWhenCanceled() var draftStore = Substitute.For(); var prservice = Substitute.For(); var vm = new PullRequestCreationViewModel(data.GetModelServiceFactory(), prservice, data.NotificationService, draftStore, - data.GitService, scheduler); + data.GitService, data.AutoCompleteAdvisor, scheduler); await vm.InitializeAsync(data.ActiveRepo, data.Connection); await vm.Cancel.Execute(); From 8906c54b4faf2a10d15cf782881d5617f42f98e3 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 4 Jan 2019 10:59:41 -0500 Subject: [PATCH 2/9] Revert "Undoing changes to PullRequestCreationViewModel" This reverts commit 653cc79c6cb098417f69b608af19edea82aaf4a0. --- .../GitHubPane/PullRequestCreationViewModel.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs b/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs index 89f8e37c50..5450fb970e 100644 --- a/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs +++ b/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs @@ -18,6 +18,7 @@ using GitHub.Models.Drafts; using GitHub.Primitives; using GitHub.Services; +using GitHub.UI; using GitHub.Validation; using Octokit; using ReactiveUI; @@ -51,8 +52,9 @@ public PullRequestCreationViewModel( IPullRequestService service, INotificationService notifications, IMessageDraftStore draftStore, - IGitService gitService) - : this(modelServiceFactory, service, notifications, draftStore, gitService, DefaultScheduler.Instance) + IGitService gitService, + IAutoCompleteAdvisor autoCompleteAdvisor) + : this(modelServiceFactory, service, notifications, draftStore, gitService, autoCompleteAdvisor, DefaultScheduler.Instance) { } @@ -62,6 +64,7 @@ public PullRequestCreationViewModel( INotificationService notifications, IMessageDraftStore draftStore, IGitService gitService, + IAutoCompleteAdvisor autoCompleteAdvisor, IScheduler timerScheduler) { Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory)); @@ -69,12 +72,14 @@ public PullRequestCreationViewModel( Guard.ArgumentNotNull(notifications, nameof(notifications)); Guard.ArgumentNotNull(draftStore, nameof(draftStore)); Guard.ArgumentNotNull(gitService, nameof(gitService)); + Guard.ArgumentNotNull(autoCompleteAdvisor, nameof(autoCompleteAdvisor)); Guard.ArgumentNotNull(timerScheduler, nameof(timerScheduler)); this.service = service; this.modelServiceFactory = modelServiceFactory; this.draftStore = draftStore; this.gitService = gitService; + this.AutoCompleteAdvisor = autoCompleteAdvisor; this.timerScheduler = timerScheduler; this.WhenAnyValue(x => x.Branches) @@ -334,8 +339,9 @@ protected string GetDraftKey() SourceBranch.Name); } - public RemoteRepositoryModel GitHubRepository { get { return githubRepository?.Value; } } - bool IsExecuting { get { return isExecuting.Value; } } + public RemoteRepositoryModel GitHubRepository => githubRepository?.Value; + bool IsExecuting => isExecuting.Value; + public IAutoCompleteAdvisor AutoCompleteAdvisor { get; } bool initialized; bool Initialized From bfa18c619ec6a02b9689b6b31a0c40672a7324c0 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 4 Jan 2019 11:09:03 -0500 Subject: [PATCH 3/9] Undoing some changes --- .../ViewModels/GitHubPane/PullRequestCreationViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs b/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs index 5450fb970e..bd25c85c52 100644 --- a/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs +++ b/src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs @@ -339,8 +339,8 @@ protected string GetDraftKey() SourceBranch.Name); } - public RemoteRepositoryModel GitHubRepository => githubRepository?.Value; - bool IsExecuting => isExecuting.Value; + public RemoteRepositoryModel GitHubRepository { get { return githubRepository?.Value; } } + bool IsExecuting { get { return isExecuting.Value; } } public IAutoCompleteAdvisor AutoCompleteAdvisor { get; } bool initialized; From 2c947487771d7038b02013b342785462b9269626 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Sat, 5 Jan 2019 10:43:14 -0500 Subject: [PATCH 4/9] Trying to display the control correctly --- .../GitHubPane/PullRequestCreationView.xaml | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml b/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml index e3d1c4b224..9b1c35db1f 100644 --- a/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml +++ b/src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestCreationView.xaml @@ -149,13 +149,24 @@ SpellCheck.IsEnabled="True" AutomationProperties.AutomationId="{x:Static ghfvs:AutomationIDs.PullRequestCreationTitleTextBox}"/> + + + Grid.Row="3" + MinHeight="100" + Margin="10,5" + Advisor="{Binding AutoCompleteAdvisor}" + > @@ -163,17 +174,13 @@ - + SpellCheck.IsEnabled="True"/> From 9d2ee84e80dd415819719bd1db6c79d7a92b2be5 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Thu, 24 Jan 2019 11:06:34 -0500 Subject: [PATCH 5/9] Including missing themes --- .../Assets/Controls/AutoCompleteBox.xaml | 20 +++---- .../Styles/ThemeBlue.xaml | 52 +++++++++++++++++++ .../Styles/ThemeDark.xaml | 52 +++++++++++++++++++ .../Styles/ThemeLight.xaml | 52 +++++++++++++++++++ 4 files changed, 166 insertions(+), 10 deletions(-) diff --git a/src/GitHub.UI/Assets/Controls/AutoCompleteBox.xaml b/src/GitHub.UI/Assets/Controls/AutoCompleteBox.xaml index 1a1a950e6b..2283b4b9a1 100644 --- a/src/GitHub.UI/Assets/Controls/AutoCompleteBox.xaml +++ b/src/GitHub.UI/Assets/Controls/AutoCompleteBox.xaml @@ -65,11 +65,11 @@ - - + + - + @@ -81,23 +81,23 @@ - + - - + + - - + + @@ -113,8 +113,8 @@ -