From a18d509409731039708c02ec11cf524c5c60a541 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Thu, 18 Jul 2024 16:54:22 -0700 Subject: [PATCH] update send list items container --- .../src/tools/popup/send/send-v2.component.ts | 2 +- apps/desktop/src/locales/en/messages.json | 26 +++++++- .../send-list-items-container.component.html | 66 +++++++++++-------- .../send-list-items-container.component.ts | 54 ++++++++++++++- 4 files changed, 114 insertions(+), 34 deletions(-) diff --git a/apps/browser/src/tools/popup/send/send-v2.component.ts b/apps/browser/src/tools/popup/send/send-v2.component.ts index 1708d30f87f..c720a27ffb0 100644 --- a/apps/browser/src/tools/popup/send/send-v2.component.ts +++ b/apps/browser/src/tools/popup/send/send-v2.component.ts @@ -51,7 +51,7 @@ export class SendV2Component implements OnInit, OnDestroy { this.sendService.sendViews$ .pipe( mergeMap(async (sends) => { - this.sends = sends; + this.sends = sends.sort((a, b) => a.name.localeCompare(b.name)); }), takeUntil(this.destroy$), ) diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index c0ce5c17ee2..abbdfef84a0 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -1368,7 +1368,7 @@ }, "exportPasswordDescription": { "message": "This password will be used to export and import this file" - }, + }, "accountRestrictedOptionDescription": { "message": "Use your account encryption key, derived from your account's username and Master Password, to encrypt the export and restrict import to only the current Bitwarden account." }, @@ -1937,6 +1937,30 @@ "copyLink": { "message": "Copy link" }, + "copySendTitle": { + "message": "Copy link - $NAME$", + "placeholders": { + "name": { + "content": "$1" + } + } + }, + "deleteSend": { + "message": "Delete - $NAME$", + "placeholders": { + "name": { + "content": "$1" + } + } + }, + "editSendTitle": { + "message": "Edit - $NAME$", + "placeholders": { + "name": { + "content": "$1" + } + } + }, "disabled": { "message": "Disabled" }, diff --git a/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html index f6e13e6c122..feb87eda39e 100644 --- a/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html +++ b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html @@ -3,42 +3,50 @@

{{ "allSends" | i18n }}

- {{ sends.length }} + {{ sends.length }} - -
-
- - - {{ send.name }} -
-
+ + + {{ send.name }} + + {{ "deletionDate" | i18n }}: {{ send.deletionDate | date: "mediumDate" }} + + + -
-
-
+ appA11yTitle="{{ 'copySendTitle' | i18n }}: {{ send.name | i18n }}" + > + + + + + + + +
diff --git a/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts index 5bee85d385c..8a3078489fc 100644 --- a/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts +++ b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts @@ -1,22 +1,28 @@ import { CommonModule } from "@angular/common"; import { Component, Input } from "@angular/core"; import { RouterLink } from "@angular/router"; +import { firstValueFrom } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; +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 { BadgeModule, ButtonModule, + DialogService, IconButtonModule, ItemModule, SectionComponent, SectionHeaderComponent, + ToastService, TypographyModule, } from "@bitwarden/components"; -import { ContainerComponent } from "../../../../../components/src/container/container.component"; - @Component({ imports: [ CommonModule, @@ -29,7 +35,6 @@ import { ContainerComponent } from "../../../../../components/src/container/cont JslibModule, SectionHeaderComponent, RouterLink, - ContainerComponent, ], selector: "app-send-list-items-container", templateUrl: "send-list-items-container.component.html", @@ -42,4 +47,47 @@ export class SendListItemsContainerComponent { */ @Input() sends: SendView[] = []; + + constructor( + protected dialogService: DialogService, + protected environmentService: EnvironmentService, + protected i18nService: I18nService, + protected logService: LogService, + protected platformUtilsService: PlatformUtilsService, + protected sendApiService: SendApiService, + protected toastService: ToastService, + ) {} + + async deleteSend(s: SendView): Promise { + const confirmed = await this.dialogService.openSimpleDialog({ + title: { key: "deleteSend" }, + content: { key: "deleteSendConfirmation" }, + type: "warning", + }); + + if (!confirmed) { + return false; + } + + try { + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("deletedSend"), + }); + } catch (e) { + this.logService.error(e); + } + } + + async copy(s: SendView) { + const env = await firstValueFrom(this.environmentService.environment$); + const link = env.getSendUrl() + s.accessId + "/" + s.urlB64Key; + this.platformUtilsService.copyToClipboard(link); + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("valueCopied", this.i18nService.t("sendLink")), + }); + } }