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

Commit c228d9e

Browse files
Merge branch 'master' into feature/navigate-from-history-to-working-directory
2 parents 3081e24 + 90f30c6 commit c228d9e

23 files changed

+136
-58
lines changed

docs/developer/how-viewmodels-are-turned-into-views.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ This is the basis for converting view models to views.
6565

6666
There are currently two top-level controls for our UI:
6767

68-
- [GitHubDialogWindow](../src/GitHub.VisualStudio/Views/Dialog/GitHubDialogWindow.xaml) for the dialog which shows the login, clone, etc views
69-
- [GitHubPaneView](../src/GitHub.VisualStudio/Views/GitHubPane/GitHubPaneView.xaml) for the GitHub pane
68+
- [GitHubDialogWindow](../../src/GitHub.VisualStudio/Views/Dialog/GitHubDialogWindow.xaml) for the dialog which shows the login, clone, etc views
69+
- [GitHubPaneView](../../src/GitHub.VisualStudio/Views/GitHubPane/GitHubPaneView.xaml) for the GitHub pane
7070

7171
In the resources for each of these top-level controls we define a `DataTemplate` like so:
7272

@@ -77,10 +77,10 @@ In the resources for each of these top-level controls we define a `DataTemplate`
7777
</DataTemplate>
7878
```
7979

80-
The `DataTemplate.DataType` here applies the template to all classes inherited from [`GitHub.ViewModels.ViewModelBase`](../src/GitHub.Exports.Reactive/ViewModels/ViewModelBase.cs) [1]. The template defines a single `ContentControl` whose contents are created by a `ViewLocator`.
80+
The `DataTemplate.DataType` here applies the template to all classes inherited from [`GitHub.ViewModels.ViewModelBase`](../../src/GitHub.Exports.Reactive/ViewModels/ViewModelBase.cs) [1]. The template defines a single `ContentControl` whose contents are created by a `ViewLocator`.
8181

82-
The [`ViewLocator`](../src/GitHub.VisualStudio/Views/ViewLocator.cs) class is an `IValueConverter` which then creates an instance of the appropriate view for the view model using MEF.
82+
The [`ViewLocator`](../../src/GitHub.VisualStudio/Views/ViewLocator.cs) class is an `IValueConverter` which then creates an instance of the appropriate view for the view model using MEF.
8383

8484
And thus a view model becomes a view.
8585

86-
[1]: it would be nice to make it apply to all classes that inherit `IViewModel` but unfortunately WPF's `DataTemplate`s don't work with interfaces.
86+
[1]: it would be nice to make it apply to all classes that inherit `IViewModel` but unfortunately WPF's `DataTemplate`s don't work with interfaces.

src/GitHub.Exports.Reactive/Services/IPullRequestSession.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ Task PostReviewComment(
138138
/// <summary>
139139
/// Deletes a pull request comment.
140140
/// </summary>
141-
/// <param name="number">The number of the pull request comment to delete</param>
141+
/// <param name="pullRequestId">The number of the pull request id of the comment</param>
142+
/// <param name="commentDatabaseId">The number of the pull request comment to delete</param>
142143
/// <returns>A task which completes when the session has completed updating.</returns>
143-
Task DeleteComment(int number);
144+
Task DeleteComment(int pullRequestId, int commentDatabaseId);
144145

145146
/// <summary>
146147
/// Edit a PR review comment reply.

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<Compile Include="Services\IUsageService.cs" />
198198
<Compile Include="Settings\PkgCmdID.cs" />
199199
<Compile Include="ViewModels\GitHubPane\IGitHubPaneViewModel.cs" />
200+
<Compile Include="ViewModels\GitHubPane\IGitHubToolWindowManager.cs" />
200201
<Compile Include="ViewModels\IConnectionInitializedViewModel.cs" />
201202
<Compile Include="ViewModels\IInfoPanel.cs" />
202203
<Compile Include="ViewModels\IViewModel.cs" />

src/GitHub.Exports/Models/CommentModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ public class CommentModel
1111
/// Gets the ID of the comment.
1212
/// </summary>
1313
public string Id { get; set; }
14+
15+
/// <summary>
16+
/// Gets the DatabaseId of the comment.
17+
/// </summary>
18+
public int DatabaseId { get; set; }
19+
20+
/// <summary>
21+
/// Gets the PullRequestId of the comment.
22+
/// </summary>
23+
public int PullRequestId { get; set; }
24+
// The GraphQL Api does not allow for deleting of pull request comments.
25+
// REST Api must be used, and PullRequestId is needed to reload the pull request.
26+
// This field should be removed with better GraphQL support.
1427

1528
/// <summary>
1629
/// Gets the author of the comment.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using System.Runtime.InteropServices;
4+
5+
namespace GitHub.ViewModels.GitHubPane
6+
{
7+
/// <summary>
8+
/// The Visual Studio service interface for accessing the GitHub Pane.
9+
/// </summary>
10+
[Guid("FC9EC5B5-C297-4548-A229-F8E16365543C")]
11+
[ComVisible(true)]
12+
public interface IGitHubToolWindowManager
13+
{
14+
/// <summary>
15+
/// Ensure that the GitHub pane is created and visible.
16+
/// </summary>
17+
/// <returns>The view model for the GitHub Pane.</returns>
18+
Task<IGitHubPaneViewModel> ShowGitHubPane();
19+
}
20+
}

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@
191191
<Project>{9aea02db-02b5-409c-b0ca-115d05331a6b}</Project>
192192
<Name>GitHub.Exports</Name>
193193
</ProjectReference>
194+
<ProjectReference Include="..\GitHub.Extensions.Reactive\GitHub.Extensions.Reactive.csproj">
195+
<Project>{6559E128-8B40-49A5-85A8-05565ED0C7E3}</Project>
196+
<Name>GitHub.Extensions.Reactive</Name>
197+
</ProjectReference>
194198
<ProjectReference Include="..\GitHub.Extensions\GitHub.Extensions.csproj">
195199
<Project>{6AFE2E2D-6DB0-4430-A2EA-F5F5388D2F78}</Project>
196200
<Name>GitHub.Extensions</Name>

src/GitHub.InlineReviews/SampleData/CommentViewModelDesigner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public CommentViewModelDesigner()
1616
}
1717

1818
public string Id { get; set; }
19+
public int PullRequestId { get; set; }
20+
public int DatabaseId { get; set; }
1921
public string Body { get; set; }
2022
public string ErrorMessage { get; set; }
2123
public CommentEditState EditState { get; set; }

src/GitHub.InlineReviews/Services/IPullRequestSessionService.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,21 +322,20 @@ Task<PullRequestDetailModel> PostStandaloneReviewCommentReply(
322322
/// Delete a PR review comment.
323323
/// </summary>
324324
/// <param name="localRepository">The local repository.</param>
325-
/// <param name="remoteRepositoryOwner">The owner of the repository fork to delete from.</param>
326-
/// <param name="user">The user deleting the comment.</param>
327-
/// <param name="number">The pull request comment number.</param>
325+
/// <param name="remoteRepositoryOwner">The owner of the repository.</param>
326+
/// <param name="pullRequestId">The pull request id of the comment</param>
327+
/// <param name="commentDatabaseId">The pull request comment number.</param>
328328
/// <returns>The updated state of the pull request.</returns>
329-
Task<PullRequestDetailModel> DeleteComment(
330-
ILocalRepositoryModel localRepository,
329+
Task<PullRequestDetailModel> DeleteComment(ILocalRepositoryModel localRepository,
331330
string remoteRepositoryOwner,
332-
int number);
331+
int pullRequestId,
332+
int commentDatabaseId);
333333

334334
/// <summary>
335335
/// Edit a PR review comment.
336336
/// </summary>
337337
/// <param name="localRepository">The local repository.</param>
338-
/// <param name="remoteRepositoryOwner">The owner of the repository fork to delete from.</param>
339-
/// <param name="user">The user deleting the comment.</param>
338+
/// <param name="remoteRepositoryOwner">The owner of the repository.</param>
340339
/// <param name="commentNodeId">The pull request comment node id.</param>
341340
/// <param name="body">The replacement comment body.</param>
342341
/// <returns>The updated state of the pull request.</returns>

src/GitHub.InlineReviews/Services/InlineCommentPeekService.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ public ITrackingPoint Show(ITextView textView, AddInlineCommentTag tag)
107107

108108
var session = peekBroker.TriggerPeekSession(options);
109109
var item = session.PeekableItems.OfType<InlineCommentPeekableItem>().FirstOrDefault();
110-
111-
if (item != null)
112-
{
113-
var placeholder = item.ViewModel.Thread.Comments.Last();
114-
placeholder.CancelEdit.Take(1).Subscribe(_ => session.Dismiss());
115-
}
110+
item?.ViewModel.Close.Take(1).Subscribe(_ => session.Dismiss());
116111

117112
return trackingPoint;
118113
}
@@ -134,7 +129,9 @@ public ITrackingPoint Show(ITextView textView, ShowInlineCommentTag tag)
134129

135130
ExpandCollapsedRegions(textView, line.Extent);
136131

137-
peekBroker.TriggerPeekSession(options);
132+
var session = peekBroker.TriggerPeekSession(options);
133+
var item = session.PeekableItems.OfType<InlineCommentPeekableItem>().FirstOrDefault();
134+
item?.ViewModel.Close.Take(1).Subscribe(_ => session.Dismiss());
138135

139136
return trackingPoint;
140137
}

src/GitHub.InlineReviews/Services/PullRequestSession.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,15 @@ public async Task PostReviewComment(
159159
}
160160

161161
/// <inheritdoc/>
162-
public async Task DeleteComment(
163-
int number)
162+
public async Task DeleteComment(int pullRequestId, int commentDatabaseId)
164163
{
165-
await service.DeleteComment(
164+
var model = await service.DeleteComment(
166165
LocalRepository,
167166
RepositoryOwner,
168-
number);
167+
pullRequestId,
168+
commentDatabaseId);
169+
170+
await Update(model);
169171
}
170172

171173
/// <inheritdoc/>

0 commit comments

Comments
 (0)