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

Commit c3c03dd

Browse files
More code cleanup
1 parent 9c8a4d8 commit c3c03dd

File tree

6 files changed

+80
-103
lines changed

6 files changed

+80
-103
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationsViewModel.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
namespace GitHub.App.ViewModels.GitHubPane
1212
{
13-
/// <summary>
14-
/// A viewmodel which displays a list of annotations for a pull request's check run.
15-
/// </summary>
13+
/// <inheritdoc cref="IPullRequestAnnotationsViewModel"/>
1614
[Export(typeof(IPullRequestAnnotationsViewModel))]
1715
[PartCreationPolicy(CreationPolicy.NonShared)]
1816
public class PullRequestAnnotationsViewModel : PanePageViewModelBase, IPullRequestAnnotationsViewModel
@@ -62,28 +60,36 @@ public async Task InitializeAsync(ILocalRepositoryModel localRepository, IConnec
6260
}
6361
}
6462

63+
/// <inheritdoc/>
6564
public ILocalRepositoryModel LocalRepository { get; private set; }
6665

66+
/// <inheritdoc/>
6767
public string RemoteRepositoryOwner { get; private set; }
6868

69+
/// <inheritdoc/>
6970
public int PullRequestNumber { get; private set; }
7071

72+
/// <inheritdoc/>
7173
public int CheckRunId { get; private set; }
7274

75+
/// <inheritdoc/>
7376
public ReactiveCommand<object> NavigateToPullRequest { get; private set; }
7477

78+
/// <inheritdoc/>
7579
public string PullRequestTitle
7680
{
7781
get { return title; }
7882
private set { this.RaiseAndSetIfChanged(ref title, value); }
7983
}
8084

85+
/// <inheritdoc/>
8186
public string CheckRunName
8287
{
8388
get { return checkRunName; }
8489
private set { this.RaiseAndSetIfChanged(ref checkRunName, value); }
8590
}
8691

92+
/// <inheritdoc/>
8793
public IReadOnlyList<IPullRequestAnnotationItemViewModel> Annotations
8894
{
8995
get { return annotations; }

src/GitHub.App/ViewModels/GitHubPane/PullRequestCheckViewModel.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
using System.ComponentModel.Composition;
44
using System.Linq;
55
using System.Linq.Expressions;
6-
using System.Reactive;
7-
using System.Reactive.Linq;
8-
using System.Windows.Media.Imaging;
96
using GitHub.Extensions;
107
using GitHub.Factories;
118
using GitHub.Models;
@@ -14,13 +11,18 @@
1411

1512
namespace GitHub.ViewModels.GitHubPane
1613
{
14+
/// <inheritdoc cref="IPullRequestCheckViewModel"/>
1715
[Export(typeof(IPullRequestCheckViewModel))]
1816
[PartCreationPolicy(CreationPolicy.NonShared)]
1917
public class PullRequestCheckViewModel: ViewModelBase, IPullRequestCheckViewModel
2018
{
2119
private readonly IUsageTracker usageTracker;
22-
const string DefaultAvatar = "pack://application:,,,/GitHub.App;component/Images/default_user_avatar.png";
2320

21+
/// <summary>
22+
/// Factory method to create a <see cref="PullRequestCheckViewModel"/>.
23+
/// </summary>
24+
/// <param name="viewViewModelFactory">A viewviewmodel factory.</param>
25+
/// <param name="pullRequest">The pull request.</param>
2426
public static IEnumerable<IPullRequestCheckViewModel> Build(IViewViewModelFactory viewViewModelFactory, PullRequestDetailModel pullRequest)
2527
{
2628
var statuses = pullRequest.Statuses?.Select(statusModel =>
@@ -51,7 +53,7 @@ public static IEnumerable<IPullRequestCheckViewModel> Build(IViewViewModelFactor
5153
pullRequestCheckViewModel.DetailsUrl = !string.IsNullOrEmpty(statusModel.TargetUrl) ? new Uri(statusModel.TargetUrl) : null;
5254

5355
return pullRequestCheckViewModel;
54-
}) ?? new PullRequestCheckViewModel[0];
56+
}) ?? Array.Empty<PullRequestCheckViewModel>();
5557

5658
var checks = pullRequest.CheckSuites?.SelectMany(checkSuiteModel => checkSuiteModel.CheckRuns)
5759
.Select(checkRunModel =>
@@ -99,11 +101,15 @@ public static IEnumerable<IPullRequestCheckViewModel> Build(IViewViewModelFactor
99101
pullRequestCheckViewModel.DetailsUrl = new Uri(checkRunModel.DetailsUrl);
100102

101103
return pullRequestCheckViewModel;
102-
}) ?? new PullRequestCheckViewModel[0];
104+
}) ?? Array.Empty<PullRequestCheckViewModel>();
103105

104106
return statuses.Concat(checks).OrderBy(model => model.Title);
105107
}
106108

