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

Commit 049bfc3

Browse files
authored
Merge branch 'master' into fixes/remove-experimental-PR-file-margin
2 parents f3d3f52 + 762d6cf commit 049bfc3

37 files changed

+1290
-225
lines changed

Directory.Build.Props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<Product>GitHub Extension for Visual Studio</Product>
4-
<Version>2.10.3.0</Version>
4+
<Version>2.10.8.0</Version>
55
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright>
66
<LangVersion>7.3</LangVersion>
77
</PropertyGroup>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: Visual Studio 2019 Preview
2-
version: '2.10.3.{build}'
2+
version: '2.10.8.{build}'
33
skip_tags: true
44

55
install:

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: 18 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,14 @@ public bool IsHostComboBoxVisible
127136
get { return isHostComboBoxVisible.Value; }
128137
}
129138

139+
async Task LoginAsDifferentUserAsync()
140+
{
141+
if (await dialogService.ShowLoginDialog() is IConnection connection)
142+
{
143+
SelectedConnection = connection;
144+
}
145+
}
146+
130147
ReactiveCommand<Unit, ProgressState> InitializePublishRepositoryCommand()
131148
{
132149
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.InlineReviews/Margins/InlineCommentMarginProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Microsoft.VisualStudio.Text.Classification;
88
using GitHub.Services;
99
using GitHub.VisualStudio;
10-
using GitHub.InlineReviews.Services;
1110

1211
namespace GitHub.InlineReviews.Margins
1312
{
@@ -16,7 +15,9 @@ namespace GitHub.InlineReviews.Margins
1615
[Order(After = PredefinedMarginNames.Glyph)]
1716
[MarginContainer(PredefinedMarginNames.Left)]
1817
[ContentType("text")]
19-
[TextViewRole(PredefinedTextViewRoles.Interactive)]
18+
[TextViewRole("LEFTDIFF")]
19+
[TextViewRole("RIGHTDIFF")]
20+
[TextViewRole("INLINEDIFF")]
2021
internal sealed class InlineCommentMarginProvider : IWpfTextViewMarginProvider
2122
{
2223
readonly Lazy<IEditorFormatMapService> editorFormatMapService;

src/GitHub.InlineReviews/Tags/InlineCommentTaggerProvider.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.ComponentModel.Composition;
33
using GitHub.Extensions;
4-
using GitHub.InlineReviews.Services;
54
using GitHub.Services;
65
using Microsoft.VisualStudio.Text;
6+
using Microsoft.VisualStudio.Text.Differencing;
77
using Microsoft.VisualStudio.Text.Editor;
88
using Microsoft.VisualStudio.Text.Tagging;
99
using Microsoft.VisualStudio.Utilities;
@@ -16,6 +16,9 @@ namespace GitHub.InlineReviews.Tags
1616
[Export(typeof(IViewTaggerProvider))]
1717
[ContentType("text")]
1818
[TagType(typeof(ShowInlineCommentTag))]
19+
[TextViewRole("LEFTDIFF")]
20+
[TextViewRole("RIGHTDIFF")]
21+
[TextViewRole("INLINEDIFF")]
1922
class InlineCommentTaggerProvider : IViewTaggerProvider
2023
{
2124
readonly IPullRequestSessionManager sessionManager;
@@ -31,11 +34,22 @@ public InlineCommentTaggerProvider(
3134

3235
public ITagger<T> CreateTagger<T>(ITextView view, ITextBuffer buffer) where T : ITag
3336
{
34-
return buffer.Properties.GetOrCreateSingletonProperty(() =>
35-
new InlineCommentTagger(
36-
view,
37-
buffer,
38-
sessionManager)) as ITagger<T>;
37+
if (view.TextViewModel is IDifferenceTextViewModel model)
38+
{
39+
if (buffer == model.Viewer.DifferenceBuffer.BaseLeftBuffer)
40+
{
41+
return view.Properties.GetOrCreateSingletonProperty("InlineTaggerForLeftBuffer",
42+
() => new InlineCommentTagger(view, buffer, sessionManager) as ITagger<T>);
43+
}
44+
45+
if (buffer == model.Viewer.DifferenceBuffer.BaseRightBuffer)
46+
{
47+
return view.Properties.GetOrCreateSingletonProperty("InlineTaggerForRightBuffer",
48+
() => new InlineCommentTagger(view, buffer, sessionManager) as ITagger<T>);
49+
}
50+
}
51+
52+
return null;
3953
}
4054
}
4155
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved. This code released
3+
* under the terms of the Microsoft Limited Public License (MS-LPL).
4+
*/
5+
using System;
6+
using System.ComponentModel;
7+
using System.Diagnostics;
8+
using Microsoft.TeamFoundation.Client;
9+
using Microsoft.TeamFoundation.Controls;
10+
11+
namespace GitHub.VisualStudio
12+
{
13+
/// <summary>
14+
/// Team Explorer plugin common base class.
15+
/// </summary>
16+
public class TeamExplorerBase : IDisposable, INotifyPropertyChanged
17+
{
18+
#region Members
19+
20+
private bool m_contextSubscribed = false;
21+
22+
#endregion
23+
24+
/// <summary>
25+
/// Get/set the service provider.
26+
/// </summary>
27+
public IServiceProvider ServiceProvider
28+
{
29+
get { return m_serviceProvider; }
30+
set
31+
{
32+
// Unsubscribe from Team Foundation context changes
33+
if (m_serviceProvider != null)
34+
{
35+
UnsubscribeContextChanges();
36+
}
37+
38+
m_serviceProvider = value;
39+
40+
// Subscribe to Team Foundation context changes
41+
if (m_serviceProvider != null)
42+
{
43+
SubscribeContextChanges();
44+
}
45+
}
46+
}
47+
private IServiceProvider m_serviceProvider = null;
48+
49+
/// <summary>
50+
/// Get the requested service from the service provider.
51+
/// </summary>
52+
public T GetService<T>()
53+
{
54+
Debug.Assert(this.ServiceProvider != null, "GetService<T> called before service provider is set");
55+
if (this.ServiceProvider != null)
56+
{
57+
return (T)this.ServiceProvider.GetService(typeof(T));
58+
}
59+
60+
return default(T);
61+
}
62+
63+
/// <summary>
64+
/// Show a notification in the Team Explorer window.
65+
/// </summary>
66+
protected Guid ShowNotification(string message, NotificationType type)
67+
{
68+
ITeamExplorer teamExplorer = GetService<ITeamExplorer>();
69+
if (teamExplorer != null)
70+
{
71+
Guid guid = Guid.NewGuid();
72+
teamExplorer.ShowNotification(message, type, NotificationFlags.None, null, guid);
73+
return guid;
74+
}
75+
76+
return Guid.Empty;
77+
}
78+
79+
#region IDisposable
80+
81+
/// <summary>
82+
/// Dispose.
83+
/// </summary>
84+
public virtual void Dispose()
85+
{
86+
UnsubscribeContextChanges();
87+
}
88+
89+
#endregion
90+
91+
#region INotifyPropertyChanged
92+
93+
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
94+
95+
/// <summary>
96+
/// Raise the PropertyChanged event for the specified property.
97+
/// </summary>
98+
/// <param name="propertyName">Property name</param>
99+
protected void RaisePropertyChanged(string propertyName)
100+
{
101+
if (this.PropertyChanged != null)
102+
{
103+
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
104+
}
105+
}
106+
107+
#endregion
108+
109+
#region Team Foundation Context
110+
111+
/// <summary>
112+
/// Subscribe to context changes.
113+
/// </summary>
114+
protected void SubscribeContextChanges()
115+
{
116+
Debug.Assert(this.ServiceProvider != null, "ServiceProvider must be set before subscribing to context changes");
117+
if (this.ServiceProvider == null || m_contextSubscribed)
118+
{
119+
return;
120+
}
121+
122+
ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
123+
if (tfContextManager != null)
124+
{
125+
tfContextManager.ContextChanged += ContextChanged;
126+
m_contextSubscribed = true;
127+
}
128+
}
129+
130+
/// <summary>
131+
/// Unsubscribe from context changes.
132+
/// </summary>
133+
protected void UnsubscribeContextChanges()
134+
{
135+
if (this.ServiceProvider == null || !m_contextSubscribed)
136+
{
137+
return;
138+
}
139+
140+
ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
141+
if (tfContextManager != null)
142+
{
143+
tfContextManager.ContextChanged -= ContextChanged;
144+
}
145+
}
146+
147+
/// <summary>
148+
/// ContextChanged event handler.
149+
/// </summary>
150+
protected virtual void ContextChanged(object sender, ContextChangedEventArgs e)
151+
{
152+
}
153+
154+
/// <summary>
155+
/// Get the current Team Foundation context.
156+
/// </summary>
157+
protected ITeamFoundationContext CurrentContext
158+
{
159+
get
160+
{
161+
ITeamFoundationContextManager tfContextManager = GetService<ITeamFoundationContextManager>();
162+
if (tfContextManager != null)
163+
{
164+
return tfContextManager.CurrentContext;
165+
}
166+
167+
return null;
168+
}
169+
}
170+
171+
#endregion
172+
}
173+
}

0 commit comments

Comments
 (0)