[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 <amorask@bitwarden.com>
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Conner Turnbull 2023-12-28 15:19:11 -05:00 committed by GitHub
parent 2068d4879a
commit 163aab202b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 3 deletions

View File

@ -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);
}