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

Commit 85916ec

Browse files
Rename Edit to Create
1 parent 8178f40 commit 85916ec

13 files changed

+58
-58
lines changed

src/GitHub.InlineReviews/SampleData/CommentViewModelDesigner.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public CommentViewModelDesigner()
2828
public DateTimeOffset UpdatedAt => DateTime.Now.Subtract(TimeSpan.FromDays(3));
2929
public IAccount User { get; set; }
3030

31-
public ReactiveCommand<object> BeginEdit { get; }
32-
public ReactiveCommand<object> CancelEdit { get; }
33-
public ReactiveCommand<Unit> CommitEdit { get; }
31+
public ReactiveCommand<object> BeginCreate { get; }
32+
public ReactiveCommand<object> CancelCreate { get; }
33+
public ReactiveCommand<Unit> CommitCreate { get; }
3434
public ReactiveCommand<object> OpenOnGitHub { get; }
3535
public ReactiveCommand<object> Delete { get; }
3636
}

src/GitHub.InlineReviews/Services/InlineCommentPeekService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public ITrackingPoint Show(ITextView textView, AddInlineCommentTag tag)
111111
if (item != null)
112112
{
113113
var placeholder = item.ViewModel.Thread.Comments.Last();
114-
placeholder.CancelEdit.Take(1).Subscribe(_ => session.Dismiss());
114+
placeholder.CancelCreate.Take(1).Subscribe(_ => session.Dismiss());
115115
}
116116

117117
return trackingPoint;

src/GitHub.InlineReviews/ViewModels/CommentViewModel.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,27 @@ protected CommentViewModel(
6666

6767
Delete = ReactiveCommand.Create(canDelete);
6868

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

74-
BeginEdit = ReactiveCommand.Create(canEdit);
75-
BeginEdit.Subscribe(DoBeginEdit);
76-
AddErrorHandler(BeginEdit);
74+
BeginCreate = ReactiveCommand.Create(canCreate);
75+
BeginCreate.Subscribe(DoBeginCreate);
76+
AddErrorHandler(BeginCreate);
7777

78-
CommitEdit = ReactiveCommand.CreateAsyncTask(
78+
CommitCreate = ReactiveCommand.CreateAsyncTask(
7979
Observable.CombineLatest(
8080
this.WhenAnyValue(x => x.IsReadOnly),
8181
this.WhenAnyValue(x => x.Body, x => !string.IsNullOrWhiteSpace(x)),
8282
this.WhenAnyObservable(x => x.Thread.PostComment.CanExecuteObservable),
8383
(readOnly, hasBody, canPost) => !readOnly && hasBody && canPost),
84-
DoCommitEdit);
85-
AddErrorHandler(CommitEdit);
84+
DoCommitCreate);
85+
AddErrorHandler(CommitCreate);
8686

87-
CancelEdit = ReactiveCommand.Create(CommitEdit.IsExecuting.Select(x => !x));
88-
CancelEdit.Subscribe(DoCancelEdit);
89-
AddErrorHandler(CancelEdit);
87+
CancelCreate = ReactiveCommand.Create(CommitCreate.IsExecuting.Select(x => !x));
88+
CancelCreate.Subscribe(DoCancelCreate);
89+
AddErrorHandler(CancelCreate);
9090

9191
OpenOnGitHub = ReactiveCommand.Create(this.WhenAnyValue(x => x.Id, x => x != 0));
9292
}
@@ -110,18 +110,18 @@ protected void AddErrorHandler<T>(ReactiveCommand<T> command)
110110
command.ThrownExceptions.Subscribe(x => ErrorMessage = x.Message);
111111
}
112112

113-
void DoBeginEdit(object unused)
113+
void DoBeginCreate(object unused)
114114
{
115-
if (state != CommentEditState.Editing)
115+
if (state != CommentEditState.Creating)
116116
{
117117
undoBody = Body;
118-
EditState = CommentEditState.Editing;
118+
EditState = CommentEditState.Creating;
119119
}
120120
}
121121

122-
void DoCancelEdit(object unused)
122+
void DoCancelCreate(object unused)
123123
{
124-
if (EditState == CommentEditState.Editing)
124+
if (EditState == CommentEditState.Creating)
125125
{
126126
EditState = string.IsNullOrWhiteSpace(undoBody) ? CommentEditState.Placeholder : CommentEditState.None;
127127
Body = undoBody;
@@ -130,7 +130,7 @@ void DoCancelEdit(object unused)
130130
}
131131
}
132132

