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

Commit 2376ace

Browse files
committed
Listen to all relevant notifications
There's two types of notifications that can come up via the Publish viewmodel: warnings from validators while filling out the form, and errors from the publish process. Errors are sent via the notification system, and warnings come up via the validators. We're doing it like this for now because warnings are reactive based on user input (so they go away if the validator becomes valid), and I'm still not sure if the NotificationDispatcher should have a `ClearNotifications` method (it's just dispatching messages, is it its job to invalidate messages too? unsure)
1 parent bfb2cd3 commit 2376ace

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/GitHub.VisualStudio/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.VisualStudio/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,7 @@
279279
<data name="NotLoggedInMessage" xml:space="preserve">
280280
<value>You are not logged in to {0}, so certain git operations may fail. [Login now]({1})</value>
281281
</data>
282+
<data name="RepositoryPublishedMessage" xml:space="preserve">
283+
<value>Repository created successfully.</value>
284+
</data>
282285
</root>

src/GitHub.VisualStudio/UI/Views/Controls/RepositoryPublishControl.xaml.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class GenericRepositoryPublishControl : SimpleViewUserControl<IRepository
2222
public partial class RepositoryPublishControl : GenericRepositoryPublishControl
2323
{
2424
[ImportingConstructor]
25-
public RepositoryPublishControl(ITeamExplorerServices teServices)
25+
public RepositoryPublishControl(ITeamExplorerServices teServices, INotificationDispatcher notifications)
2626
{
2727
InitializeComponent();
2828

@@ -33,7 +33,7 @@ public RepositoryPublishControl(ITeamExplorerServices teServices)
3333
d(this.Bind(ViewModel, vm => vm.SelectedConnection, v => v.hostsComboBox.SelectedItem));
3434

3535
d(this.Bind(ViewModel, vm => vm.RepositoryName, v => v.nameText.Text));
36-
36+
3737
d(this.Bind(ViewModel, vm => vm.Description, v => v.description.Text));
3838
d(this.Bind(ViewModel, vm => vm.KeepPrivate, v => v.makePrivate.IsChecked));
3939
d(this.OneWayBind(ViewModel, vm => vm.CanKeepPrivate, v => v.makePrivate.IsEnabled));
@@ -50,18 +50,26 @@ public RepositoryPublishControl(ITeamExplorerServices teServices)
5050
ViewModel.PublishRepository.Subscribe(state =>
5151
{
5252
if (state == ProgressState.Success)
53+
{
54+
teServices.ShowMessage(VisualStudio.Resources.RepositoryPublishedMessage);
5355
NotifyDone();
56+
}
5457
});
5558

5659
d(this.WhenAny(x => x.ViewModel.IsPublishing, x => x.Value)
5760
.Subscribe(x => NotifyIsBusy(x)));
5861

62+
63+
d(notifications.Listen()
64+
.Where(n => n.Type == Notification.NotificationType.Error)
65+
.Subscribe(n => teServices.ShowError(n.Message)));
66+
5967
d(this.WhenAny(x => x.ViewModel.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value)
6068
.WhereNotNull()
6169
.Select(result => result?.Message)
6270
.Subscribe(message =>
6371
{
64-
if (!string.IsNullOrEmpty(message))
72+
if (!String.IsNullOrEmpty(message))
6573
teServices.ShowWarning(message);
6674
else
6775
teServices.ClearNotifications();

0 commit comments

Comments
 (0)