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

Commit f3635e9

Browse files
Hiding the checks section if there are no checks to display
1 parent 790d4b3 commit f3635e9

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public PullRequestDetailViewModelDesigner()
9898
Files = new PullRequestFilesViewModelDesigner();
9999

100100
Checks = Array.Empty<PullRequestCheckViewModelDesigner>();
101+
HasChecks = false;
101102
}
102103

103104
public PullRequestDetailModel Model { get; }
@@ -129,6 +130,7 @@ public PullRequestDetailViewModelDesigner()
129130
public ReactiveCommand<IPullRequestCheckViewModel, Unit> ShowAnnotations { get; }
130131

131132
public IReadOnlyList<IPullRequestCheckViewModel> Checks { get; }
133+
public bool HasChecks { get; }
132134

133135
public Task InitializeAsync(LocalRepositoryModel localRepository, IConnection connection, string owner, string repo, int number) => Task.CompletedTask;
134136

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
5858
Uri webUrl;
5959
IDisposable sessionSubscription;
6060
IReadOnlyList<IPullRequestCheckViewModel> checks;
61+
bool hasChecks;
6162

6263
/// <summary>
6364
/// Initializes a new instance of the <see cref="PullRequestDetailViewModel"/> class.
@@ -282,6 +283,13 @@ public IReadOnlyList<IPullRequestCheckViewModel> Checks
282283
private set { this.RaiseAndSetIfChanged(ref checks, value); }
283284
}
284285

286+
/// <inheritdoc/>
287+
public bool HasChecks
288+
{
289+
get { return hasChecks; }
290+
private set { this.RaiseAndSetIfChanged(ref hasChecks, value); }
291+
}
292+
285293
/// <inheritdoc/>
286294
public async Task InitializeAsync(
287295
LocalRepositoryModel localRepository,
@@ -351,6 +359,7 @@ public async Task Load(PullRequestDetailModel pullRequest)
351359
Reviews = PullRequestReviewSummaryViewModel.BuildByUser(Session.User, pullRequest).ToList();
352360

353361
Checks = PullRequestCheckViewModel.Build(viewViewModelFactory, pullRequest)?.ToList();
362+
HasChecks = Checks?.Any() ?? false;
354363

355364
await Files.InitializeAsync(Session);
356365

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ public interface IPullRequestDetailViewModel : IPanePageViewModel, IOpenInBrowse
191191
/// </summary>
192192
IReadOnlyList<IPullRequestCheckViewModel> Checks { get; }
193193

194+
/// <summary>
195+
/// Flag that indicates if there are checks or statuses to display.
196+
/// </summary>
197+
bool HasChecks { get; }
198+
194199
/// <summary>
195200
/// Initializes the view model.
196201
/// </summary>

src/GitHub.VisualStudio.UI/Views/GitHubPane/PullRequestDetailView.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@
248248
HeaderText="Checks"
249249
IsExpanded="True"
250250
Margin="0 8 0 0"
251-
ghfvs:ScrollingVerticalStackPanel.IsFixed="true">
251+
ghfvs:ScrollingVerticalStackPanel.IsFixed="true"
252+
Visibility="{Binding HasChecks, Converter={ghfvs:BooleanToVisibilityConverter}}">
252253
<ItemsControl ItemsSource="{Binding Checks}" Margin="0 4 12 4">
253254
<ItemsControl.ItemsPanel>
254255
<ItemsPanelTemplate>

0 commit comments

Comments
 (0)