mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
* migrate all components to use PremiumBadgeComponent * move badge component to vault * move premium badge to vault * move premium badge to billing * fix import * use premium badge in tools new send dropdown * remove badge module import * remove module
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { CommonModule } from "@angular/common";
|
|
import { Component, Input, OnInit } from "@angular/core";
|
|
import { RouterLink } from "@angular/router";
|
|
import { firstValueFrom } from "rxjs";
|
|
|
|
import { PremiumBadgeComponent } from "@bitwarden/angular/billing/components/premium-badge";
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
|
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
|
import { ButtonModule, ButtonType, MenuModule } from "@bitwarden/components";
|
|
|
|
@Component({
|
|
selector: "tools-new-send-dropdown",
|
|
templateUrl: "new-send-dropdown.component.html",
|
|
imports: [JslibModule, CommonModule, ButtonModule, RouterLink, MenuModule, PremiumBadgeComponent],
|
|
})
|
|
export class NewSendDropdownComponent implements OnInit {
|
|
@Input() hideIcon: boolean = false;
|
|
@Input() buttonType: ButtonType = "primary";
|
|
|
|
sendType = SendType;
|
|
|
|
hasNoPremium = false;
|
|
|
|
constructor(
|
|
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
|
private accountService: AccountService,
|
|
) {}
|
|
|
|
async ngOnInit() {
|
|
const account = await firstValueFrom(this.accountService.activeAccount$);
|
|
if (!account) {
|
|
this.hasNoPremium = true;
|
|
return;
|
|
}
|
|
|
|
this.hasNoPremium = !(await firstValueFrom(
|
|
this.billingAccountProfileStateService.hasPremiumFromAnySource$(account.id),
|
|
));
|
|
}
|
|
|
|
buildRouterLink(type: SendType) {
|
|
if (this.hasNoPremium && type === SendType.File) {
|
|
return "/premium";
|
|
} else {
|
|
return "/add-send";
|
|
}
|
|
}
|
|
|
|
buildQueryParams(type: SendType) {
|
|
if (this.hasNoPremium && type === SendType.File) {
|
|
return null;
|
|
}
|
|
return { type: type, isNew: true };
|
|
}
|
|
}
|