mirror of
https://github.com/bitwarden/browser
synced 2025-12-30 07:03:26 +00:00
[PM-8830] Billing Enums Rename (#9612)
* Renamed ProductType to ProductTierType * Renamed Product properties to ProductTier * Moved product-tier-type.enum.ts to billing folder * Added ProductType enum
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
<input id="emails" type="text" appAutoFocus bitInput formControlName="emails" />
|
||||
<bit-hint>{{
|
||||
"inviteMultipleEmailDesc"
|
||||
| i18n: (organization.planProductType === ProductType.TeamsStarter ? "10" : "20")
|
||||
| i18n
|
||||
: (organization.productTierType === ProductTierType.TeamsStarter ? "10" : "20")
|
||||
}}</bit-hint>
|
||||
</bit-form-field>
|
||||
</ng-container>
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import { PermissionsApi } from "@bitwarden/common/admin-console/models/api/permissions.api";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -463,7 +463,8 @@ export class MemberDialogComponent implements OnDestroy {
|
||||
await this.userService.save(userView);
|
||||
} else {
|
||||
userView.id = this.params.organizationUserId;
|
||||
const maxEmailsCount = organization.planProductType === ProductType.TeamsStarter ? 10 : 20;
|
||||
const maxEmailsCount =
|
||||
organization.productTierType === ProductTierType.TeamsStarter ? 10 : 20;
|
||||
const emails = [...new Set(this.formGroup.value.emails.trim().split(/\s*,\s*/))];
|
||||
if (emails.length > maxEmailsCount) {
|
||||
this.formGroup.controls.emails.setErrors({
|
||||
@@ -614,7 +615,7 @@ export class MemberDialogComponent implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
protected readonly ProductType = ProductType;
|
||||
protected readonly ProductTierType = ProductTierType;
|
||||
}
|
||||
|
||||
function mapCollectionToAccessItemView(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AbstractControl, FormControl, ValidationErrors } from "@angular/forms";
|
||||
|
||||
import { OrganizationUserType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
|
||||
import { orgSeatLimitReachedValidator } from "./org-seat-limit-reached.validator";
|
||||
|
||||
@@ -54,7 +54,7 @@ describe("orgSeatLimitReachedValidator", () => {
|
||||
|
||||
it("should return null when max seats are not exceeded on free plan", () => {
|
||||
organization = orgFactory({
|
||||
planProductType: ProductType.Free,
|
||||
productTierType: ProductTierType.Free,
|
||||
seats: 2,
|
||||
});
|
||||
validatorFn = orgSeatLimitReachedValidator(
|
||||
@@ -71,7 +71,7 @@ describe("orgSeatLimitReachedValidator", () => {
|
||||
|
||||
it("should return null when max seats are not exceeded on teams starter plan", () => {
|
||||
organization = orgFactory({
|
||||
planProductType: ProductType.TeamsStarter,
|
||||
productTierType: ProductTierType.TeamsStarter,
|
||||
seats: 10,
|
||||
});
|
||||
validatorFn = orgSeatLimitReachedValidator(
|
||||
@@ -98,7 +98,7 @@ describe("orgSeatLimitReachedValidator", () => {
|
||||
|
||||
it("should return validation error when max seats are exceeded on free plan", () => {
|
||||
organization = orgFactory({
|
||||
planProductType: ProductType.Free,
|
||||
productTierType: ProductTierType.Free,
|
||||
seats: 2,
|
||||
});
|
||||
const errorMessage = "You cannot invite more than 2 members without upgrading your plan.";
|
||||
@@ -117,7 +117,7 @@ describe("orgSeatLimitReachedValidator", () => {
|
||||
it("should return null when not on free plan", () => {
|
||||
const control = new FormControl("user2@example.com,user3@example.com");
|
||||
organization = orgFactory({
|
||||
planProductType: ProductType.Enterprise,
|
||||
productTierType: ProductTierType.Enterprise,
|
||||
seats: 100,
|
||||
});
|
||||
validatorFn = orgSeatLimitReachedValidator(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractControl, ValidationErrors, ValidatorFn } from "@angular/forms";
|
||||
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
|
||||
/**
|
||||
* If the organization doesn't allow additional seat options, this checks if the seat limit has been reached when adding
|
||||
@@ -37,9 +37,9 @@ export function orgSeatLimitReachedValidator(
|
||||
);
|
||||
|
||||
const productHasAdditionalSeatsOption =
|
||||
organization.planProductType !== ProductType.Free &&
|
||||
organization.planProductType !== ProductType.Families &&
|
||||
organization.planProductType !== ProductType.TeamsStarter;
|
||||
organization.productTierType !== ProductTierType.Free &&
|
||||
organization.productTierType !== ProductTierType.Families &&
|
||||
organization.productTierType !== ProductTierType.TeamsStarter;
|
||||
|
||||
return !productHasAdditionalSeatsOption &&
|
||||
allOrganizationUserEmails.length + newEmailsToAdd.length > organization.seats
|
||||
|
||||
@@ -33,7 +33,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
import { OrganizationKeysRequest } from "@bitwarden/common/admin-console/models/request/organization-keys.request";
|
||||
import { BillingApiServiceAbstraction } from "@bitwarden/common/billing/abstractions/billilng-api.service.abstraction";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
@@ -335,13 +335,13 @@ export class PeopleComponent extends NewBasePeopleComponent<OrganizationUserView
|
||||
return this.organization.canEditSubscription ? "ManageBilling" : "NoManageBilling";
|
||||
}
|
||||
|
||||
private getProductKey(productType: ProductType): string {
|
||||
private getProductKey(productType: ProductTierType): string {
|
||||
let product = "";
|
||||
switch (productType) {
|
||||
case ProductType.Free:
|
||||
case ProductTierType.Free:
|
||||
product = "freeOrg";
|
||||
break;
|
||||
case ProductType.TeamsStarter:
|
||||
case ProductTierType.TeamsStarter:
|
||||
product = "teamsStarterPlan";
|
||||
break;
|
||||
default:
|
||||
@@ -352,7 +352,7 @@ export class PeopleComponent extends NewBasePeopleComponent<OrganizationUserView
|
||||
|
||||
private getDialogContent(): string {
|
||||
return this.i18nService.t(
|
||||
this.getProductKey(this.organization.planProductType),
|
||||
this.getProductKey(this.organization.productTierType),
|
||||
this.organization.seats,
|
||||
);
|
||||
}
|
||||
@@ -362,9 +362,9 @@ export class PeopleComponent extends NewBasePeopleComponent<OrganizationUserView
|
||||
return this.i18nService.t("ok");
|
||||
}
|
||||
|
||||
const productType = this.organization.planProductType;
|
||||
const productType = this.organization.productTierType;
|
||||
|
||||
if (productType !== ProductType.Free && productType !== ProductType.TeamsStarter) {
|
||||
if (productType !== ProductTierType.Free && productType !== ProductTierType.TeamsStarter) {
|
||||
throw new Error(`Unsupported product type: ${productType}`);
|
||||
}
|
||||
|
||||
@@ -376,10 +376,10 @@ export class PeopleComponent extends NewBasePeopleComponent<OrganizationUserView
|
||||
return;
|
||||
}
|
||||
|
||||
const productType = this.organization.planProductType;
|
||||
const productType = this.organization.productTierType;
|
||||
|
||||
if (productType !== ProductType.Free && productType !== ProductType.TeamsStarter) {
|
||||
throw new Error(`Unsupported product type: ${this.organization.planProductType}`);
|
||||
if (productType !== ProductTierType.Free && productType !== ProductTierType.TeamsStarter) {
|
||||
throw new Error(`Unsupported product type: ${this.organization.productTierType}`);
|
||||
}
|
||||
|
||||
await this.router.navigate(
|
||||
@@ -423,8 +423,8 @@ export class PeopleComponent extends NewBasePeopleComponent<OrganizationUserView
|
||||
if (
|
||||
!user &&
|
||||
this.allUsers.length === this.organization.seats &&
|
||||
(this.organization.planProductType === ProductType.Free ||
|
||||
this.organization.planProductType === ProductType.TeamsStarter)
|
||||
(this.organization.productTierType === ProductTierType.Free ||
|
||||
this.organization.productTierType === ProductTierType.TeamsStarter)
|
||||
) {
|
||||
// Show org upgrade modal
|
||||
await this.showSeatLimitReachedDialog();
|
||||
|
||||
@@ -8,8 +8,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { OrganizationSponsorshipRedeemRequest } from "@bitwarden/common/admin-console/models/request/organization/organization-sponsorship-redeem.request";
|
||||
import { PlanSponsorshipType, PlanType } from "@bitwarden/common/billing/enums";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { PlanSponsorshipType, PlanType, ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||
@@ -36,7 +35,7 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
value.plan = PlanType.FamiliesAnnually;
|
||||
value.product = ProductType.Families;
|
||||
value.productTier = ProductTierType.Families;
|
||||
value.acceptingSponsorship = true;
|
||||
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
||||
value.onSuccess.subscribe(this.onOrganizationCreateSuccess.bind(this));
|
||||
@@ -96,7 +95,7 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
|
||||
this.existingFamilyOrganizations$ = this.organizationService.organizations$.pipe(
|
||||
map((orgs) => orgs.filter((o) => o.planProductType === ProductType.Families)),
|
||||
map((orgs) => orgs.filter((o) => o.productTierType === ProductTierType.Families)),
|
||||
);
|
||||
|
||||
this.existingFamilyOrganizations$.pipe(takeUntil(this._destroy)).subscribe((orgs) => {
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Component, OnInit, ViewChild } from "@angular/core";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { first } from "rxjs/operators";
|
||||
|
||||
import { PlanType } from "@bitwarden/common/billing/enums";
|
||||
import { ProductType } from "@bitwarden/common/enums";
|
||||
import { PlanType, ProductTierType } from "@bitwarden/common/billing/enums";
|
||||
|
||||
import { OrganizationPlansComponent } from "../../billing";
|
||||
import { HeaderModule } from "../../layouts/header/header.module";
|
||||
@@ -26,16 +25,16 @@ export class CreateOrganizationComponent implements OnInit {
|
||||
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
|
||||
if (qParams.plan === "families") {
|
||||
this.orgPlansComponent.plan = PlanType.FamiliesAnnually;
|
||||
this.orgPlansComponent.product = ProductType.Families;
|
||||
this.orgPlansComponent.productTier = ProductTierType.Families;
|
||||
} else if (qParams.plan === "teams") {
|
||||
this.orgPlansComponent.plan = PlanType.TeamsAnnually;
|
||||
this.orgPlansComponent.product = ProductType.Teams;
|
||||
this.orgPlansComponent.productTier = ProductTierType.Teams;
|
||||
} else if (qParams.plan === "teamsStarter") {
|
||||
this.orgPlansComponent.plan = PlanType.TeamsStarter;
|
||||
this.orgPlansComponent.product = ProductType.TeamsStarter;
|
||||
this.orgPlansComponent.productTier = ProductTierType.TeamsStarter;
|
||||
} else if (qParams.plan === "enterprise") {
|
||||
this.orgPlansComponent.plan = PlanType.EnterpriseAnnually;
|
||||
this.orgPlansComponent.product = ProductType.Enterprise;
|
||||
this.orgPlansComponent.productTier = ProductTierType.Enterprise;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user