1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 18:23:31 +00:00
Files
browser/libs/tools/send/send-ui/src/new-send-dropdown/new-send-dropdown.component.ts
Jordan Aasen 5a1583cb0a [PM-12732] - fix new send button (#11266)
* fix new send button

* simplify logic. use static class name where possible
2024-10-01 11:36:34 +02:00

42 lines
1.4 KiB
TypeScript

import { CommonModule } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
import { Router, RouterLink } from "@angular/router";
import { firstValueFrom } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { BadgeModule, ButtonModule, MenuModule } from "@bitwarden/components";
@Component({
selector: "tools-new-send-dropdown",
templateUrl: "new-send-dropdown.component.html",
standalone: true,
imports: [JslibModule, CommonModule, ButtonModule, RouterLink, MenuModule, BadgeModule],
})
export class NewSendDropdownComponent implements OnInit {
@Input() hideIcon: boolean = false;
sendType = SendType;
hasNoPremium = false;
constructor(
private router: Router,
private billingAccountProfileStateService: BillingAccountProfileStateService,
) {}
async ngOnInit() {
this.hasNoPremium = !(await firstValueFrom(
this.billingAccountProfileStateService.hasPremiumFromAnySource$,
));
}
newItemNavigate(type: SendType) {
if (this.hasNoPremium && type === SendType.File) {
return this.router.navigate(["/premium"]);
}
void this.router.navigate(["/add-send"], { queryParams: { type: type, isNew: true } });
}
}