109+
/// <summary>
110+
/// Initializes a new instance of <see cref="PullRequestCheckViewModel"/>.
111+
/// </summary>
112+
/// <param name="usageTracker">The usage tracker.</param>
107113
[ImportingConstructor]
108114
public PullRequestCheckViewModel(IUsageTracker usageTracker)
109115
{
@@ -125,21 +131,29 @@ private void DoOpenDetailsUrl(object obj)
125131

126132
usageTracker.IncrementCounter(expression).Forget();
127133
}
128-
134+
135+
/// <inheritdoc/>
129136
public string Title { get; private set; }
130137

138+
/// <inheritdoc/>
131139
public string Description { get; private set; }
132140

141+
/// <inheritdoc/>
133142
public PullRequestCheckType CheckType { get; private set; }
134143

144+
/// <inheritdoc/>
135145
public int CheckRunId { get; private set; }
136146

147+
/// <inheritdoc/>
137148
public bool HasAnnotations { get; private set; }
138149

150+
/// <inheritdoc/>
139151
public PullRequestCheckStatus Status{ get; private set; }
140152

153+
/// <inheritdoc/>
141154
public Uri DetailsUrl { get; private set; }
142155

156+
/// <inheritdoc/>
143157
public ReactiveCommand<object> OpenDetailsUrl { get; }
144158
}
145159
}

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 27 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
namespace GitHub.ViewModels.GitHubPane
2525
{
26-
/// <summary>
27-
/// A view model which displays the details of a pull request.
28-
/// </summary>
26+
/// <inheritdoc cref="IPullRequestDetailViewModel"/>
2927
[Export(typeof(IPullRequestDetailViewModel))]
3028
[PartCreationPolicy(CreationPolicy.NonShared)]
3129
public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDetailViewModel
@@ -138,9 +136,7 @@ private void DoOpenDetailsUrl(object obj)
138136
usageTracker.IncrementCounter(measuresModel => measuresModel.NumberOfPRDetailsOpenInGitHub).Forget();
139137
}
140138

141-
/// <summary>
142-
/// Gets the underlying pull request model.
143-
/// </summary>
139+
/// <inheritdoc/>
144140
public PullRequestDetailModel Model
145141
{
146142
get { return model; }
@@ -158,124 +154,89 @@ private set
158154
}
159155
}
160156

161-
/// <summary>
162-
/// Gets the local repository.
163-
/// </summary>
157+
/// <inheritdoc/>
164158
public ILocalRepositoryModel LocalRepository { get; private set; }
165159

166-
/// <summary>
167-
/// Gets the owner of the remote repository that contains the pull request.
168-
/// </summary>
169-
/// <remarks>
170-
/// The remote repository may be different from the local repository if the local
171-
/// repository is a fork and the user is viewing pull requests from the parent repository.
172-
/// </remarks>
160+
/// <inheritdoc/>
173161
public string RemoteRepositoryOwner { get; private set; }
174162

175-
/// <summary>
176-
/// Gets the Pull Request number.
177-
/// </summary>
163+
/// <inheritdoc/>
178164
public int Number { get; private set; }
179165

180-
/// <summary>
181-
/// Gets the Pull Request author.
182-
/// </summary>
166+
/// <inheritdoc/>
183167
public IActorViewModel Author
184168
{
185169
get { return author; }
186170
private set { this.RaiseAndSetIfChanged(ref author, value); }
187171
}
188172

189-
/// <summary>
190-
/// Gets the session for the pull request.
191-
/// </summary>
173+
/// <inheritdoc/>
192174
public IPullRequestSession Session { get; private set; }
193175

194-
/// <summary>
195-
/// Gets a string describing how to display the pull request's source branch.
196-
/// </summary>
176+
/// <inheritdoc/>
197177
public string SourceBranchDisplayName
198178
{
199179
get { return sourceBranchDisplayName; }
200180
private set { this.RaiseAndSetIfChanged(ref sourceBranchDisplayName, value); }
201181
}
202182

203-
/// <summary>
204-
/// Gets a string describing how to display the pull request's target branch.
205-
/// </summary>
183+
/// <inheritdoc/>
206184
public string TargetBranchDisplayName
207185
{
208186
get { return targetBranchDisplayName; }
209187
private set { this.RaiseAndSetIfChanged(ref targetBranchDisplayName, value); }
210188
}
211189

212-
/// <summary>
213-
/// Gets a value indicating whether the pull request branch is checked out.
214-
/// </summary>
190+
/// <inheritdoc/>
215191
public bool IsCheckedOut
216192
{
217193
get { return isCheckedOut; }
218194
private set { this.RaiseAndSetIfChanged(ref isCheckedOut, value); }
219195
}
220196

221-
/// <summary>
222-
/// Gets a value indicating whether the pull request comes from a fork.
223-
/// </summary>
197+
/// <inheritdoc/>
224198
public bool IsFromFork
225199
{
226200
get { return isFromFork; }
227201
private set { this.RaiseAndSetIfChanged(ref isFromFork, value); }
228202
}
229203

230-
/// <summary>
231-
/// Gets the pull request body.
232-
/// </summary>
204+
/// <inheritdoc/>
233205
public string Body
234206
{
235207
get { return body; }
236208
private set { this.RaiseAndSetIfChanged(ref body, value); }
237209
}
238210

