Skip to content

Commit b6e8d97

Browse files
authored
link to nugettrends.com (#9737)
* link to nugettrends.com * add interface in fake feature service Co-authored-by: Lynn Dai
1 parent 7210f7a commit b6e8d97

13 files changed

Lines changed: 157 additions & 7 deletions

File tree

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public bool IsDisplayNuGetPackageExplorerLinkEnabled()
7575
{
7676
throw new NotImplementedException();
7777
}
78-
78+
public bool IsDisplayNuGetTrendsLinksEnabled()
79+
{
80+
throw new NotImplementedException();
81+
}
7982
public bool IsDisplayTargetFrameworkEnabled(User user)
8083
{
8184
throw new NotImplementedException();

src/GitHubVulnerabilities2Db/Fakes/FakeFeatureFlagService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public bool IsDisplayFuGetLinksEnabled()
6565
throw new NotImplementedException();
6666
}
6767

68+
public bool IsDisplayNuGetTrendsLinksEnabled()
69+
{
70+
throw new NotImplementedException();
71+
}
72+
6873
public bool IsDisplayVulnerabilitiesEnabled()
6974
{
7075
throw new NotImplementedException();
@@ -320,4 +325,4 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
320325
throw new NotImplementedException();
321326
}
322327
}
323-
}
328+
}

src/NuGetGallery.Services/Configuration/FeatureFlagService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class FeatureFlagService : IFeatureFlagService
3030
private const string ManagePackagesVulnerabilitiesFeatureName = GalleryPrefix + "ManagePackagesVulnerabilities";
3131
private const string DisplayFuGetLinksFeatureName = GalleryPrefix + "DisplayFuGetLinks";
3232
private const string DisplayNuGetPackageExplorerLinkFeatureName = GalleryPrefix + "DisplayNuGetPackageExplorerLink";
33+
private const string DisplayNuGetTrendsLinkFeatureName = GalleryPrefix + "DisplayNuGetTrendsLink";
3334
private const string ODataReadOnlyDatabaseFeatureName = GalleryPrefix + "ODataReadOnlyDatabase";
3435
private const string PackagesAtomFeedFeatureName = GalleryPrefix + "PackagesAtomFeed";
3536
private const string SearchSideBySideFlightName = GalleryPrefix + "SearchSideBySide";
@@ -172,6 +173,11 @@ public bool IsDisplayNuGetPackageExplorerLinkEnabled()
172173
return _client.IsEnabled(DisplayNuGetPackageExplorerLinkFeatureName, defaultValue: false);
173174
}
174175

176+
public bool IsDisplayNuGetTrendsLinksEnabled()
177+
{
178+
return _client.IsEnabled(DisplayNuGetTrendsLinkFeatureName, defaultValue: false);
179+
}
180+
175181
public bool AreEmbeddedIconsEnabled(User user)
176182
{
177183
return _client.IsEnabled(EmbeddedIconFlightName, user, defaultValue: false);
@@ -416,4 +422,4 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
416422
return _client.IsEnabled(AdvancedFrameworkFilteringFeatureName, user, defaultValue: false);
417423
}
418424
}
419-
}
425+
}

src/NuGetGallery.Services/Configuration/IFeatureFlagService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public interface IFeatureFlagService
7777
/// </summary>
7878
bool IsDisplayFuGetLinksEnabled();
7979

80+
/// <summary>
81+
/// Whether or not a nugettrends.com link is visible on a package's details page.
82+
/// </summary>
83+
bool IsDisplayNuGetTrendsLinksEnabled();
84+
8085
/// <summary>
8186
/// Whether or not a nuget.info (NuGet Package Explorer) link is visible on a package's details page.
8287
/// </summary>

src/NuGetGallery/App_Data/Files/Content/flags.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"NuGetGallery.ManagePackagesVulnerabilities": "Enabled",
2727
"NuGetGallery.DisplayFuGetLinks": "Enabled",
2828
"NuGetGallery.DisplayNuGetPackageExplorerLink": "Enabled",
29+
"NuGetGallery.DisplayNuGetTrendsLink": "Enabled",
2930
"NuGetGallery.PatternSetTfmHeuristics": "Enabled",
3031
"NuGetGallery.EmbeddedIcons": "Enabled",
3132
"NuGetGallery.MarkdigMdRendering": "Enabled",
@@ -146,4 +147,4 @@
146147
"Domains": []
147148
}
148149
}
149-
}
150+
}
2.25 KB
Loading
Lines changed: 27 additions & 0 deletions
Loading

