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

[Prefix]Add visual indicator for Reserved prefix Packages #4601

Merged
merged 7 commits into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from 6 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/NuGetGallery/Content/gallery/img/reserved-indicator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private static Package PackageFromDoc(Document doc)
int key = Int32.Parse(doc.Get("Key"), CultureInfo.InvariantCulture);
int packageRegistrationKey = Int32.Parse(doc.Get("PackageRegistrationKey"), CultureInfo.InvariantCulture);
int packageSize = Int32.Parse(doc.Get("PackageFileSize"), CultureInfo.InvariantCulture);
bool isVerified = Boolean.Parse(doc.Get("IsVerified-Original"));
bool isLatest = Boolean.Parse(doc.Get("IsLatest"));
bool isLatestStable = Boolean.Parse(doc.Get("IsLatestStable"));
bool isLatestSemVer2 = Boolean.Parse(doc.Get("IsLatestSemVer2"));
Expand Down Expand Up @@ -172,6 +173,7 @@ private static Package PackageFromDoc(Document doc)
Id = doc.Get("Id-Original"),
DownloadCount = downloadCount,
Key = packageRegistrationKey,
IsVerified = isVerified,
Owners = owners
},
PackageRegistrationKey = packageRegistrationKey,
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/Infrastructure/PackageIndexEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public Document ToDocument()
document.Add(new Field("Hash", Package.Hash.ToStringSafe(), Field.Store.YES, Field.Index.NO));
document.Add(new Field("HashAlgorithm", Package.HashAlgorithm.ToStringSafe(), Field.Store.YES, Field.Index.NO));
document.Add(new Field("Id-Original", Package.PackageRegistration.Id, Field.Store.YES, Field.Index.NO));
document.Add(new Field("IsVerified-Original", Package.PackageRegistration.IsVerified.ToString(), Field.Store.YES, Field.Index.NO));
document.Add(new Field("LastUpdated", Package.LastUpdated.ToString(CultureInfo.InvariantCulture), Field.Store.YES, Field.Index.NO));
if (Package.LastEdited != null)
{
Expand Down
9 changes: 9 additions & 0 deletions src/NuGetGallery/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/NuGetGallery/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -561,4 +561,7 @@ For more information, please contact '{2}'.</value>
<data name="ReservedNamespace_UserNotFound" xml:space="preserve">
<value>User not found with username '{0}'</value>
</data>
<data name="ReservedNamespace_ReservedIndicatorTooltip" xml:space="preserve">
<value>The ID prefix of this package has been reserved for one of the owner of this package by NuGet.org.</value>
</data>
</root>
2 changes: 2 additions & 0 deletions src/NuGetGallery/ViewModels/ListPackageItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public ListPackageItemViewModel(Package package)
Authors = package.FlattenedAuthors;
MinClientVersion = package.MinClientVersion;
Owners = package.PackageRegistration?.Owners;
IsVerified = package.PackageRegistration?.IsVerified;

bool wasTruncated;
ShortDescription = Description.TruncateAtWordBoundary(_descriptionLengthLimit, _omissionString, out wasTruncated);
Expand All @@ -37,6 +38,7 @@ public ListPackageItemViewModel(Package package)
public string ShortDescription { get; set; }
public bool IsDescriptionTruncated { get; set; }
public string PolicyMessage { get; set; }
public bool? IsVerified { get; set; }

public bool UseVersion
{
Expand Down
32 changes: 21 additions & 11 deletions src/NuGetGallery/Views/Packages/DisplayPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
<h1>
@Html.BreakWord(Model.Id)
<small class="text-nowrap">@Model.FullVersion</small>

@if (Model.IsVerified.HasValue && Model.IsVerified.Value)
{
<img style="vertical-align: middle; width: 25px"
src="~/Content/gallery/img/reserved-indicator.svg"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/reserved-indicator-25x25.png"))
title="@Strings.ReservedNamespace_ReservedIndicatorTooltip" />
}
</h1>

@if (!StringComparer.OrdinalIgnoreCase.Equals(Model.Id, Model.Title))
Expand Down Expand Up @@ -221,7 +229,7 @@
@if (!String.IsNullOrWhiteSpace(Model.ReleaseNotes))
{
<h2>Release Notes</h2>

<p>@Html.PreFormattedText(Model.ReleaseNotes)</p>
}

Expand Down Expand Up @@ -400,7 +408,7 @@
<li>
<i class="ms-Icon ms-Icon--Globe" aria-hidden="true"></i>
<a href="@Model.ProjectUrl" data-track="outbound-project-url" title="Visit the project site to learn more about this package" rel="nofollow">
@if(Model.ProjectUrl.Length <= 28)
@if (Model.ProjectUrl.Length <= 28)
{
@Model.ProjectUrl
}
Expand All @@ -416,7 +424,7 @@
<li>
<i class="ms-Icon ms-Icon--Certificate" aria-hidden="true"></i>
<a href="@Model.LicenseUrl" data-track="outbound-license-url" title="Make sure you agree with the license" rel="nofollow">
@if(Model.LicenseNames.AnySafe())
@if (Model.LicenseNames.AnySafe())
{
@(string.Join(", ", Model.LicenseNames.Select(x => x + " License")))
}
Expand Down Expand Up @@ -554,14 +562,16 @@
var encodedText = Url.Encode(string.Format("Check out {0} on #NuGet.", Model.Id));
}
<p class="share-buttons">
<a href="https://www.facebook.com/sharer/sharer.php?u=@absolutePackageUrl&t=@encodedText" target="_blank"><img
width="24" height="24" alt="Share this package on Facebook"
src="@Url.Absolute("~/Content/gallery/img/facebook.svg")"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/facebook-24x24.png")) /></a>
<a href="https://twitter.com/intent/tweet?url=@absolutePackageUrl&text=@encodedText" target="_blank"><img
width="24" height="24" alt="Tweet this package"
src="@Url.Absolute("~/Content/gallery/img/twitter.svg")"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/twitter-24x24.png")) /></a>
<a href="https://www.facebook.com/sharer/sharer.php?u=@absolutePackageUrl&t=@encodedText" target="_blank">
<img width="24" height="24" alt="Share this package on Facebook"
src="@Url.Absolute("~/Content/gallery/img/facebook.svg")"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/facebook-24x24.png")) />
</a>
<a href="https://twitter.com/intent/tweet?url=@absolutePackageUrl&text=@encodedText" target="_blank">
<img width="24" height="24" alt="Tweet this package"
src="@Url.Absolute("~/Content/gallery/img/twitter.svg")"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/twitter-24x24.png")) />
</a>
</p>
</aside>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/NuGetGallery/Views/Shared/_ListPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<div class="package-header">
<a class="package-title" href="@Url.Package(Model.Id, Model.UseVersion ? Model.Version : null)">@Html.BreakWord(Model.Id)</a>

@if (Model.IsVerified.HasValue && Model.IsVerified.Value)
{
<img style="vertical-align: top; margin-left: 3px; margin-top: 3px; width: 20px"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style [](start = 25, length = 5)

Move this to CSS

src="~/Content/gallery/img/reserved-indicator.svg"
@ViewHelpers.ImageFallback(Url.Absolute("~/Content/gallery/img/reserved-indicator-20x20.png"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ViewHelpers [](start = 26, length = 11)

The fallback seems unnecessary as the reserved-indicator.svg is static content. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback is for browsers that don't render svg, some older IE versions etc. This is common through out our codebase.

title="@Strings.ReservedNamespace_ReservedIndicatorTooltip"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReservedNamespace_ReservedIndicatorTooltip [](start = 41, length = 42)

I don't think we use Strings anywhere else in views. Maybe use just a plain C# string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using the strings is most appropriate. This needs to be reused in another place as well.

}

<span class="package-by">
by:
@foreach (var owner in Model.Owners)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void IndexAndSearchAPackageByDescription(string semVerLevel)
PackageRegistration = new PackageRegistration
{
Id = "Package #1",
IsVerified = false
},
Title = "Package #1 4.2.0",
Description = "Package #1 is an awesome package",
Expand Down Expand Up @@ -69,6 +70,7 @@ public void ResultsIncludeVersionAndNormalizedVersion(string semVerLevel)
PackageRegistration = new PackageRegistration
{
Id = "Package #1",
IsVerified = false
},
Title = "Package #1 4.2.0",
Description = "Package #1 is an awesome package",
Expand Down Expand Up @@ -109,6 +111,7 @@ public void ResultsIncludeVersionAndNormalizedVersionEvenIfNormalizedVersionColu
PackageRegistration = new PackageRegistration
{
Id = "Package #1",
IsVerified = false
},
Title = "Package #1 4.2.0",
Description = "Package #1 is an awesome package",
Expand Down Expand Up @@ -150,7 +153,8 @@ public void IndexAndSearchDavid123For12(string semVerLevel)
{
Id = "DavidTest123",
Key = 11500,
DownloadCount = 495
DownloadCount = 495,
IsVerified = false
},
Description = "Description",
Listed = true,
Expand Down Expand Up @@ -185,7 +189,8 @@ public void IndexAndSearchWithWordStemming(string semVerLevel)
{
Id = "SuperzipLib",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "Library for compressing your filez",
Listed = true,
Expand Down Expand Up @@ -218,7 +223,8 @@ public void SearchUsingCombinedIdAndGeneralTerms(string semVerLevel)
{
Id = "RedDeath",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "Yeah",
Listed = true,
Expand All @@ -238,7 +244,8 @@ public void SearchUsingCombinedIdAndGeneralTerms(string semVerLevel)
{
Id = "RedHerring",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "Library for compressing your filez",
Listed = true,
Expand Down Expand Up @@ -273,7 +280,8 @@ public void SearchUsingExactPackageId(string semVerLevel)
{
Id = "NuGet.Core",
Key = 12,
DownloadCount = 25
DownloadCount = 25,
IsVerified = false
},
Description = "NuGet.Core is the core framework assembly for NuGet",
DownloadCount = 3,
Expand All @@ -296,6 +304,7 @@ public void SearchUsingExactPackageId(string semVerLevel)
Id = "SomeotherNuGet.Core.SimilarlyNamedPackage",
Key = 13,
DownloadCount = 25,
IsVerified = false
},
Description =
"This isn't really NuGet.Core. The confusing package ID is the test!",
Expand Down Expand Up @@ -351,6 +360,7 @@ public void SearchForNuGetCoreWithExactField(string field, string term)
Id = "NuGet.Core",
Key = 12,
DownloadCount = 41,
IsVerified = false,
Owners = { new User { Username = "NugetCoreOwner" } },
},
Description = "NuGet.Core is the core framework assembly for NuGet that the rest of NuGet builds upon.",
Expand All @@ -373,6 +383,7 @@ public void SearchForNuGetCoreWithExactField(string field, string term)
Id = "SomeotherNuGet.Core.SimilarlyNamedPackage",
Key = 13,
DownloadCount = 2,
IsVerified = false,
Owners = { new User { Username = "SomeOtherOwner" } },
},
Description = "This isn't really NuGet.Core. But it needs to look a bit like it for the test case!",
Expand Down Expand Up @@ -413,7 +424,8 @@ public void SearchForJQueryUICombinedWithPartialId(string semVerLevel)
{
Id = "JQuery.UI.Combined",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "jQuery UI is etc etc and many more important things",
Listed = true,
Expand Down Expand Up @@ -447,7 +459,8 @@ public void SearchForDegenerateSingleQuoteQuery(string semVerLevel)
{
Id = "JQuery.UI.Combined",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "jQuery UI is etc etc and many more important things",
Listed = true,
Expand Down Expand Up @@ -481,7 +494,8 @@ public void SearchUsesPackageRegistrationDownloadCountsToPrioritize(string semVe
{
Id = "FooQuery",
Key = 13,
DownloadCount = 21
DownloadCount = 21,
IsVerified = false
},
Description = "FooQuery is overall much less popular than JQuery UI",
DownloadCount = 5,
Expand All @@ -502,7 +516,8 @@ public void SearchUsesPackageRegistrationDownloadCountsToPrioritize(string semVe
{
Id = "JQuery.UI.Combined",
Key = 12,
DownloadCount = 42
DownloadCount = 42,
IsVerified = false
},
DownloadCount = 3,
Description = "jQuery UI has only a few downloads of its latest and greatest version, but many total downloads",
Expand Down Expand Up @@ -538,7 +553,8 @@ public void IndexAndSearchRetrievesCanDriveV2Feed(string semVerLevel)
{
Id = "Pride",
Key = 456,
DownloadCount = 123456
DownloadCount = 123456,
IsVerified = false
},
Created = new DateTime(2019, 2, 28, 0, 5, 59, DateTimeKind.Utc),
Description = "DescriptionText",
Expand Down Expand Up @@ -579,7 +595,7 @@ public void IndexAndSearchRetrievesCanDriveV2Feed(string semVerLevel)
var packages = new[] { p };
var results = IndexAndSearch(packages, string.Empty, semVerLevel);
var r = results.AsQueryable().ToV2FeedPackageQuery(
"http://www.nuget.org/",
"http://www.nuget.org/",
includeLicenseReport: true,
semVerLevelKey: SemVerLevelKey.Unknown).First();

Expand Down Expand Up @@ -629,7 +645,8 @@ public void SearchWorksAroundLuceneQuerySyntaxExceptions(string semVerLevel)
{
Id = "NuGet.Core",
Key = 12,
DownloadCount = 41
DownloadCount = 41,
IsVerified = false
},
Description = "NuGet.Core is the core framework assembly for NuGet that the rest of NuGet builds upon.",
Listed = true,
Expand Down