239-
/// <summary>
240-
/// Gets the state associated with the <see cref="Checkout"/> command.
241-
/// </summary>
211+
/// <inheritdoc/>
242212
public IPullRequestCheckoutState CheckoutState
243213
{
244214
get { return checkoutState; }
245215
private set { this.RaiseAndSetIfChanged(ref checkoutState, value); }
246216
}
247217

248-
/// <summary>
249-
/// Gets the state associated with the <see cref="Pull"/> and <see cref="Push"/> commands.
250-
/// </summary>
218+
/// <inheritdoc/>
251219
public IPullRequestUpdateState UpdateState
252220
{
253221
get { return updateState; }
254222
private set { this.RaiseAndSetIfChanged(ref updateState, value); }
255223
}
256224

257-
/// <summary>
258-
/// Gets the error message to be displayed in the action area as a result of an error in a
259-
/// git operation.
260-
/// </summary>
225+
/// <inheritdoc/>
261226
public string OperationError
262227
{
263228
get { return operationError; }
264229
private set { this.RaiseAndSetIfChanged(ref operationError, value); }
265230
}
266231

267-
/// <summary>
268-
/// Gets the latest pull request review for each user.
269-
/// </summary>
232+
/// <inheritdoc/>
270233
public IReadOnlyList<IPullRequestReviewSummaryViewModel> Reviews
271234
{
272235
get { return reviews; }
273236
private set { this.RaiseAndSetIfChanged(ref reviews, value); }
274237
}
275238

276-
/// <summary>
277-
/// Gets the pull request's changed files.
278-
/// </summary>
239+
/// <inheritdoc/>
279240
public IPullRequestFilesViewModel Files { get; }
280241

281242
/// <summary>
@@ -287,52 +248,35 @@ public Uri WebUrl
287248
private set { this.RaiseAndSetIfChanged(ref webUrl, value); }
288249
}
289250

290-
/// <summary>
291-
/// Gets a command that checks out the pull request locally.
292-
/// </summary>
251+
/// <inheritdoc/>
293252
public ReactiveCommand<Unit> Checkout { get; }
294253

295-
/// <summary>
296-
/// Gets a command that pulls changes to the current branch.
297-
/// </summary>
254+
/// <inheritdoc/>
298255
public ReactiveCommand<Unit> Pull { get; }
299256

300-
/// <summary>
301-
/// Gets a command that pushes changes from the current branch.
302-
/// </summary>
257+
/// <inheritdoc/>
303258
public ReactiveCommand<Unit> Push { get; }
304259

305-
/// <summary>
306-
/// Sync submodules for PR branch.
307-
/// </summary>
260+
/// <inheritdoc/>
308261
public ReactiveCommand<Unit> SyncSubmodules { get; }
309262

310-
/// <summary>
311-
/// Gets a command that opens the pull request on GitHub.
312-
/// </summary>
263+
/// <inheritdoc/>
313264
public ReactiveCommand<object> OpenOnGitHub { get; }
314265

315-
/// <summary>
316-
/// Gets a command that navigates to a pull request review.
317-
/// </summary>
266+
/// <inheritdoc/>
318267
public ReactiveCommand<object> ShowReview { get; }
319268

269+
/// <inheritdoc/>
320270
public ReactiveCommand<object> ShowAnnotations { get; }
321271

272+
/// <inheritdoc/>
322273
public IReadOnlyList<IPullRequestCheckViewModel> Checks
323274
{
324275
get { return checks; }
325276
private set { this.RaiseAndSetIfChanged(ref checks, value); }
326277
}
327278

328-
/// <summary>
329-
/// Initializes the view model.
330-
/// </summary>
331-
/// <param name="localRepository">The local repository.</param>
332-
/// <param name="connection">The connection to the repository host.</param>
333-
/// <param name="owner">The pull request's repository owner.</param>
334-
/// <param name="repo">The pull request's repository name.</param>
335-
/// <param name="number">The pull request number.</param>
279+
/// <inheritdoc/>
336280
public async Task InitializeAsync(
337281
ILocalRepositoryModel localRepository,
338282
IConnection connection,
@@ -521,11 +465,7 @@ public override async Task Refresh()
521465
}
522466
}
523467

524-
/// <summary>
525-
/// Gets the full path to a file in the working directory.
526-
/// </summary>
527-
/// <param name="file">The file.</param>
528-
/// <returns>The full path to the file in the working directory.</returns>
468+
/// <inheritdoc/>
529469
public string GetLocalFilePath(IPullRequestFileNode file)
530470
{
531471
return Path.Combine(LocalRepository.LocalPath, file.RelativePath);

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestAnnotationsViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace GitHub.ViewModels.GitHubPane
77
{
8+
/// <summary>
9+
/// A viewmodel which displays a list of annotations for a pull request's check run.
10+
/// </summary>
811
public interface IPullRequestAnnotationsViewModel : IPanePageViewModel
912
{
1013
/// <summary>

0 commit comments

Comments
 (0)