mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[PM-9853] - Add SendListItemsContainer component (#10193)
* send list items container * update send list items container * finalize send list container * remove unecessary file * undo change to config * prefer use of takeUntilDestroyed * add specss
This commit is contained in:
@@ -2090,6 +2090,9 @@
|
||||
"passwordProtected": {
|
||||
"message": "Password protected"
|
||||
},
|
||||
"copyLink": {
|
||||
"message": "Copy link"
|
||||
},
|
||||
"copySendLink": {
|
||||
"message": "Copy Send link",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
|
||||
@@ -8,14 +8,12 @@
|
||||
</ng-container>
|
||||
</popup-header>
|
||||
|
||||
<div
|
||||
*ngIf="sendsListState === SendsListStateEnum.Empty"
|
||||
class="tw-flex tw-flex-col tw-h-full tw-justify-center"
|
||||
>
|
||||
<div *ngIf="sends.length === 0" class="tw-flex tw-flex-col tw-h-full tw-justify-center">
|
||||
<bit-no-items [icon]="noItemIcon" class="tw-text-main">
|
||||
<ng-container slot="title">{{ "sendsNoItemsTitle" | i18n }}</ng-container>
|
||||
<ng-container slot="description">{{ "sendsNoItemsMessage" | i18n }}</ng-container>
|
||||
<tools-new-send-dropdown slot="button"></tools-new-send-dropdown>
|
||||
</bit-no-items>
|
||||
</div>
|
||||
<app-send-list-items-container [sends]="sends" />
|
||||
</popup-page>
|
||||
|
||||
101
apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts
Normal file
101
apps/browser/src/tools/popup/send-v2/send-v2.component.spec.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
||||
import { RouterLink } from "@angular/router";
|
||||
import { RouterTestingModule } from "@angular/router/testing";
|
||||
import { mock } from "jest-mock-extended";
|
||||
import { Observable, of } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.service";
|
||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions";
|
||||
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 { 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";
|
||||
import { ButtonModule, NoItemsModule } from "@bitwarden/components";
|
||||
import {
|
||||
NewSendDropdownComponent,
|
||||
SendListItemsContainerComponent,
|
||||
SendListFiltersComponent,
|
||||
} from "@bitwarden/send-ui";
|
||||
|
||||
import { CurrentAccountComponent } from "../../../auth/popup/account-switching/current-account.component";
|
||||
import { PopOutComponent } from "../../../platform/popup/components/pop-out.component";
|
||||
import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-header.component";
|
||||
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
|
||||
|
||||
import { SendV2Component } from "./send-v2.component";
|
||||
|
||||
describe("SendV2Component", () => {
|
||||
let component: SendV2Component;
|
||||
let fixture: ComponentFixture<SendV2Component>;
|
||||
let sendViews$: Observable<SendView[]>;
|
||||
|
||||
beforeEach(async () => {
|
||||
sendViews$ = of([
|
||||
{ id: "1", name: "Send A" },
|
||||
{ id: "2", name: "Send B" },
|
||||
] as SendView[]);
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterTestingModule,
|
||||
JslibModule,
|
||||
NoItemsModule,
|
||||
ButtonModule,
|
||||
NoItemsModule,
|
||||
RouterLink,
|
||||
NewSendDropdownComponent,
|
||||
SendListItemsContainerComponent,
|
||||
SendListFiltersComponent,
|
||||
PopupPageComponent,
|
||||
PopupHeaderComponent,
|
||||
PopOutComponent,
|
||||
CurrentAccountComponent,
|
||||
],
|
||||
providers: [
|
||||
{ provide: AccountService, useValue: mock<AccountService>() },
|
||||
{ provide: AuthService, useValue: mock<AuthService>() },
|
||||
{ provide: AvatarService, useValue: mock<AvatarService>() },
|
||||
{
|
||||
provide: BillingAccountProfileStateService,
|
||||
useValue: mock<BillingAccountProfileStateService>(),
|
||||
},
|
||||
{ provide: ConfigService, useValue: mock<ConfigService>() },
|
||||
{ provide: EnvironmentService, useValue: mock<EnvironmentService>() },
|
||||
{ provide: LogService, useValue: mock<LogService>() },
|
||||
{ provide: PlatformUtilsService, useValue: mock<PlatformUtilsService>() },
|
||||
{ provide: SendApiService, useValue: mock<SendApiService>() },
|
||||
{ provide: SendService, useValue: { sendViews$ } },
|
||||
{ provide: I18nService, useValue: { t: (key: string) => key } },
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(SendV2Component);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it("should create", () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should sort sends by name on initialization", async () => {
|
||||
const sortedSends = [
|
||||
{ id: "1", name: "Send A" },
|
||||
{ id: "2", name: "Send B" },
|
||||
] as SendView[];
|
||||
|
||||
await component.ngOnInit();
|
||||
|
||||
expect(component.sends).toEqual(sortedSends);
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,17 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { RouterLink } from "@angular/router";
|
||||
import { mergeMap, Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
|
||||
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
||||
import { ButtonModule, NoItemsModule } from "@bitwarden/components";
|
||||
import {
|
||||
NoSendsIcon,
|
||||
NewSendDropdownComponent,
|
||||
SendListItemsContainerComponent,
|
||||
SendListFiltersComponent,
|
||||
} from "@bitwarden/send-ui";
|
||||
|
||||
@@ -16,10 +20,6 @@ import { PopOutComponent } from "../../../platform/popup/components/pop-out.comp
|
||||
import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-header.component";
|
||||
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
|
||||
|
||||
enum SendsListState {
|
||||
Empty,
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: "send-v2.component.html",
|
||||
standalone: true,
|
||||
@@ -34,24 +34,31 @@ enum SendsListState {
|
||||
ButtonModule,
|
||||
RouterLink,
|
||||
NewSendDropdownComponent,
|
||||
SendListItemsContainerComponent,
|
||||
SendListFiltersComponent,
|
||||
],
|
||||
})
|
||||
export class SendV2Component implements OnInit, OnDestroy {
|
||||
sendType = SendType;
|
||||
|
||||
/** Visual state of the Sends list */
|
||||
protected sendsListState: SendsListState | null = null;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
sends: SendView[] = [];
|
||||
|
||||
protected noItemIcon = NoSendsIcon;
|
||||
|
||||
protected SendsListStateEnum = SendsListState;
|
||||
constructor(protected sendService: SendService) {}
|
||||
|
||||
constructor() {
|
||||
this.sendsListState = SendsListState.Empty;
|
||||
async ngOnInit() {
|
||||
this.sendService.sendViews$
|
||||
.pipe(
|
||||
mergeMap(async (sends) => {
|
||||
this.sends = sends.sort((a, b) => a.name.localeCompare(b.name));
|
||||
}),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
ngOnDestroy(): void {}
|
||||
}
|
||||
|
||||
@@ -4386,6 +4386,9 @@
|
||||
"message": "Send link",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
},
|
||||
"copyLink": {
|
||||
"message": "Copy link"
|
||||
},
|
||||
"copySendLink": {
|
||||
"message": "Copy Send link",
|
||||
"description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated."
|
||||
|
||||
Reference in New Issue
Block a user