133-
async Task DoCommitEdit(object unused)
133+
async Task DoCommitCreate(object unused)
134134
{
135135
try
136136
{
@@ -213,13 +213,13 @@ public DateTimeOffset UpdatedAt
213213
public IAccount User { get; }
214214

215215
/// <inheritdoc/>
216-
public ReactiveCommand<object> BeginEdit { get; }
216+
public ReactiveCommand<object> BeginCreate { get; }
217217

218218
/// <inheritdoc/>
219-
public ReactiveCommand<object> CancelEdit { get; }
219+
public ReactiveCommand<object> CancelCreate { get; }
220220

221221
/// <inheritdoc/>
222-
public ReactiveCommand<Unit> CommitEdit { get; }
222+
public ReactiveCommand<Unit> CommitCreate { get; }
223223

224224
/// <inheritdoc/>
225225
public ReactiveCommand<object> OpenOnGitHub { get; }

src/GitHub.InlineReviews/ViewModels/ICommentViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace GitHub.InlineReviews.ViewModels
99
public enum CommentEditState
1010
{
1111
None,
12-
Editing,
12+
Creating,
1313
Placeholder,
1414
}
1515

@@ -72,17 +72,17 @@ public interface ICommentViewModel : IViewModel
7272
/// <summary>
7373
/// Gets a command which will begin editing of the comment.
7474
/// </summary>
75-
ReactiveCommand<object> BeginEdit { get; }
75+
ReactiveCommand<object> BeginCreate { get; }
7676

7777
/// <summary>
7878
/// Gets a command which will cancel editing of the comment.
7979
/// </summary>
80-
ReactiveCommand<object> CancelEdit { get; }
80+
ReactiveCommand<object> CancelCreate { get; }
8181

8282
/// <summary>
8383
/// Gets a command which will commit edits to the comment.
8484
/// </summary>
85-
ReactiveCommand<Unit> CommitEdit { get; }
85+
ReactiveCommand<Unit> CommitCreate { get; }
8686

8787
/// <summary>
8888
/// Gets a command to open the comment in a browser.

src/GitHub.InlineReviews/ViewModels/InlineCommentPeekViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async Task UpdateThread()
185185

186186
if (placeholder?.EditState == CommentEditState.Placeholder)
187187
{
188-
await placeholder.BeginEdit.ExecuteAsync(null);
188+
await placeholder.BeginCreate.ExecuteAsync(null);
189189
placeholder.Body = placeholderBody;
190190
}
191191
}
@@ -212,7 +212,7 @@ string GetPlaceholderBodyToPreserve()
212212
{
213213
var lastComment = Thread?.Comments.LastOrDefault();
214214

215-
if (lastComment?.EditState == CommentEditState.Editing)
215+
if (lastComment?.EditState == CommentEditState.Creating)
216216
{
217217
if (!lastComment.IsSubmitting) return lastComment.Body;
218218
}

src/GitHub.InlineReviews/ViewModels/NewInlineCommentThreadViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public NewInlineCommentThreadViewModel(
4646
DoPostComment);
4747

4848
var placeholder = PullRequestReviewCommentViewModel.CreatePlaceholder(session, this, CurrentUser);
49-
placeholder.BeginEdit.Execute(null);
49+
placeholder.BeginCreate.Execute(null);
5050
this.WhenAnyValue(x => x.NeedsPush).Subscribe(x => placeholder.IsReadOnly = x);
5151
Comments.Add(placeholder);
5252

src/GitHub.InlineReviews/ViewModels/PullRequestReviewCommentViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public PullRequestReviewCommentViewModel(
6161
.ToProperty(this, x => x.CommitCaption);
6262

6363
StartReview = ReactiveCommand.CreateAsyncTask(
64-
CommitEdit.CanExecuteObservable,
64+
CommitCreate.CanExecuteObservable,
6565
DoStartReview);
6666
AddErrorHandler(StartReview);
6767
}
@@ -125,7 +125,7 @@ async Task DoStartReview(object unused)
125125
try
126126
{
127127
await session.StartReview();
128-
await CommitEdit.ExecuteAsync(null);
128+
await CommitCreate.ExecuteAsync(null);
129129
}
130130
finally
131131
{

src/GitHub.InlineReviews/Views/CommentView.xaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
HorizontalAlignment="Right"
8080
DockPanel.Dock="Right"/>
8181
<ui:GitHubActionLink Content="Edit"
82-
Command="{Binding BeginEdit}"
82+
Command="{Binding BeginCreate}"
8383
Foreground="{DynamicResource GitHubVsToolWindowText}"
8484
Opacity="0.75"
8585
HorizontalAlignment="Right"
@@ -102,7 +102,7 @@
102102
<DataTrigger Binding="{Binding EditState}" Value="Placeholder">
103103
<Setter Property="Visibility" Value="Visible"/>
104104
</DataTrigger>
105-
<DataTrigger Binding="{Binding EditState}" Value="Editing">
105+
<DataTrigger Binding="{Binding EditState}" Value="Creating">
106106
<Setter Property="Visibility" Value="Visible"/>
107107
</DataTrigger>
108108
</Style.Triggers>
@@ -144,7 +144,7 @@
144144
<Setter Property="BorderBrush" Value="{DynamicResource GitHubVsBrandedUIBorder}" />
145145

146146
<Style.Triggers>
147-
<DataTrigger Binding="{Binding EditState}" Value="Editing">
147+
<DataTrigger Binding="{Binding EditState}" Value="Creating">
148148
<Setter Property="MinHeight" Value="100"/>
149149
<Setter Property="PromptText" Value="Leave a comment"/>
150150
</DataTrigger>
@@ -186,19 +186,19 @@
186186
<Style TargetType="FrameworkElement">
187187
<Setter Property="Visibility" Value="Collapsed"/>
188188
<Style.Triggers>
189-
<DataTrigger Binding="{Binding EditState}" Value="Editing">
189+
<DataTrigger Binding="{Binding EditState}" Value="Creating">
190190
<Setter Property="Visibility" Value="Visible"/>
191191
</DataTrigger>
192192
</Style.Triggers>
193193
</Style>
194194
</StackPanel.Style>
195-
<Button Command="{Binding CommitEdit}" Content="{Binding CommitCaption}"/>
195+
<Button Command="{Binding CommitCreate}" Content="{Binding CommitCaption}"/>
196196
<Button Margin="4 0 0 0"
197197
Command="{Binding StartReview}"
198198
Visibility="{Binding CanStartReview, Converter={ui:BooleanToVisibilityConverter}}">
199199
Start a review
200200
</Button>
201-
<Button Margin="4 0 0 0" Command="{Binding CancelEdit}">Cancel</Button>
201+
<Button Margin="4 0 0 0" Command="{Binding CancelCreate}">Cancel</Button>
202202
</StackPanel>
203203
</Grid>
204204
</Grid>

src/GitHub.InlineReviews/Views/CommentView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void CommentView_Loaded(object sender, System.Windows.RoutedEventArgs e)
4545

4646
private void ReplyPlaceholder_GotFocus(object sender, System.Windows.RoutedEventArgs e)
4747
{
48-
var command = ((ICommentViewModel)DataContext)?.BeginEdit;
48+
var command = ((ICommentViewModel)DataContext)?.BeginCreate;
4949

5050
if (command?.CanExecute(null) == true)
5151
{

test/GitHub.InlineReviews.UnitTests/ViewModels/InlineCommentPeekViewModelTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public async Task ThreadIsCreatedForNewComment()
6464

6565
Assert.That(target.Thread, Is.InstanceOf(typeof(NewInlineCommentThreadViewModel)));
6666
Assert.That(string.Empty, Is.EqualTo(target.Thread.Comments[0].Body));
67-
Assert.That(CommentEditState.Editing, Is.EqualTo(target.Thread.Comments[0].EditState));
67+
Assert.That(CommentEditState.Creating, Is.EqualTo(target.Thread.Comments[0].EditState));
6868
}
6969

7070
[Test]
@@ -131,7 +131,7 @@ public async Task SwitchesFromNewThreadToExistingThreadWhenCommentPosted()
131131
RaiseLinesChanged(file, Tuple.Create(8, DiffSide.Right));
132132
});
133133

134-
await target.Thread.Comments[0].CommitEdit.ExecuteAsyncTask(null);
134+
await target.Thread.Comments[0].CommitCreate.ExecuteAsyncTask(null);
135135

136136
Assert.That(target.Thread, Is.InstanceOf(typeof(InlineCommentThreadViewModel)));
137137
}
@@ -179,7 +179,7 @@ public async Task RetainsCommentBeingEditedWhenSessionRefreshed()
179179
Assert.That(2, Is.EqualTo(target.Thread.Comments.Count));
180180

181181
var placeholder = target.Thread.Comments.Last();
182-
placeholder.BeginEdit.Execute(null);
182+
placeholder.BeginCreate.Execute(null);
183183
placeholder.Body = "Comment being edited";
184184

185185
var file = await sessionManager.GetLiveFile(
@@ -190,7 +190,7 @@ public async Task RetainsCommentBeingEditedWhenSessionRefreshed()
190190

191191
placeholder = target.Thread.Comments.Last();
192192
Assert.That(3, Is.EqualTo(target.Thread.Comments.Count));
193-
Assert.That(CommentEditState.Editing, Is.EqualTo(placeholder.EditState));
193+
Assert.That(CommentEditState.Creating, Is.EqualTo(placeholder.EditState));
194194
Assert.That("Comment being edited", Is.EqualTo(placeholder.Body));
195195
}
196196

@@ -222,9 +222,9 @@ public async Task CommittingEditDoesntRetainSubmittedCommentInPlaceholderAfterPo
222222
});
223223

224224
var placeholder = target.Thread.Comments.Last();
225-
placeholder.BeginEdit.Execute(null);
225+
placeholder.BeginCreate.Execute(null);
226226
placeholder.Body = "Comment being edited";
227-
placeholder.CommitEdit.Execute(null);
227+
placeholder.CommitCreate.Execute(null);
228228

229229
placeholder = target.Thread.Comments.Last();
230230
Assert.That(CommentEditState.Placeholder, Is.EqualTo(placeholder.EditState));
@@ -259,7 +259,7 @@ public async Task StartingReviewDoesntRetainSubmittedCommentInPlaceholderAfterPo
259259
});
260260

261261
var placeholder = (IPullRequestReviewCommentViewModel)target.Thread.Comments.Last();
262-
placeholder.BeginEdit.Execute(null);
262+
placeholder.BeginCreate.Execute(null);
263263
placeholder.Body = "Comment being edited";
264264
placeholder.StartReview.Execute(null);
265265

0 commit comments

Comments
 (0)