66using System . Linq ;
77using System . Reactive ;
88using System . Reactive . Linq ;
9- using GitHub . App ;
9+ using System . Threading . Tasks ;
1010using GitHub . Extensions ;
1111using GitHub . Extensions . Reactive ;
1212using 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 ) ;
0 commit comments