1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00

Fixed naming in subscription update models.

This commit is contained in:
jrmccannon 2025-03-26 11:18:35 -05:00
parent ad3131f66e
commit 2f7c0ff1bf
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
3 changed files with 38 additions and 7 deletions

View File

@ -7,7 +7,7 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
public class PasswordManagerSubscriptionUpdate
{
/// <summary>
/// Seats the organization is currently paying for
/// Seats the organization has
/// </summary>
public int? Seats { get; }

View File

@ -8,11 +8,11 @@ public static class SecretsManagerInviteUserValidation
SecretsManagerSubscriptionUpdate subscriptionUpdate) =>
subscriptionUpdate switch
{
{ UseSecretsManger: false, AdditionalSeats: > 0 } =>
{ UseSecretsManger: false, NewUsersToAdd: > 0 } =>
new Invalid<SecretsManagerSubscriptionUpdate>(
new OrganizationNoSecretsManagerError(subscriptionUpdate)),
{ UseSecretsManger: false, AdditionalSeats: 0 } or { UseSecretsManger: true, Seats: null } =>
{ UseSecretsManger: false, NewUsersToAdd: 0 } or { UseSecretsManger: true, Seats: null } =>
new Valid<SecretsManagerSubscriptionUpdate>(subscriptionUpdate),
{ UseSecretsManger: true, SecretsManagerPlan.HasAdditionalSeatsOption: false } =>
@ -20,7 +20,7 @@ public static class SecretsManagerInviteUserValidation
new SecretsManagerAdditionalSeatLimitReachedError(subscriptionUpdate)),
{ UseSecretsManger: true, SecretsManagerPlan.MaxAdditionalSeats: var planMaxSeats }
when planMaxSeats < subscriptionUpdate.AdditionalSeats =>
when planMaxSeats < subscriptionUpdate.NewUsersToAdd =>
new Invalid<SecretsManagerSubscriptionUpdate>(
new SecretsManagerAdditionalSeatLimitReachedError(subscriptionUpdate)),

View File

@ -8,14 +8,45 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
public class SecretsManagerSubscriptionUpdate
{
public bool UseSecretsManger { get; }
/// <summary>
/// Seats the organization has
/// </summary>
public int? Seats { get; }
/// <summary>
/// Max number of seats that the organization can have
/// </summary>
public int? MaxAutoScaleSeats { get; }
/// <summary>
/// Seats currently occupied by current users
/// </summary>
public int OccupiedSeats { get; }
public int AdditionalSeats { get; }
/// <summary>
/// Users to add to the organization seats
/// </summary>
public int NewUsersToAdd { get; }
public int? PasswordManagerUpdatedSeatTotal { get; }
public Plan.SecretsManagerPlanFeatures SecretsManagerPlan { get; }
/// <summary>
/// Number of seats available for users
/// </summary>
public int? AvailableSeats => Seats - OccupiedSeats;
public int SeatsRequiredToAdd => AdditionalSeats - AvailableSeats ?? 0;
/// <summary>
/// Number of seats to scale the organization to.
///
/// If Organization has no seat limit (Seats is null), then there are no new seats to add.
/// </summary>
public int SeatsRequiredToAdd => AvailableSeats.HasValue ? Math.Max(NewUsersToAdd - AvailableSeats.Value, 0) : 0;
/// <summary>
/// New total of seats for the organization
/// </summary>
public int? UpdatedSeatTotal => Seats + SeatsRequiredToAdd;
private SecretsManagerSubscriptionUpdate(bool useSecretsManger,
@ -30,7 +61,7 @@ public class SecretsManagerSubscriptionUpdate
Seats = organizationSeats;
MaxAutoScaleSeats = organizationAutoScaleSeatLimit;
OccupiedSeats = currentSeats;
AdditionalSeats = seatsToAdd;
NewUsersToAdd = seatsToAdd;
PasswordManagerUpdatedSeatTotal = passwordManagerUpdatedSeatTotal;
SecretsManagerPlan = plan;
}