From 2f7c0ff1bff41d8e108b5828649a3b0e93733ee0 Mon Sep 17 00:00:00 2001 From: jrmccannon Date: Wed, 26 Mar 2025 11:18:35 -0500 Subject: [PATCH] Fixed naming in subscription update models. --- .../PasswordManagerSubscriptionUpdate.cs | 2 +- .../SecretsManagerInviteUserValidation.cs | 6 +-- .../SecretsManagerSubscriptionUpdate.cs | 37 +++++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManager/PasswordManagerSubscriptionUpdate.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManager/PasswordManagerSubscriptionUpdate.cs index f740be0f8f..281965c0af 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManager/PasswordManagerSubscriptionUpdate.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/PasswordManager/PasswordManagerSubscriptionUpdate.cs @@ -7,7 +7,7 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse public class PasswordManagerSubscriptionUpdate { /// - /// Seats the organization is currently paying for + /// Seats the organization has /// public int? Seats { get; } diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerInviteUserValidation.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerInviteUserValidation.cs index f5f83b6d2e..610dbd2b7a 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerInviteUserValidation.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerInviteUserValidation.cs @@ -8,11 +8,11 @@ public static class SecretsManagerInviteUserValidation SecretsManagerSubscriptionUpdate subscriptionUpdate) => subscriptionUpdate switch { - { UseSecretsManger: false, AdditionalSeats: > 0 } => + { UseSecretsManger: false, NewUsersToAdd: > 0 } => new Invalid( new OrganizationNoSecretsManagerError(subscriptionUpdate)), - { UseSecretsManger: false, AdditionalSeats: 0 } or { UseSecretsManger: true, Seats: null } => + { UseSecretsManger: false, NewUsersToAdd: 0 } or { UseSecretsManger: true, Seats: null } => new Valid(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( new SecretsManagerAdditionalSeatLimitReachedError(subscriptionUpdate)), diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerSubscriptionUpdate.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerSubscriptionUpdate.cs index 946632f57d..eeae1cf947 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerSubscriptionUpdate.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/SecretsManager/SecretsManagerSubscriptionUpdate.cs @@ -8,14 +8,45 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse public class SecretsManagerSubscriptionUpdate { public bool UseSecretsManger { get; } + + /// + /// Seats the organization has + /// public int? Seats { get; } + + /// + /// Max number of seats that the organization can have + /// public int? MaxAutoScaleSeats { get; } + + /// + /// Seats currently occupied by current users + /// public int OccupiedSeats { get; } - public int AdditionalSeats { get; } + + /// + /// Users to add to the organization seats + /// + public int NewUsersToAdd { get; } + public int? PasswordManagerUpdatedSeatTotal { get; } public Plan.SecretsManagerPlanFeatures SecretsManagerPlan { get; } + + /// + /// Number of seats available for users + /// public int? AvailableSeats => Seats - OccupiedSeats; - public int SeatsRequiredToAdd => AdditionalSeats - AvailableSeats ?? 0; + + /// + /// 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. + /// + public int SeatsRequiredToAdd => AvailableSeats.HasValue ? Math.Max(NewUsersToAdd - AvailableSeats.Value, 0) : 0; + + /// + /// New total of seats for the organization + /// 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; }