1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-02 18:17:46 +01:00

[PM-9855] Add premium badge to new file send item dropdown (#10137)

* Create browsers SendV2 component

* Add premium badge to new file send item dropdown

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2024-07-18 15:41:09 +02:00 committed by GitHub
parent 84b719d797
commit cebbb9486e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 5 deletions

View File

@ -10,5 +10,8 @@
<a type="button" bitMenuItem (click)="newItemNavigate(sendType.File)"> <a type="button" bitMenuItem (click)="newItemNavigate(sendType.File)">
<i class="bwi bwi-file" slot="start" aria-hidden="true"></i> <i class="bwi bwi-file" slot="start" aria-hidden="true"></i>
{{ "sendTypeFile" | i18n }} {{ "sendTypeFile" | i18n }}
<button type="button" slot="end" *ngIf="hasNoPremium" bitBadge variant="success">
{{ "premium" | i18n }}
</button>
</a> </a>
</bit-menu> </bit-menu>

View File

@ -1,23 +1,39 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { Component } from "@angular/core"; import { Component, OnInit } from "@angular/core";
import { Router, RouterLink } from "@angular/router"; import { Router, RouterLink } from "@angular/router";
import { firstValueFrom } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module"; 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 { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { ButtonModule, MenuModule } from "@bitwarden/components"; import { BadgeModule, ButtonModule, MenuModule } from "@bitwarden/components";
@Component({ @Component({
selector: "tools-new-send-dropdown", selector: "tools-new-send-dropdown",
templateUrl: "new-send-dropdown.component.html", templateUrl: "new-send-dropdown.component.html",
standalone: true, standalone: true,
imports: [JslibModule, CommonModule, ButtonModule, RouterLink, MenuModule], imports: [JslibModule, CommonModule, ButtonModule, RouterLink, MenuModule, BadgeModule],
}) })
export class NewSendDropdownComponent { export class NewSendDropdownComponent implements OnInit {
sendType = SendType; sendType = SendType;
constructor(private router: Router) {} hasNoPremium = false;
constructor(
private router: Router,
private billingAccountProfileStateService: BillingAccountProfileStateService,
) {}
async ngOnInit() {
this.hasNoPremium = !(await firstValueFrom(
this.billingAccountProfileStateService.hasPremiumFromAnySource$,
));
}
newItemNavigate(type: SendType) { 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 } }); void this.router.navigate(["/add-send"], { queryParams: { type: type, isNew: true } });
} }
} }