Added option to through queryParams pre select the desired upgrade option on the subscription page (#10145)

This commit is contained in:
aj-rosado 2024-07-23 12:56:21 +01:00 committed by GitHub
parent 57b8c30664
commit 2ea2045686
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 1 deletions

View File

@ -56,7 +56,7 @@ export class IsEnterpriseOrgGuard implements CanActivate {
});
if (upgradeConfirmed) {
await this.router.navigate(["organizations", org.id, "billing", "subscription"], {
queryParams: { upgrade: true },
queryParams: { upgrade: true, productTierType: ProductTierType.Enterprise },
});
}
}

View File

@ -18,6 +18,7 @@
[showCancel]="true"
[organizationId]="organizationId"
[currentPlan]="currentPlan"
[preSelectedProductTier]="preSelectedProductTier"
(onCanceled)="cancel()"
>
</app-organization-plans>

View File

@ -1,5 +1,6 @@
import { Component, EventEmitter, Input, Output } from "@angular/core";
import { ProductTierType } from "@bitwarden/common/billing/enums";
import { PlanResponse } from "@bitwarden/common/billing/models/response/plan.response";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@ -10,6 +11,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
export class ChangePlanComponent {
@Input() organizationId: string;
@Input() currentPlan: PlanResponse;
@Input() preSelectedProductTier: ProductTierType;
@Output() onChanged = new EventEmitter();
@Output() onCanceled = new EventEmitter();

View File

@ -95,6 +95,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
private _plan = PlanType.Free;
@Input() providerId?: string;
@Input() preSelectedProductTier?: ProductTierType;
@Output() onSuccess = new EventEmitter<OnSuccessArgs>();
@Output() onCanceled = new EventEmitter<void>();
@Output() onTrialBillingSuccess = new EventEmitter();
@ -209,6 +210,9 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
this.singleOrgPolicyAppliesToActiveUser = policyAppliesToActiveUser;
});
if (this.preSelectedProductTier != null && this.productTier < this.preSelectedProductTier) {
this.productTier = this.preSelectedProductTier;
}
if (!this.selfHosted) {
this.changedProduct();
}

View File

@ -122,6 +122,7 @@
<app-change-plan
[organizationId]="organizationId"
[currentPlan]="sub.plan"
[preSelectedProductTier]="preSelectedProductTier"
(onChanged)="closeChangePlan()"
(onCanceled)="closeChangePlan()"
*ngIf="showChangePlan"

View File

@ -52,6 +52,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
manageBillingFromProviderPortal = ManageBilling;
isProviderManaged = false;
enableTimeThreshold: boolean;
preSelectedProductTier: ProductTierType = ProductTierType.Free;
protected readonly teamsStarter = ProductTierType.TeamsStarter;
@ -83,6 +84,13 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.changePlan();
const productTierTypeStr = this.route.snapshot.queryParamMap.get("productTierType");
if (productTierTypeStr != null) {
const productTier = Number(productTierTypeStr);
if (Object.values(ProductTierType).includes(productTier as ProductTierType)) {
this.preSelectedProductTier = productTier;
}
}
}
this.route.params