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

Commit f3de109

Browse files
authored
Merge pull request #1672 from github/fixes/fork-back-button
Adding functionality to the back button in the fork view
2 parents 501f239 + 90cad7e commit f3de109

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

src/GitHub.App/SampleData/ForkRepositoryExecuteViewModelDesigner.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public ForkRepositoryExecuteViewModelDesigner()
3030

3131
public IObservable<object> Done => null;
3232

33+
public IObservable<object> Back => null;
34+
3335
public string Title => null;
3436

3537
public IRepositoryModel SourceRepository { get; set; }
@@ -40,6 +42,8 @@ public ForkRepositoryExecuteViewModelDesigner()
4042

4143
public IReactiveCommand<Repository> CreateFork => null;
4244

45+
public IReactiveCommand<object> BackCommand => null;
46+
4347
public bool ResetMasterTracking { get; set; } = true;
4448

4549
public bool AddUpstream { get; set; } = true;

src/GitHub.App/ViewModels/Dialog/ForkRepositoryExecuteViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ IRepositoryForkService repositoryForkService
4545
.Subscribe(tuple => CanResetMasterTracking = tuple.Item1 && tuple.Item2);
4646

4747
CreateFork = ReactiveCommand.CreateAsyncObservable(OnCreateFork);
48+
BackCommand = ReactiveCommand.Create();
4849
}
4950

5051
public IRepositoryModel SourceRepository { get; private set; }
@@ -55,10 +56,14 @@ IRepositoryForkService repositoryForkService
5556

5657
public IReactiveCommand<Repository> CreateFork { get; }
5758

59+
public IReactiveCommand<object> BackCommand { get; }
60+
5861
public string Title => Resources.ForkRepositoryTitle;
5962

6063
public IObservable<object> Done => CreateFork.Where(repository => repository != null);
6164

65+
public IObservable<object> Back => BackCommand.AsObservable();
66+
6267
public async Task InitializeAsync(ILocalRepositoryModel sourceRepository, IAccount destinationAccount, IConnection connection)
6368
{
6469
var modelService = await modelServiceFactory.CreateAsync(connection);
@@ -140,6 +145,7 @@ public bool ResetMasterTracking
140145
}
141146

142147
string error = null;
148+
143149
public string Error
144150
{
145151
get { return error; }

src/GitHub.App/ViewModels/Dialog/ForkRepositoryViewModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public ForkRepositoryViewModel(
3333

3434
selectPage.SwitchOrigin.Subscribe(x => ShowSwitchRepositoryPath((IRemoteRepositoryModel)x));
3535
selectPage.Done.Subscribe(x => ShowExecutePage((IAccount)x).Forget());
36+
executePage.Back.Subscribe(x => ShowSelectPage().Forget());
3637
}
3738

3839
public ILocalRepositoryModel Repository { get; private set; }
@@ -47,7 +48,12 @@ public async Task InitializeAsync(ILocalRepositoryModel repository, IConnection
4748
{
4849
Repository = repository;
4950
Connection = connection;
50-
await selectPage.InitializeAsync(repository, connection);
51+
await ShowSelectPage();
52+
}
53+
54+
async Task ShowSelectPage()
55+
{
56+
await selectPage.InitializeAsync(Repository, Connection);
5157
Content = selectPage;
5258
}
5359

src/GitHub.Exports.Reactive/ViewModels/Dialog/IForkRepositoryExecuteViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public interface IForkRepositoryExecuteViewModel : IDialogContentViewModel
2323
/// </summary>
2424
IReactiveCommand<Repository> CreateFork { get; }
2525

26+
IReactiveCommand<object> BackCommand { get; }
27+
2628
bool ResetMasterTracking { get; set; }
2729

2830
bool AddUpstream { get; set; }
@@ -34,6 +36,7 @@ public interface IForkRepositoryExecuteViewModel : IDialogContentViewModel
3436
bool CanResetMasterTracking { get; }
3537

3638
string Error { get; }
39+
IObservable<object> Back { get; }
3740

3841
/// <summary>
3942
/// Initializes the view model.

src/GitHub.VisualStudio/Views/Dialog/ForkRepositoryExecuteView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
Visibility="{Binding Error, Converter={ui:NullToVisibilityConverter}}"
9090
HorizontalAlignment="Left" />
9191
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
92-
<Button HorizontalAlignment="Right" Margin="0 0 4 0">Back</Button>
92+
<Button HorizontalAlignment="Right" Margin="0 0 4 0" Click="backButton_OnClick">Back</Button>
9393
<Button HorizontalAlignment="Right" Click="repoForkButton_OnClick">Fork Repo</Button>
9494
</StackPanel>
9595
</Grid>

src/GitHub.VisualStudio/Views/Dialog/ForkRepositoryExecuteView.xaml.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ private void repoForkButton_OnClick(object sender, RoutedEventArgs e)
1919
{
2020
((IForkRepositoryExecuteViewModel)DataContext).CreateFork.Execute(new object());
2121
}
22+
23+
private void backButton_OnClick(object sender, RoutedEventArgs e)
24+
{
25+
((IForkRepositoryExecuteViewModel)DataContext).BackCommand.Execute(new object());
26+
}
2227
}
2328
}

0 commit comments

Comments
 (0)