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

Commit 2aa0881

Browse files
Authenticating the user before showing the publish section view
co-authored-by: Jamie Cansdale <[email protected]>
1 parent 25878e0 commit 2aa0881

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/GitHub.VisualStudio.16/Sync/PublishSection.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
using System.Reactive.Linq;
66
using System.Windows;
77
using System.Windows.Input;
8+
using GitHub.Extensions;
89
using GitHub.Factories;
910
using GitHub.Primitives;
11+
using GitHub.Services;
1012
using GitHub.ViewModels.TeamExplorer;
1113
using GitHub.VisualStudio;
1214
using Microsoft.TeamFoundation.Controls;
1315
using Microsoft.VisualStudio.Shell;
16+
using Microsoft.VisualStudio.Threading;
1417
using ReactiveUI;
18+
using Task = System.Threading.Tasks.Task;
1519

1620

1721
namespace Microsoft.TeamExplorerSample.Sync
@@ -79,16 +83,29 @@ public override void Initialize(object sender, SectionInitializeEventArgs e)
7983
}
8084
}
8185

82-
PublishToGitHub = new RelayCommand(o => ShowPublishDialog());
86+
PublishToGitHub = new RelayCommand(o => ShowPublishDialog().Forget());
8387
}
8488

85-
void ShowPublishDialog()
89+
async Task ShowPublishDialog()
8690
{
8791
var exportProvider = compositionServices.GetExportProvider();
8892

93+
var connectionManager = exportProvider.GetExportedValue<IConnectionManager>();
94+
var loggedIn = await connectionManager.IsLoggedIn();
95+
if (!loggedIn)
96+
{
97+
var dialogService = exportProvider.GetExportedValue<IDialogService>();
98+
var connection = await dialogService.ShowLoginDialog();
99+
100+
if (connection == null)
101+
{
102+
return;
103+
}
104+
}
105+
89106
var factory = exportProvider.GetExportedValue<IViewViewModelFactory>();
90107
var viewModel = exportProvider.GetExportedValue<IRepositoryPublishViewModel>();
91-
108+
92109
var busy = viewModel.WhenAnyValue(x => x.IsBusy).Subscribe(x => IsBusy = x);
93110
var completed = viewModel.PublishRepository
94111
.Where(x => x == ProgressState.Success)

0 commit comments

Comments
 (0)