mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
Cleaned up feature flag logic now that it's released (#3490)
This commit is contained in:
parent
f9941f5dfe
commit
a31295df26
@ -1,9 +1,5 @@
|
||||
using Bit.Api.Models.Response;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Repositories;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -15,42 +11,14 @@ namespace Bit.Api.Controllers;
|
||||
public class PlansController : Controller
|
||||
{
|
||||
private readonly ITaxRateRepository _taxRateRepository;
|
||||
private readonly IFeatureService _featureService;
|
||||
private readonly ICurrentContext _currentContext;
|
||||
|
||||
public PlansController(
|
||||
ITaxRateRepository taxRateRepository,
|
||||
IFeatureService featureService,
|
||||
ICurrentContext currentContext)
|
||||
{
|
||||
_taxRateRepository = taxRateRepository;
|
||||
_featureService = featureService;
|
||||
_currentContext = currentContext;
|
||||
}
|
||||
public PlansController(ITaxRateRepository taxRateRepository) => _taxRateRepository = taxRateRepository;
|
||||
|
||||
[HttpGet("")]
|
||||
[AllowAnonymous]
|
||||
public ListResponseModel<PlanResponseModel> Get()
|
||||
{
|
||||
var plansUpgradeIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.BillingPlansUpgrade, _currentContext);
|
||||
var teamsStarterPlanIsEnabled = _featureService.IsEnabled(FeatureFlagKeys.BillingStarterPlan, _currentContext);
|
||||
var responses = StaticStore.Plans
|
||||
// If plans upgrade is disabled, return only the original plans. Otherwise, return everything
|
||||
.Where(plan => plansUpgradeIsEnabled || plan.Type <= PlanType.EnterpriseAnnually2020 || plan.Type == PlanType.TeamsStarter)
|
||||
// If teams starter is disabled, don't return that plan, otherwise return everything
|
||||
.Where(plan => teamsStarterPlanIsEnabled || plan.Product != ProductType.TeamsStarter)
|
||||
.Select(plan =>
|
||||
{
|
||||
if (!plansUpgradeIsEnabled && plan.Type is <= PlanType.EnterpriseAnnually2020 and >= PlanType.TeamsMonthly2020)
|
||||
{
|
||||
plan.LegacyYear = null;
|
||||
}
|
||||
else if (plansUpgradeIsEnabled && plan.Type is <= PlanType.EnterpriseAnnually2020 and >= PlanType.TeamsMonthly2020)
|
||||
{
|
||||
plan.LegacyYear = 2023;
|
||||
}
|
||||
return new PlanResponseModel(plan);
|
||||
});
|
||||
var responses = StaticStore.Plans.Select(plan => new PlanResponseModel(plan));
|
||||
return new ListResponseModel<PlanResponseModel>(responses);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,6 @@ public static class FeatureFlagKeys
|
||||
public const string BulkCollectionAccess = "bulk-collection-access";
|
||||
public const string AutofillOverlay = "autofill-overlay";
|
||||
public const string ItemShare = "item-share";
|
||||
public const string BillingPlansUpgrade = "billing-plans-upgrade";
|
||||
public const string BillingStarterPlan = "billing-starter-plan";
|
||||
public const string KeyRotationImprovements = "key-rotation-improvements";
|
||||
|
||||
public static List<string> GetAllKeys()
|
||||
|
@ -28,7 +28,7 @@ public abstract record Plan
|
||||
public bool HasCustomPermissions { get; protected init; }
|
||||
public int UpgradeSortOrder { get; protected init; }
|
||||
public int DisplaySortOrder { get; protected init; }
|
||||
public int? LegacyYear { get; set; }
|
||||
public int? LegacyYear { get; protected init; }
|
||||
public bool Disabled { get; protected init; }
|
||||
public PasswordManagerPlanFeatures PasswordManager { get; protected init; }
|
||||
public SecretsManagerPlanFeatures SecretsManager { get; protected init; }
|
||||
|
Loading…
Reference in New Issue
Block a user