Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display 'No dependencies' if group has no dependencies #686

Merged
merged 1 commit into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/BaGet.Core/Entities/PackageDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ public class PackageDependency
{
public int Key { get; set; }

/// <summary>
/// The dependency's package ID. Null if this is a dependency group without any dependencies.
/// </summary>
public string Id { get; set; }

/// <summary>
/// The dependency's package version. Null if this is a dependency group without any dependencies.
/// </summary>
public string VersionRange { get; set; }

public string TargetFramework { get; set; }

public Package Package { get; set; }
Expand Down
27 changes: 17 additions & 10 deletions src/BaGet.Web/Pages/Package.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,24 @@ else
</h4>

<ul class="list-unstyled dependency-group">
@foreach (var dependency in group.Dependencies)
@if (!group.Dependencies.Any())
{
<li>
<a asp-page="Package"
asp-route-id="@dependency.PackageId"
asp-route-version="@null">
@dependency.PackageId
</a>

<span> @dependency.VersionSpec</span>
</li>
<li>No dependencies.</li>
}
else
{
@foreach (var dependency in group.Dependencies)
{
<li>
<a asp-page="Package"
asp-route-id="@dependency.PackageId"
asp-route-version="@null">
@dependency.PackageId
</a>

<span> @dependency.VersionSpec</span>
</li>
}
}
</ul>
}
Expand Down
1 change: 1 addition & 0 deletions src/BaGet.Web/Pages/Package.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private IReadOnlyList<DependencyGroupModel> ToDependencyGroups(Package package)
{
Name = PrettifyTargetFramework(group.Key),
Dependencies = group
.Where(d => d.Id != null)
.Select(d => new DependencyModel
{
PackageId = d.Id,
Expand Down