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

Commit e550bad

Browse files
committed
Add option to add/change accounts from publish view
1 parent b4a400b commit e550bad

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

src/GitHub.App/SampleData/SampleViewModels.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ public ReactiveCommand<Unit, ProgressState> PublishRepository
214214
private set;
215215
}
216216

217+
public ReactiveCommand<Unit, Unit> LoginAsDifferentUser
218+
{
219+
get;
220+
private set;
221+
}
222+
217223
public IReadOnlyObservableCollection<IConnection> Connections
218224
{
219225
get;

src/GitHub.App/ViewModels/TeamExplorer/RepositoryPublishViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Linq;
77
using System.Reactive;
88
using System.Reactive.Linq;
9-
using GitHub.App;
9+
using System.Threading.Tasks;
1010
using GitHub.Extensions;
1111
using GitHub.Extensions.Reactive;
1212
using GitHub.Factories;
@@ -29,6 +29,7 @@ public class RepositoryPublishViewModel : RepositoryFormViewModel, IRepositoryPu
2929
readonly IRepositoryPublishService repositoryPublishService;
3030
readonly INotificationService notificationService;
3131
readonly IModelServiceFactory modelServiceFactory;
32+
readonly IDialogService dialogService;
3233
readonly ObservableAsPropertyHelper<IReadOnlyList<IAccount>> accounts;
3334
readonly ObservableAsPropertyHelper<bool> isHostComboBoxVisible;
3435
readonly IUsageTracker usageTracker;
@@ -39,17 +40,20 @@ public RepositoryPublishViewModel(
3940
INotificationService notificationService,
4041
IConnectionManager connectionManager,
4142
IModelServiceFactory modelServiceFactory,
43+
IDialogService dialogService,
4244
IUsageTracker usageTracker)
4345
{
4446
Guard.ArgumentNotNull(repositoryPublishService, nameof(repositoryPublishService));
4547
Guard.ArgumentNotNull(notificationService, nameof(notificationService));
4648
Guard.ArgumentNotNull(connectionManager, nameof(connectionManager));
4749
Guard.ArgumentNotNull(usageTracker, nameof(usageTracker));
4850
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
51+
Guard.ArgumentNotNull(dialogService, nameof(dialogService));
4952

5053
this.notificationService = notificationService;
5154
this.usageTracker = usageTracker;
5255
this.modelServiceFactory = modelServiceFactory;
56+
this.dialogService = dialogService;
5357

5458
Connections = connectionManager.Connections;
5559
this.repositoryPublishService = repositoryPublishService;
@@ -83,6 +87,8 @@ public RepositoryPublishViewModel(
8387
PublishRepository = InitializePublishRepositoryCommand();
8488
PublishRepository.IsExecuting.Subscribe(x => IsBusy = x);
8589

90+
LoginAsDifferentUser = ReactiveCommand.CreateFromTask(LoginAsDifferentUserAsync);
91+
8692
var defaultRepositoryName = repositoryPublishService.LocalRepositoryName;
8793
if (!string.IsNullOrEmpty(defaultRepositoryName))
8894
RepositoryName = defaultRepositoryName;
@@ -101,6 +107,9 @@ public RepositoryPublishViewModel(
101107
}
102108

103109
public ReactiveCommand<Unit, ProgressState> PublishRepository { get; private set; }
110+
111+
public ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; private set; }
112+
104113
public IReadOnlyObservableCollection<IConnection> Connections { get; private set; }
105114

106115
bool isBusy;
@@ -127,6 +136,11 @@ public bool IsHostComboBoxVisible
127136
get { return isHostComboBoxVisible.Value; }
128137
}
129138

139+
Task LoginAsDifferentUserAsync()
140+
{
141+
return dialogService.ShowLoginDialog();
142+
}
143+
130144
ReactiveCommand<Unit, ProgressState> InitializePublishRepositoryCommand()
131145
{
132146
var canCreate = this.WhenAny(x => x.RepositoryNameValidator.ValidationResult.IsValid, x => x.Value);

src/GitHub.Exports.Reactive/ViewModels/TeamExplorer/IRepositoryPublishViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public interface IRepositoryPublishViewModel : IViewModel, IRepositoryForm
1919
/// </summary>
2020
ReactiveCommand<Unit, ProgressState> PublishRepository { get; }
2121

22+
/// <summary>
23+
/// Command that shows login dialog.
24+
/// </summary>
25+
ReactiveCommand<Unit, Unit> LoginAsDifferentUser { get; }
26+
2227
/// <summary>
2328
/// Determines whether the host combo box is visible. Only true if the user is logged into more than one host.
2429
/// </summary>

src/GitHub.VisualStudio.UI/Views/TeamExplorer/RepositoryPublishView.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
Orientation="Vertical"
4848
Style="{DynamicResource DialogContainerStackPanel}">
4949

50+
<TextBlock TextAlignment="Right">
51+
<Hyperlink Command="{Binding LoginAsDifferentUser}">
52+
<Run Text="{x:Static ghfvs:Resources.AddChangeAccounts}" />
53+
</Hyperlink>
54+
</TextBlock>
55+
5056
<DockPanel Margin="0,0,0,13" VerticalAlignment="Top">
5157
<ghfvs:OcticonImage x:Name="octokit"
5258
Width="32"

0 commit comments

Comments
 (0)