diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts index cb99bab0dae..fe83acf0bc3 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts @@ -62,7 +62,7 @@ export interface MemberDialogParams { name: string; organizationId: string; organizationUserId: string; - activeUserCount: number; + activeUserCount?: number; allOrganizationUserEmails: string[]; usesKeyConnector: boolean; isOnSecretsManagerStandalone: boolean; @@ -268,8 +268,8 @@ export class MemberDialogComponent implements OnDestroy { orgSeatLimitReachedValidator( organization, this.params.allOrganizationUserEmails, - this.params.activeUserCount, this.i18nService.t("subscriptionUpgrade", organization.seats), + this.params.activeUserCount, ), ]; diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.spec.ts b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.spec.ts index 6c693ee8f84..a7ae1ac0336 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.spec.ts +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.spec.ts @@ -102,10 +102,14 @@ describe("orgSeatLimitReachedValidator", () => { seats: 2, }); const errorMessage = "You cannot invite more than 2 members without upgrading your plan."; + + const activeUserCount = 1; + validatorFn = orgSeatLimitReachedValidator( organization, allOrganizationUserEmails, "You cannot invite more than 2 members without upgrading your plan.", + activeUserCount, ); const control = new FormControl("user2@example.com,user3@example.com"); diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.ts b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.ts index 8209862ae5e..5dc695043fb 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.ts +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/validators/org-seat-limit-reached.validator.ts @@ -8,15 +8,15 @@ import { ProductTierType } from "@bitwarden/common/billing/enums"; * new users * @param organization An object representing the organization * @param allOrganizationUserEmails An array of strings with existing user email addresses - * @param activeUserCount The current count of active users occupying the organization's seats. * @param errorMessage A localized string to display if validation fails + * @param activeUserCount The current count of active users occupying the organization's seats. * @returns A function that validates an `AbstractControl` and returns `ValidationErrors` or `null` */ export function orgSeatLimitReachedValidator( organization: Organization, allOrganizationUserEmails: string[], - activeUserCount: number, errorMessage: string, + activeUserCount?: number, ): ValidatorFn { return (control: AbstractControl): ValidationErrors | null => { if (control.value === "" || !control.value) { @@ -28,10 +28,14 @@ export function orgSeatLimitReachedValidator( organization.productTierType !== ProductTierType.Families && organization.productTierType !== ProductTierType.TeamsStarter; - const newTotalCount = + if (productHasAdditionalSeatsOption || !activeUserCount) { + return null; + } + + const newTotalUserCount = activeUserCount + getUniqueNewEmailCount(allOrganizationUserEmails, control); - if (!productHasAdditionalSeatsOption && newTotalCount > organization.seats) { + if (newTotalUserCount > organization.seats) { return { seatLimitReached: { message: errorMessage } }; } diff --git a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/member-access-report.component.ts b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/member-access-report.component.ts index c8ff68a28ce..978bdca080c 100644 --- a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/member-access-report.component.ts +++ b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/member-access-report.component.ts @@ -92,13 +92,12 @@ export class MemberAccessReportComponent implements OnInit { }; edit = async (user: MemberAccessReportView | null): Promise => { + console.log("Jimmy report ", { dataSource: this.dataSource }); const dialog = openUserAddEditDialog(this.dialogService, { data: { name: this.userNamePipe.transform(user), organizationId: this.organizationId, organizationUserId: user != null ? user.userGuid : null, - // This is a temp solution. I will discuss this with the team before merging in the code. - activeUserCount: 0, allOrganizationUserEmails: this.dataSource.data?.map((user) => user.email) ?? [], usesKeyConnector: user?.usesKeyConnector, isOnSecretsManagerStandalone: this.orgIsOnSecretsManagerStandalone,