Permalink
Browse files

initial UI changes for dependency sets

  • Loading branch information...
1 parent 7962e0a commit a155556a996447b342a9f67585d18ceea8756729 @half-ogre half-ogre committed Jun 15, 2012
View
@@ -564,6 +564,33 @@ header.main {
padding-right: 6px;
}
+ /* DependencySets */
+ #dependencySets {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ }
+
+ #dependencySets > li {
+ font-style: italic;
+ }
+
+ #dependencySets > li > h4 {
+ margin: 2px 0;
+ }
+
+ ul.dependencySet {
+ list-style: none;
+ margin: 0 0 5px 0;
+ padding: 0;
+ }
+
+ ul.dependencySet li {
+ font-size: 1.25em;
+ font-style: normal;
+ padding-right: 6px;
+ }
+
/* Owners */
.owners {
list-style: none;
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NuGet;
+
+namespace NuGetGallery
+{
+ public class DependencySetsViewModel
+ {
+ public DependencySetsViewModel(IEnumerable<PackageDependency> packageDependencies)
+ {
+ DependencySets = new Dictionary<string, IEnumerable<DependencyViewModel>>();
+
+ var dependencySets = packageDependencies
+ .GroupBy(d => d.TargetFramework)
+ .OrderBy(ds => ds.Key);
+
+ foreach(var dependencySet in dependencySets)
+ {
+ var targetFramework = dependencySet.Key ?? "All";
+ DependencySets.Add(targetFramework, dependencySet.Select(d => new DependencyViewModel(d.Id, d.VersionSpec)));
+ }
+
+ OnlyHasAllFrameworks = DependencySets.Count == 1 && DependencySets.First().Key == "All";
+ }
+
+ public IDictionary<string, IEnumerable<DependencyViewModel>> DependencySets { get; private set; }
+ public bool OnlyHasAllFrameworks { get; private set; }
+
+ public class DependencyViewModel
+ {
+ public DependencyViewModel(string id, string versionSpec)
+ {
+ Id = id;
+
+ if (!String.IsNullOrEmpty(versionSpec))
+ VersionSpec = VersionUtility.PrettyPrint(VersionUtility.ParseVersionSpec(versionSpec));
+ }
+
+ public string Id { get; private set; }
+ public string VersionSpec { get; private set; }
+ }
+ }
+}
@@ -1,25 +0,0 @@
-using System;
-using NuGet;
-
-namespace NuGetGallery
-{
- public class DependencyViewModel
- {
- public DependencyViewModel(PackageDependency dependency)
- : this(dependency.Id, dependency.VersionSpec)
- {
- }
-
- public DependencyViewModel(string id, string versionSpec)
- {
- Id = id;
- if (!String.IsNullOrEmpty(versionSpec))
- {
- VersionSpec = VersionUtility.PrettyPrint(VersionUtility.ParseVersionSpec(versionSpec));
- }
- }
-
- public string Id { get; private set; }
- public string VersionSpec { get; private set; }
- }
-}
@@ -17,7 +17,7 @@ public DisplayPackageViewModel(Package package, bool isVersionHistory)
Copyright = package.Copyright;
if (!isVersionHistory)
{
- Dependencies = package.Dependencies.Select(d => new DependencyViewModel(d));
+ Dependencies = new DependencySetsViewModel(package.Dependencies);
PackageVersions = from p in package.PackageRegistration.Packages.ToList()
orderby new SemanticVersion(p.Version) descending
select new DisplayPackageViewModel(p, isVersionHistory: true);
@@ -26,7 +26,7 @@ public DisplayPackageViewModel(Package package, bool isVersionHistory)
DownloadCount = package.DownloadCount;
}
- public IEnumerable<DependencyViewModel> Dependencies { get; set; }
+ public DependencySetsViewModel Dependencies { get; set; }
public IEnumerable<DisplayPackageViewModel> PackageVersions { get; set; }
public string Copyright { get; set; }
@@ -1,4 +1,4 @@
-@model DisplayPackageViewModel
+@model DisplayPackageViewModel
@{
ViewBag.Tab = "Packages";
Layout = "~/Views/Shared/TwoColumnLayout.cshtml";
@@ -125,39 +125,7 @@
}
</ul>
}
- <h3>Dependencies</h3>
- @if (Model.Dependencies.Any())
- {
- <table class="sexy-table">
- <thead>
- <tr>
- <th class="first">
- Id
- </th>
- <th class="last">
- Version Range
- </th>
- </tr>
- </thead>
- <tbody>
- @foreach (var dependency in Model.Dependencies)
- {
- <tr>
- <td>
- <a href="@Url.Package(dependency.Id)">@dependency.Id</a>
- </td>
- <td>@dependency.VersionSpec
- </td>
- </tr>
- }
- </tbody>
- </table>
- }
- else
- {
- <p>@Model.Id @Model.Version does not have any dependencies
- </p>
- }
+ @Html.Partial("_PackageDependencies", Model.Dependencies)
<h3>Version History</h3>
<table class="sexy-table">
<thead>
@@ -211,4 +179,4 @@
}
</tbody>
</table>
-</div>
+</div>
@@ -0,0 +1,29 @@
+@model DependencySetsViewModel
+<h3>Dependencies</h3>
+@if (Model.DependencySets.Any())
+{
+ <ul id="dependencySets">
+ @foreach (var dependencySet in Model.DependencySets)
+ {
+ <li>
+ @if (!Model.OnlyHasAllFrameworks)
+ {
+ <h4>@dependencySet.Key</h4>
+ }
+ <ul class="dependencySet">
+ @foreach (var dependency in dependencySet.Value)
+ {
+ <li>
+ <a href="@Url.Package(dependency.Id)">@dependency.Id</a>
+ <span>@dependency.VersionSpec</span>
+ </li>
+ }
+ </ul>
+ </li>
+ }
+ </ul>
+}
+else
+{
+ <p>This package has no dependencies.</p>
+}
View
@@ -401,6 +401,7 @@
<Compile Include="ViewModels\AccountViewModel.cs" />
<Compile Include="ViewModels\AggregateStats.cs" />
<Compile Include="ViewModels\CuratedFeedViewModel.cs" />
+ <Compile Include="ViewModels\DependencySetsViewModel.cs" />
<Compile Include="ViewModels\EditProfileViewModel.cs" />
<Compile Include="ViewModels\EmailConfirmationModel.cs" />
<Compile Include="ViewModels\PackageOwnerConfirmationModel.cs" />
@@ -650,7 +651,6 @@
<Compile Include="ViewModels\ContactOwnersViewModel.cs" />
<Compile Include="ViewModels\PasswordResetViewModel.cs" />
<Compile Include="ViewModels\ManagePackageOwnersViewModel.cs" />
- <Compile Include="ViewModels\DependencyViewModel.cs" />
<Compile Include="ViewModels\IPackageVersionModel.cs" />
<Compile Include="ViewModels\IPageableEnumerable.cs" />
<Compile Include="App_Start\Routes.cs" />
@@ -878,6 +878,7 @@
<LastGenOutput>T4MVC.cs</LastGenOutput>
</None>
<None Include="T4MVC.tt.settings.t4" />
+ <Content Include="Views\Packages\_PackageDependencies.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="DynamicData\CustomPages\" />

0 comments on commit a155556

Please sign in to comment.