mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
[PM-26019] Pre-Launch Payment Dialog (#16859)
This commit is contained in:
@@ -42,6 +42,13 @@ import {
|
|||||||
UnifiedUpgradeDialogStep,
|
UnifiedUpgradeDialogStep,
|
||||||
} from "../upgrade/unified-upgrade-dialog/unified-upgrade-dialog.component";
|
} from "../upgrade/unified-upgrade-dialog/unified-upgrade-dialog.component";
|
||||||
|
|
||||||
|
const RouteParams = {
|
||||||
|
callToAction: "callToAction",
|
||||||
|
} as const;
|
||||||
|
const RouteParamValues = {
|
||||||
|
upgradeToPremium: "upgradeToPremium",
|
||||||
|
} as const;
|
||||||
|
|
||||||
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
|
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
|
||||||
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
|
||||||
@Component({
|
@Component({
|
||||||
@@ -61,6 +68,7 @@ export class PremiumVNextComponent {
|
|||||||
protected hasPremiumFromAnyOrganization$: Observable<boolean>;
|
protected hasPremiumFromAnyOrganization$: Observable<boolean>;
|
||||||
protected hasPremiumPersonally$: Observable<boolean>;
|
protected hasPremiumPersonally$: Observable<boolean>;
|
||||||
protected shouldShowNewDesign$: Observable<boolean>;
|
protected shouldShowNewDesign$: Observable<boolean>;
|
||||||
|
protected shouldShowUpgradeDialogOnInit$: Observable<boolean>;
|
||||||
protected personalPricingTiers$: Observable<PersonalSubscriptionPricingTier[]>;
|
protected personalPricingTiers$: Observable<PersonalSubscriptionPricingTier[]>;
|
||||||
protected premiumCardData$: Observable<{
|
protected premiumCardData$: Observable<{
|
||||||
tier: PersonalSubscriptionPricingTier | undefined;
|
tier: PersonalSubscriptionPricingTier | undefined;
|
||||||
@@ -72,7 +80,6 @@ export class PremiumVNextComponent {
|
|||||||
price: number;
|
price: number;
|
||||||
features: string[];
|
features: string[];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
protected subscriber!: BitwardenSubscriber;
|
protected subscriber!: BitwardenSubscriber;
|
||||||
protected isSelfHost = false;
|
protected isSelfHost = false;
|
||||||
private destroyRef = inject(DestroyRef);
|
private destroyRef = inject(DestroyRef);
|
||||||
@@ -134,6 +141,17 @@ export class PremiumVNextComponent {
|
|||||||
)
|
)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
|
this.shouldShowUpgradeDialogOnInit$ = combineLatest([
|
||||||
|
this.hasPremiumFromAnyOrganization$,
|
||||||
|
this.hasPremiumPersonally$,
|
||||||
|
this.activatedRoute.queryParams,
|
||||||
|
]).pipe(
|
||||||
|
map(([hasOrgPremium, hasPersonalPremium, queryParams]) => {
|
||||||
|
const cta = queryParams[RouteParams.callToAction];
|
||||||
|
return !hasOrgPremium && !hasPersonalPremium && cta === RouteParamValues.upgradeToPremium;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.personalPricingTiers$ =
|
this.personalPricingTiers$ =
|
||||||
this.subscriptionPricingService.getPersonalSubscriptionPricingTiers$();
|
this.subscriptionPricingService.getPersonalSubscriptionPricingTiers$();
|
||||||
|
|
||||||
@@ -166,6 +184,17 @@ export class PremiumVNextComponent {
|
|||||||
}),
|
}),
|
||||||
shareReplay({ bufferSize: 1, refCount: true }),
|
shareReplay({ bufferSize: 1, refCount: true }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.shouldShowUpgradeDialogOnInit$
|
||||||
|
.pipe(
|
||||||
|
switchMap(async (shouldShowUpgradeDialogOnInit) => {
|
||||||
|
if (shouldShowUpgradeDialogOnInit) {
|
||||||
|
from(this.openUpgradeDialog("Premium"));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
takeUntilDestroyed(this.destroyRef),
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
private navigateToSubscriptionPage = (): Promise<boolean> =>
|
private navigateToSubscriptionPage = (): Promise<boolean> =>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewChecked,
|
||||||
Component,
|
Component,
|
||||||
DestroyRef,
|
DestroyRef,
|
||||||
input,
|
input,
|
||||||
@@ -96,7 +96,7 @@ export type UpgradePaymentParams = {
|
|||||||
providers: [UpgradePaymentService],
|
providers: [UpgradePaymentService],
|
||||||
templateUrl: "./upgrade-payment.component.html",
|
templateUrl: "./upgrade-payment.component.html",
|
||||||
})
|
})
|
||||||
export class UpgradePaymentComponent implements OnInit, AfterViewInit {
|
export class UpgradePaymentComponent implements OnInit, AfterViewChecked {
|
||||||
protected readonly selectedPlanId = input.required<PersonalSubscriptionPricingTierId>();
|
protected readonly selectedPlanId = input.required<PersonalSubscriptionPricingTierId>();
|
||||||
protected readonly account = input.required<Account>();
|
protected readonly account = input.required<Account>();
|
||||||
protected goBack = output<void>();
|
protected goBack = output<void>();
|
||||||
@@ -118,6 +118,7 @@ export class UpgradePaymentComponent implements OnInit, AfterViewInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
protected readonly loading = signal(true);
|
protected readonly loading = signal(true);
|
||||||
|
private cartSummaryConfigured = false;
|
||||||
private pricingTiers$!: Observable<PersonalSubscriptionPricingTier[]>;
|
private pricingTiers$!: Observable<PersonalSubscriptionPricingTier[]>;
|
||||||
|
|
||||||
// Cart Summary data
|
// Cart Summary data
|
||||||
@@ -201,9 +202,11 @@ export class UpgradePaymentComponent implements OnInit, AfterViewInit {
|
|||||||
this.loading.set(false);
|
this.loading.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewChecked(): void {
|
||||||
if (this.cartSummaryComponent) {
|
// Configure cart summary only once when it becomes available
|
||||||
|
if (this.cartSummaryComponent && !this.cartSummaryConfigured) {
|
||||||
this.cartSummaryComponent.isExpanded.set(false);
|
this.cartSummaryComponent.isExpanded.set(false);
|
||||||
|
this.cartSummaryConfigured = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user