Browse Source

[PM-4395] Block reseller org invites if they outnumber available seats (#6698)

* Add Toast when reseller org invites over seat limit

* Set validation error when reseller org invited members outnumber seats

* Thomas' feedback
pull/6926/head
Alex Morask 2 years ago committed by GitHub
parent
commit
6f9c6d07af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts
  2. 10
      apps/web/src/app/admin-console/organizations/members/people.component.ts
  3. 9
      apps/web/src/locales/en/messages.json
  4. 4
      libs/common/src/admin-console/models/domain/organization.ts

10
apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts

@ -54,6 +54,7 @@ export interface MemberDialogParams { @@ -54,6 +54,7 @@ export interface MemberDialogParams {
allOrganizationUserEmails: string[];
usesKeyConnector: boolean;
initialTab?: MemberDialogTab;
numConfirmedMembers: number;
}
export enum MemberDialogResult {
@ -383,6 +384,15 @@ export class MemberDialogComponent implements OnInit, OnDestroy { @@ -383,6 +384,15 @@ export class MemberDialogComponent implements OnInit, OnDestroy {
});
return;
}
if (
this.organization.hasReseller &&
this.params.numConfirmedMembers + emails.length > this.organization.seats
) {
this.formGroup.controls.emails.setErrors({
tooManyEmails: { message: this.i18nService.t("seatLimitReachedContactYourProvider") },
});
return;
}
await this.userService.invite(emails, userView);
}

10
apps/web/src/app/admin-console/organizations/members/people.component.ts

@ -427,6 +427,15 @@ export class PeopleComponent @@ -427,6 +427,15 @@ export class PeopleComponent
}
async edit(user: OrganizationUserView, initialTab: MemberDialogTab = MemberDialogTab.Role) {
if (!user && this.organization.hasReseller && this.organization.seats === this.confirmedCount) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("seatLimitReached"),
this.i18nService.t("contactYourProvider")
);
return;
}
// Invite User: Add Flow
// Click on user email: Edit Flow
@ -450,6 +459,7 @@ export class PeopleComponent @@ -450,6 +459,7 @@ export class PeopleComponent
allOrganizationUserEmails: this.allUsers?.map((user) => user.email) ?? [],
usesKeyConnector: user?.usesKeyConnector,
initialTab: initialTab,
numConfirmedMembers: this.confirmedCount,
},
});

9
apps/web/src/locales/en/messages.json

@ -7398,5 +7398,14 @@ @@ -7398,5 +7398,14 @@
},
"unexpectedErrorSend": {
"message": "An unexpected error has occurred while loading this Send. Try again later."
},
"seatLimitReached": {
"message": "Seat limit has been reached"
},
"contactYourProvider": {
"message": "Contact your provider to purchase additional seats."
},
"seatLimitReachedContactYourProvider": {
"message": "Seat limit has been reached. Contact your provider to purchase additional seats."
}
}

4
libs/common/src/admin-console/models/domain/organization.ts

@ -258,6 +258,10 @@ export class Organization { @@ -258,6 +258,10 @@ export class Organization {
return this.providerId != null || this.providerName != null;
}
get hasReseller() {
return this.hasProvider && this.providerType === ProviderType.Reseller;
}
get canAccessSecretsManager() {
return this.useSecretsManager && this.accessSecretsManager;
}

Loading…
Cancel
Save