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

Commit c32b620

Browse files
committed
Wire up cancel button in "Create PR" flow.
This fixes the first part of #325. Clicking "Create New" again after cancel still doesn't work.
1 parent 2f0753f commit c32b620

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace GitHub.SampleData
2525
public class BaseViewModelDesigner : ReactiveObject, IViewModel
2626
{
2727
public ICommand Cancel { get; set; }
28+
public ReactiveCommand<object> CancelCommand { get; protected set; }
2829
public bool IsShowing { get; set; }
2930
public string Title { get; set; }
3031

src/GitHub.App/ViewModels/PullRequestCreationViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
using System.Linq;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using ReactiveUI;
1011

1112
namespace GitHub.ViewModels
1213
{
1314
[ExportViewModel(ViewType = UIViewType.PRCreation)]
1415
[PartCreationPolicy(CreationPolicy.NonShared)]
1516
class PullRequestCreationViewModel : BaseViewModel, IPullRequestCreationViewModel
1617
{
18+
public PullRequestCreationViewModel()
19+
{
20+
CancelCommand = ReactiveCommand.Create();
21+
}
1722
}
1823
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
namespace GitHub.ViewModels
1+
using ReactiveUI;
2+
3+
namespace GitHub.ViewModels
24
{
35
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
46
public interface IPullRequestCreationViewModel : IViewModel
57
{
8+
ReactiveCommand<object> CancelCommand { get; }
69
}
710
}

src/GitHub.VisualStudio/UI/Views/PullRequestCreationView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
<ColumnDefinition Width="Auto" />
299299
</Grid.ColumnDefinitions>
300300

301-
<Button HorizontalAlignment="Right" Content="Cancel" Grid.Column="0" Style="{StaticResource GitHubVsButton}"/>
301+
<Button Name="cancelButton" HorizontalAlignment="Right" Content="Cancel" Grid.Column="0" Style="{StaticResource GitHubVsButton}"/>
302302
<Button HorizontalAlignment="Right" Margin="6,0,0,0" Content="Create pull request" Grid.Column="1" Style="{StaticResource GitHubVsPrimaryActionButton}" />
303303
</Grid>
304304
</StackPanel>

src/GitHub.VisualStudio/UI/Views/PullRequestCreationView.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using GitHub.Exports;
1+
using System;
2+
using GitHub.Exports;
23
using GitHub.UI;
34
using GitHub.ViewModels;
45
using System.ComponentModel.Composition;
@@ -20,6 +21,8 @@ public PullRequestCreationView()
2021

2122
this.WhenActivated(d =>
2223
{
24+
d(this.BindCommand(ViewModel, vm => vm.Cancel, v => v.cancelButton));
25+
d(ViewModel.CancelCommand.Subscribe(_ => NotifyCancel()));
2326
});
2427
}
2528

0 commit comments

Comments
 (0)