src/NuGetGallery/Controllers/PackagesController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ public virtual async Task<ActionResult> DisplayPackage(string id, string version
982982
model.IsPackageVulnerabilitiesEnabled = isPackageVulnerabilitiesEnabled;
983983
model.IsFuGetLinksEnabled = _featureFlagService.IsDisplayFuGetLinksEnabled();
984984
model.IsNuGetPackageExplorerLinkEnabled = _featureFlagService.IsDisplayNuGetPackageExplorerLinkEnabled();
985+
model.IsNuGetTrendsLinksEnabled = _featureFlagService.IsDisplayNuGetTrendsLinksEnabled();
985986
model.IsPackageRenamesEnabled = _featureFlagService.IsPackageRenamesEnabled(currentUser);
986987
model.IsPackageDependentsEnabled = _featureFlagService.IsPackageDependentsEnabled(currentUser);
987988
model.IsRecentPackagesNoIndexEnabled = _featureFlagService.IsRecentPackagesNoIndexEnabled();

src/NuGetGallery/Helpers/ViewModelExtensions/DisplayPackageViewModelFactory.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ private DisplayPackageViewModel SetupCommon(
180180
viewModel.NuGetPackageExplorerUrl = nugetPackageExplorerReadyUrl;
181181
}
182182

183+
var nugetTrendsUrl = $"https://nugettrends.com/packages?ids={package.Id}";
184+
if (PackageHelper.TryPrepareUrlForRendering(nugetTrendsUrl, out string nugetTrendsReadyUrl))
185+
{
186+
viewModel.NuGetTrendsUrl = nugetTrendsReadyUrl;
187+
}
188+
183189
viewModel.EmbeddedLicenseType = package.EmbeddedLicenseType;
184190
viewModel.LicenseExpression = package.LicenseExpression;
185191

@@ -265,4 +271,4 @@ private static string GetPushedBy(Package package, User currentUser, Dictionary<
265271
return pushedByCache[userPushedBy];
266272
}
267273
}
268-
}
274+
}

src/NuGetGallery/ViewModels/DisplayPackageViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class DisplayPackageViewModel : ListPackageItemViewModel
3838
public bool IsPackageDeprecationEnabled { get; set; }
3939
public bool IsPackageVulnerabilitiesEnabled { get; set; }
4040
public bool IsFuGetLinksEnabled { get; set; }
41+
public bool IsNuGetTrendsLinksEnabled { get; set; }
4142
public bool IsNuGetPackageExplorerLinkEnabled { get; set; }
4243
public bool IsPackageRenamesEnabled { get; set; }
4344
public bool IsGitHubUsageEnabled { get; set; }
@@ -88,6 +89,7 @@ public bool HasNewerRelease
8889
public string ProjectUrl { get; set; }
8990
public string LicenseUrl { get; set; }
9091
public string FuGetUrl { get; set; }
92+
public string NuGetTrendsUrl { get; set; }
9193
public string NuGetPackageExplorerUrl { get; set; }
9294
public IReadOnlyCollection<string> LicenseNames { get; set; }
9395
public string LicenseExpression { get; set; }
@@ -146,6 +148,11 @@ public bool CanDisplayFuGetLink()
146148
return IsFuGetLinksEnabled && !string.IsNullOrEmpty(FuGetUrl) && Available;
147149
}
148150

151+
public bool CanDisplayNuGetTrendsLink()
152+
{
153+
return IsNuGetTrendsLinksEnabled && !string.IsNullOrEmpty(NuGetTrendsUrl) && Available;
154+
}
155+
149156
public bool CanDisplayTargetFrameworks()
150157
{
151158
return IsDisplayTargetFrameworkEnabled && !Deleted && !IsDotnetNewTemplatePackageType;
@@ -166,4 +173,4 @@ public enum RepositoryKind
166173
GitHub,
167174
}
168175
}
169-
}
176+
}

0 commit comments

Comments
 (0)