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

add feature flag for banner #8527

Merged
merged 1 commit into from
Apr 15, 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public bool IsDeletePackageApiEnabled(User user)
throw new NotImplementedException();
}

public bool IsDisplayBannerEnabled()
{
throw new NotImplementedException();
}

public bool IsDisplayFuGetLinksEnabled()
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class FeatureFlagService : IFeatureFlagService
private const string MarkdigMdRenderingFlightName = GalleryPrefix + "MarkdigMdRendering";
private const string DeletePackageApiFlightName = GalleryPrefix + "DeletePackageApi";
private const string ImageAllowlistFlightName = GalleryPrefix + "ImageAllowlist";
private const string DisplayBannerFlightName = GalleryPrefix + "Banner";

private const string ODataV1GetAllNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllNonHijacked";
private const string ODataV1GetAllCountNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllCountNonHijacked";
Expand Down Expand Up @@ -326,5 +327,10 @@ public bool IsImageAllowlistEnabled()
{
return _client.IsEnabled(ImageAllowlistFlightName, defaultValue: false);
}

public bool IsDisplayBannerEnabled()
{
return _client.IsEnabled(DisplayBannerFlightName, defaultValue: false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,10 @@ public interface IFeatureFlagService
/// Whether the allowlist is enabled for checking the image sources
/// </summary>
bool IsImageAllowlistEnabled();

/// <summary>
/// Whether or not display the banner on nuget.org
/// </summary>
bool IsDisplayBannerEnabled();
}
}
3 changes: 2 additions & 1 deletion src/NuGetGallery/Controllers/PagesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public virtual ActionResult Home()
var externalIdentityList = ClaimsExtensions.GetExternalCredentialIdentityList(identity);
var showEnable2FAModal = _featureFlagService.IsShowEnable2FADialogEnabled();
var getFeedbackOnModalDismiss = _featureFlagService.IsGet2FADismissFeedbackEnabled();
var displayBanner = _featureFlagService.IsDisplayBannerEnabled();

return View(new GalleryHomeViewModel(showTransformModal, transformIntoOrganization, showEnable2FAModal, getFeedbackOnModalDismiss, externalIdentityList));
return View(new GalleryHomeViewModel(showTransformModal, transformIntoOrganization, showEnable2FAModal, getFeedbackOnModalDismiss, displayBanner, externalIdentityList));
}

[HttpGet]
Expand Down
5 changes: 5 additions & 0 deletions src/NuGetGallery/ViewModels/GalleryHomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ public class GalleryHomeViewModel

public bool GetFeedbackOnModalDismissFeatureEnabled { get; set; }

public bool DisplayBannerFeatureEnabled { get; set; }

public GalleryHomeViewModel() : this(
showTransformModal: false,
transformIntoOrganization: false,
showEnable2FAModalFeatureEnabled: false,
getFeedbackOnModalDismiss: false,
displayBanner: false,
identity: null)
{ }

Expand All @@ -28,12 +31,14 @@ public GalleryHomeViewModel(
bool transformIntoOrganization,
bool showEnable2FAModalFeatureEnabled,
bool getFeedbackOnModalDismiss,
bool displayBanner,
string identity = null)
{
ShowTransformModal = showTransformModal;
TransformIntoOrganization = transformIntoOrganization;
ShowEnable2FAModalFeatureEnabled = showEnable2FAModalFeatureEnabled;
GetFeedbackOnModalDismissFeatureEnabled = getFeedbackOnModalDismiss;
DisplayBannerFeatureEnabled = displayBanner;
Identity = identity;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/Views/Pages/Home.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ViewBag.ShowSearchInNavbar = false;
ViewBag.AutofocusSearch = true;
ViewBag.HasJumbotron = true;
ViewBag.DisplayBanner = Model.DisplayBannerFeatureEnabled;
var AskUserToEnable2FA = TempData.ContainsKey("AskUserToEnable2FA")
&& Convert.ToBoolean(TempData["AskUserToEnable2FA"].ToString())
&& Model.ShowEnable2FAModalFeatureEnabled;
Expand Down
17 changes: 10 additions & 7 deletions src/NuGetGallery/Views/Shared/Gallery/Header.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
</div>
}

<div class="container-fluid banner banner-info text-center">
<div class="row">
<div class="col-sm-12">
<span>
&#128075; What do you think about NuGet.org? We're looking for feedback from developers like you. <a href="https://aka.ms/NuGetSurvey" target="_blank">Take the survey.</a>
</span>
@if (ViewBag.DisplayBanner == true)
{
<div class="container-fluid banner banner-info text-center">
<div class="row">
<div class="col-sm-12">
<span>
&#128075; What do you think about NuGet.org? We're looking for feedback from developers like you. <a href="https://aka.ms/NuGetSurvey" target="_blank">Take the survey.</a>
</span>
</div>
</div>
</div>
</div>
}

@helper DisplayNavigationItem(string tab, string url, bool bold = false, string title = null)
{
Expand Down
2 changes: 2 additions & 0 deletions src/VerifyMicrosoftPackage/Fakes/FakeFeatureFlagService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,7 @@ public class FakeFeatureFlagService : IFeatureFlagService
public bool IsDeletePackageApiEnabled(User user) => throw new NotImplementedException();

public bool IsImageAllowlistEnabled() => throw new NotImplementedException();

public bool IsDisplayBannerEnabled() => throw new NotImplementedException();
}
}