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

Commit 5064ec4

Browse files
Controlling CanStartReview and CommitCaption
1 parent b9f7b41 commit 5064ec4

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

src/GitHub.InlineReviews/ViewModels/CommentViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected CommentViewModel(
7171

7272
var canEdit = this.WhenAnyValue(
7373
x => x.EditState,
74-
x => x == CommentEditState.Placeholder || (x == CommentEditState.None && user.Equals(currentUser)));
74+
x => x == CommentEditState.Placeholder || (x == CommentEditState.None && user.Login.Equals(currentUser.Login)));
7575

7676
BeginEdit = ReactiveCommand.Create(canEdit);
7777
BeginEdit.Subscribe(DoBeginEdit);

src/GitHub.InlineReviews/ViewModels/PullRequestReviewCommentViewModel.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Reactive;
45
using System.Reactive.Linq;
@@ -53,13 +54,16 @@ public PullRequestReviewCommentViewModel(
5354
this.session = session;
5455
IsPending = isPending;
5556

56-
canStartReview = session.WhenAnyValue(x => x.HasPendingReview, x => !x)
57-
.ToProperty(this, x => x.CanStartReview);
58-
commitCaption = session.WhenAnyValue(
59-
x => x.HasPendingReview,
60-
x => x ? Resources.AddReviewComment : Resources.AddSingleComment)
57+
var pendingReviewAndIdObservable = Observable.Zip(session.WhenAnyValue(x => x.HasPendingReview, x => !x), this.WhenAnyValue(model => model.Id, i => i == 0));
58+
59+
canStartReview = pendingReviewAndIdObservable
60+
.Select(list => list.All(b => b))
61+
.ToProperty(this, x => x.CanStartReview);
62+
63+
commitCaption = pendingReviewAndIdObservable
64+
.Select(list => !list[1] ? Resources.EditComment : list[0] ? Resources.AddReviewComment : Resources.AddSingleComment)
6165
.ToProperty(this, x => x.CommitCaption);
62-
66+
6367
StartReview = ReactiveCommand.CreateAsyncTask(
6468
CommitEdit.CanExecuteObservable,
6569
DoStartReview);
@@ -85,6 +89,7 @@ public PullRequestReviewCommentViewModel(
8589
/// <summary>
8690
/// Creates a placeholder comment which can be used to add a new comment to a thread.
8791
/// </summary>
92+
/// <param name="session">The pull request session.</param>
8893
/// <param name="thread">The comment thread.</param>
8994
/// <param name="currentUser">The current user.</param>
9095
/// <returns>THe placeholder comment.</returns>

src/GitHub.VisualStudio.UI/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.UI/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,7 @@
431431
<data name="Options_ForkButtonLabel" xml:space="preserve">
432432
<value>Show Fork button in Team Explorer</value>
433433
</data>
434+
<data name="EditComment" xml:space="preserve">
435+
<value>Edit Comment</value>
436+
</data>
434437
</root>

0 commit comments

Comments
 (0)