mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 05:30:01 +00:00
Add feature flagged usage of NewSendDropdown component
This commit is contained in:
@@ -138,7 +138,13 @@
|
||||
</ng-container>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<tools-new-send-dropdown
|
||||
*ngIf="isDesktopSendUIRefreshEnabled$ | async"
|
||||
(onCreateSendOfType)="addSend($event)"
|
||||
>
|
||||
</tools-new-send-dropdown>
|
||||
<button
|
||||
*ngIf="!(isDesktopSendUIRefreshEnabled$ | async)"
|
||||
type="button"
|
||||
(click)="addSend()"
|
||||
class="block primary"
|
||||
|
||||
@@ -3,17 +3,21 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, NgZone, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||
import { FormsModule } from "@angular/forms";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { SendComponent as BaseSendComponent } from "@bitwarden/angular/tools/send/send.component";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
||||
@@ -24,6 +28,7 @@ import { NavComponent } from "../../layout/nav.component";
|
||||
import { SearchBarService } from "../../layout/search/search-bar.service";
|
||||
|
||||
import { AddEditComponent } from "./add-edit.component";
|
||||
import { NewSendDropdownComponent } from "./new-send/new-send-dropdown.component";
|
||||
|
||||
enum Action {
|
||||
None = "",
|
||||
@@ -37,7 +42,14 @@ const BroadcasterSubscriptionId = "SendComponent";
|
||||
selector: "app-send",
|
||||
templateUrl: "send.component.html",
|
||||
standalone: true,
|
||||
imports: [CommonModule, JslibModule, FormsModule, NavComponent, AddEditComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
JslibModule,
|
||||
FormsModule,
|
||||
NavComponent,
|
||||
AddEditComponent,
|
||||
NewSendDropdownComponent,
|
||||
],
|
||||
})
|
||||
export class SendComponent extends BaseSendComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(AddEditComponent) addEditComponent: AddEditComponent;
|
||||
@@ -45,6 +57,9 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
|
||||
sendId: string;
|
||||
action: Action = Action.None;
|
||||
|
||||
/* Observable that represents if the Desktop Send UI Refresh feature flag is enabled or not */
|
||||
protected isDesktopSendUIRefreshEnabled$: Observable<boolean>;
|
||||
|
||||
constructor(
|
||||
sendService: SendService,
|
||||
i18nService: I18nService,
|
||||
@@ -60,6 +75,7 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
|
||||
dialogService: DialogService,
|
||||
toastService: ToastService,
|
||||
accountService: AccountService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
super(
|
||||
sendService,
|
||||
@@ -75,6 +91,10 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
|
||||
toastService,
|
||||
accountService,
|
||||
);
|
||||
this.isDesktopSendUIRefreshEnabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.DesktopSendUIRefresh,
|
||||
);
|
||||
|
||||
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
||||
this.searchBarService.searchText$.subscribe((searchText) => {
|
||||
this.searchText = searchText;
|
||||
@@ -108,7 +128,7 @@ export class SendComponent extends BaseSendComponent implements OnInit, OnDestro
|
||||
this.searchBarService.setEnabled(false);
|
||||
}
|
||||
|
||||
async addSend() {
|
||||
async addSend(sendType?: SendType) {
|
||||
this.action = Action.Add;
|
||||
if (this.addEditComponent != null) {
|
||||
await this.addEditComponent.resetAndLoad();
|
||||
|
||||
Reference in New Issue
Block a user