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:
parent
ad3131f66e
commit
2f7c0ff1bf
@ -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; }
|
||||
|
||||
|
@ -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)),
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user