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

Commit 8bdccb2

Browse files
committed
Add login button to Open from GitHub
1 parent 435a838 commit 8bdccb2

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/GitHub.App/SampleData/Dialog/Clone/RepositoryCloneViewModelDesigner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public RepositoryCloneViewModelDesigner()
2727
public IRepositorySelectViewModel EnterpriseTab { get; }
2828
public ReactiveCommand<Unit, Unit> Browse { get; }
2929
public ReactiveCommand<Unit, CloneDialogResult> Clone { get; }
30+
public ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }
3031

3132
public Task InitializeAsync(IConnection connection)
3233
{

src/GitHub.App/ViewModels/Dialog/Clone/RepositoryCloneViewModel.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2626
readonly IRepositoryCloneService service;
2727
readonly IGitService gitService;
2828
readonly IUsageTracker usageTracker;
29+
readonly IDialogService dialogService;
2930
readonly IReadOnlyList<IRepositoryCloneTabViewModel> tabs;
3031
string path;
3132
UriString url;
@@ -40,6 +41,7 @@ public RepositoryCloneViewModel(
4041
IRepositoryCloneService service,
4142
IGitService gitService,
4243
IUsageTracker usageTracker,
44+
IDialogService dialogService,
4345
IRepositorySelectViewModel gitHubTab,
4446
IRepositorySelectViewModel enterpriseTab)
4547
{
@@ -48,6 +50,7 @@ public RepositoryCloneViewModel(
4850
this.service = service;
4951
this.gitService = gitService;
5052
this.usageTracker = usageTracker;
53+
this.dialogService = dialogService;
5154

5255
GitHubTab = gitHubTab;
5356
EnterpriseTab = enterpriseTab;
@@ -82,6 +85,14 @@ public RepositoryCloneViewModel(
8285
Open = ReactiveCommand.CreateFromObservable(
8386
() => repository.Select(x => new CloneDialogResult(Path, x?.CloneUrl)),
8487
canOpen);
88+
89+
LoginAsDifferentUser = ReactiveCommand.CreateFromTask(async () =>
90+
{
91+
if (await dialogService.ShowLoginDialog() is IConnection connection)
92+
{
93+
await InitializeAsync(connection);
94+
}
95+
});
8596
}
8697

8798
public IRepositorySelectViewModel GitHubTab { get; }
@@ -111,6 +122,8 @@ public int SelectedTabIndex
111122

112123
public IObservable<object> Done => Observable.Merge(Clone, Open);
113124

125+
public ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }
126+
114127
public ReactiveCommand<Unit, Unit> Browse { get; }
115128

116129
public ReactiveCommand<Unit, CloneDialogResult> Clone { get; }
@@ -133,7 +146,11 @@ public async Task InitializeAsync(IConnection connection)
133146
EnterpriseTab.Initialize(enterpriseConnection);
134147
}
135148

136-
if (connection == enterpriseConnection)
149+
if (connection == gitHubConnection)
150+
{
151+
SelectedTabIndex = 0;
152+
}
153+
else if (connection == enterpriseConnection)
137154
{
138155
SelectedTabIndex = 1;
139156
}

src/GitHub.Exports.Reactive/ViewModels/Dialog/Clone/IRepositoryCloneViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ public interface IRepositoryCloneViewModel : IDialogContentViewModel, IConnectio
5353
/// Gets the command executed when the user clicks "Clone".
5454
/// </summary>
5555
ReactiveCommand<Unit, CloneDialogResult> Clone { get; }
56+
57+
ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }
5658
}
5759
}

src/GitHub.VisualStudio.UI/Views/Dialog/Clone/RepositoryCloneView.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121

2222
<DockPanel>
2323
<StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" HorizontalAlignment="Right" Margin="0,18,0,0">
24+
<Button
25+
Margin="0,0,6,0"
26+
HorizontalAlignment="Center"
27+
IsDefault="True"
28+
Command="{Binding LoginAsDifferentUser}"
29+
Content="Login"
30+
KeyboardNavigation.TabIndex="5" />
31+
2432
<Button
2533
HorizontalAlignment="Center"
2634
IsDefault="True"

0 commit comments

Comments
 (0)