From 163aab202bb1db3afdbb6b712366b68d885fd373 Mon Sep 17 00:00:00 2001 From: Conner Turnbull <133619638+cturnbull-bitwarden@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:19:11 -0500 Subject: [PATCH] [AC-1359] Setting plan and product to Teams if adding an org from a provider (#7269) * wip * Running prettier after npm ci * Defects AC-1929 AC-1955 AC-1956 * Setting plan and product to Teams if adding an org from a provider * Updated logic to correctly set seat count depending on how you approach the upgrade flow * Moved logic setting seat count to changedProduct * Setting sm seats when upgrading to the current count * Setting max storage if the organization's current plan has it set above the base * Refactored logic in changedProduct to be a bit more concise. Added logic for handling sm service accounts and storage increases * Decomposed the logic in changedProduct * Resolved defects introduced in the merge conflict * Changes after executing `npm run prettier` --------- Co-authored-by: Alex Morask Co-authored-by: Daniel James Smith --- .../organization-plans.component.ts | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/billing/organizations/organization-plans.component.ts b/apps/web/src/app/billing/organizations/organization-plans.component.ts index 6f01d42174b..dd246b5f75b 100644 --- a/apps/web/src/app/billing/organizations/organization-plans.component.ts +++ b/apps/web/src/app/billing/organizations/organization-plans.component.ts @@ -167,10 +167,26 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy { } } + if (this.currentPlan && this.currentPlan.product !== ProductType.Enterprise) { + const upgradedPlan = this.passwordManagerPlans.find((plan) => + this.currentPlan.product === ProductType.Free + ? plan.type === PlanType.FamiliesAnnually + : plan.upgradeSortOrder == this.currentPlan.upgradeSortOrder + 1, + ); + + this.plan = upgradedPlan.type; + this.product = upgradedPlan.product; + } + if (this.hasProvider) { this.formGroup.controls.businessOwned.setValue(true); this.changedOwnedBusiness(); this.provider = await this.apiService.getProvider(this.providerId); + const providerDefaultPlan = this.passwordManagerPlans.find( + (plan) => plan.type === PlanType.TeamsAnnually, + ); + this.plan = providerDefaultPlan.type; + this.product = providerDefaultPlan.product; } if (!this.createOrganization) { @@ -187,6 +203,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy { this.singleOrgPolicyAppliesToActiveUser = policyAppliesToActiveUser; }); + this.changedProduct(); this.loading = false; } @@ -448,12 +465,17 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy { return; } - if (!this.currentPlan?.PasswordManager?.hasAdditionalSeatsOption) { + if (this.currentPlan && !this.currentPlan.PasswordManager.hasAdditionalSeatsOption) { this.formGroup.controls.additionalSeats.setValue(this.currentPlan.PasswordManager.baseSeats); return; } - this.formGroup.controls.additionalSeats.setValue(this.organization.seats); + if (this.organization) { + this.formGroup.controls.additionalSeats.setValue(this.organization.seats); + return; + } + + this.formGroup.controls.additionalSeats.setValue(1); } handleSecretsManagerForm() { @@ -461,7 +483,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy { this.secretsManagerForm.enable(); } - if (this.organization.useSecretsManager) { + if (this.organization?.useSecretsManager) { this.secretsManagerForm.controls.enabled.setValue(true); }