mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
* feature flag * new upgrade dialog component and moved pricing service into libs first draft * moved pricing service to libs/common removed toast service from the pricing service and implemented error handling in calling components # Conflicts: # apps/web/src/app/billing/individual/upgrade/upgrade-payment/upgrade-payment.component.ts * moved new premium upgrade dialog component to libs/angular * badge opens new dialog in browser extension * adds new dialog to desktop and fixes tests * updates send dropdown to use premium prompt service * styling and copy updates * implement in web and desktop * unit tests * converting premium reports to use premium badge, and some cleanup * fixes issue after merge * linter errors * pr feedback * handle async promise correctly * full sync after the premium upgrade is complete * fixing test * add padding to bottom of card in new dialog * add support for self hosting * fixing tests * fix test * Update has-premium.guard.ts * pr feedback * fix build and pr feedback * fix build * prettier * fixing stories and making badge line height consistent * pr feedback * updated upgrade dialog to no longer use pricing card * fixing incorrect markup and removing unused bits * formatting * pr feedback removing unused message keys and adding back in code that was erroneously removed * change detection * close dialog when error * claude pr feedback
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { DestroyRef, Directive, OnInit, TemplateRef, ViewContainerRef } from "@angular/core";
|
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
import { firstValueFrom } from "rxjs";
|
|
|
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
|
|
/**
|
|
* Hides the element if the user has premium.
|
|
*/
|
|
@Directive({
|
|
selector: "[appNotPremium]",
|
|
standalone: false,
|
|
})
|
|
export class NotPremiumDirective implements OnInit {
|
|
constructor(
|
|
private templateRef: TemplateRef<any>,
|
|
private viewContainer: ViewContainerRef,
|
|
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
|
private destroyRef: DestroyRef,
|
|
private accountService: AccountService,
|
|
) {}
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
const account = await firstValueFrom(this.accountService.activeAccount$);
|
|
|
|
if (!account) {
|
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
return;
|
|
}
|
|
|
|
this.billingAccountProfileStateService
|
|
.hasPremiumFromAnySource$(account.id)
|
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
.subscribe((premium) => {
|
|
if (premium) {
|
|
this.viewContainer.clear();
|
|
} else {
|
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
}
|
|
});
|
|
}
|
|
}
|