From 2ea2045686ea6eb594e8df327ecb58781641c6b9 Mon Sep 17 00:00:00 2001 From: aj-rosado <109146700+aj-rosado@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:56:21 +0100 Subject: [PATCH] Added option to through queryParams pre select the desired upgrade option on the subscription page (#10145) --- .../organizations/guards/is-enterprise-org.guard.ts | 2 +- .../app/billing/organizations/change-plan.component.html | 1 + .../app/billing/organizations/change-plan.component.ts | 2 ++ .../billing/organizations/organization-plans.component.ts | 4 ++++ .../organization-subscription-cloud.component.html | 1 + .../organization-subscription-cloud.component.ts | 8 ++++++++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/admin-console/organizations/guards/is-enterprise-org.guard.ts b/apps/web/src/app/admin-console/organizations/guards/is-enterprise-org.guard.ts index 8e35c60db9..605ce0059d 100644 --- a/apps/web/src/app/admin-console/organizations/guards/is-enterprise-org.guard.ts +++ b/apps/web/src/app/admin-console/organizations/guards/is-enterprise-org.guard.ts @@ -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 }, }); } } diff --git a/apps/web/src/app/billing/organizations/change-plan.component.html b/apps/web/src/app/billing/organizations/change-plan.component.html index a25dde4fd3..75a12122d1 100644 --- a/apps/web/src/app/billing/organizations/change-plan.component.html +++ b/apps/web/src/app/billing/organizations/change-plan.component.html @@ -18,6 +18,7 @@ [showCancel]="true" [organizationId]="organizationId" [currentPlan]="currentPlan" + [preSelectedProductTier]="preSelectedProductTier" (onCanceled)="cancel()" > diff --git a/apps/web/src/app/billing/organizations/change-plan.component.ts b/apps/web/src/app/billing/organizations/change-plan.component.ts index a131e344b7..51cdbba557 100644 --- a/apps/web/src/app/billing/organizations/change-plan.component.ts +++ b/apps/web/src/app/billing/organizations/change-plan.component.ts @@ -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(); 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 661b896913..4f8fbea94d 100644 --- a/apps/web/src/app/billing/organizations/organization-plans.component.ts +++ b/apps/web/src/app/billing/organizations/organization-plans.component.ts @@ -95,6 +95,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy { private _plan = PlanType.Free; @Input() providerId?: string; + @Input() preSelectedProductTier?: ProductTierType; @Output() onSuccess = new EventEmitter(); @Output() onCanceled = new EventEmitter(); @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(); } diff --git a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html index e519b8887b..72a0a40080 100644 --- a/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html +++ b/apps/web/src/app/billing/organizations/organization-subscription-cloud.component.html @@ -122,6 +122,7 @@