From b33b82f6befbbab5509a850fbaee515137787a2f Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Wed, 17 Jul 2024 17:36:25 -0700 Subject: [PATCH 1/3] send list items container --- .../tools/popup/send/send-v2.component.html | 6 +-- .../src/tools/popup/send/send-v2.component.ts | 34 +++++++++----- .../services/config/default-config.service.ts | 1 + .../common/src/vault/models/view/send.view.ts | 0 libs/tools/send/send-ui/src/index.ts | 1 + .../send-list-items-container.component.html | 44 ++++++++++++++++++ .../send-list-items-container.component.ts | 45 +++++++++++++++++++ 7 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 libs/common/src/vault/models/view/send.view.ts create mode 100644 libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html create mode 100644 libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts diff --git a/apps/browser/src/tools/popup/send/send-v2.component.html b/apps/browser/src/tools/popup/send/send-v2.component.html index 3499f8c32ef..52f7c3ed8ff 100644 --- a/apps/browser/src/tools/popup/send/send-v2.component.html +++ b/apps/browser/src/tools/popup/send/send-v2.component.html @@ -8,14 +8,12 @@ -
+
{{ "sendsNoItemsTitle" | i18n }} {{ "sendsNoItemsMessage" | i18n }}
+ 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 fba14b762b1..1708d30f87f 100644 --- a/apps/browser/src/tools/popup/send/send-v2.component.ts +++ b/apps/browser/src/tools/popup/send/send-v2.component.ts @@ -1,21 +1,24 @@ 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 } from "@bitwarden/send-ui"; +import { + NoSendsIcon, + NewSendDropdownComponent, + SendListItemsContainerComponent, +} 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"; -enum SendsListState { - Empty, -} - @Component({ templateUrl: "send-v2.component.html", standalone: true, @@ -30,23 +33,30 @@ enum SendsListState { ButtonModule, RouterLink, NewSendDropdownComponent, + SendListItemsContainerComponent, ], }) export class SendV2Component implements OnInit, OnDestroy { sendType = SendType; - /** Visual state of the Sends list */ - protected sendsListState: SendsListState | null = null; + protected sends: SendView[] = []; + + private destroy$ = new Subject(); 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; + }), + takeUntil(this.destroy$), + ) + .subscribe(); } - ngOnInit(): void {} - ngOnDestroy(): void {} } diff --git a/libs/common/src/platform/services/config/default-config.service.ts b/libs/common/src/platform/services/config/default-config.service.ts index 16878a72832..7bdf79f409b 100644 --- a/libs/common/src/platform/services/config/default-config.service.ts +++ b/libs/common/src/platform/services/config/default-config.service.ts @@ -115,6 +115,7 @@ export class DefaultConfigService implements ConfigService { return DefaultFeatureFlagValue[key]; } + serverConfig.featureStates[FeatureFlag.ExtensionRefresh] = true; return serverConfig.featureStates[key] as FeatureFlagValueType; }), ); diff --git a/libs/common/src/vault/models/view/send.view.ts b/libs/common/src/vault/models/view/send.view.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libs/tools/send/send-ui/src/index.ts b/libs/tools/send/send-ui/src/index.ts index fc7c87449dd..2bb0a3e942d 100644 --- a/libs/tools/send/send-ui/src/index.ts +++ b/libs/tools/send/send-ui/src/index.ts @@ -1,2 +1,3 @@ export * from "./icons"; export { NewSendDropdownComponent } from "./new-send-dropdown/new-send-dropdown.component"; +export { SendListItemsContainerComponent } from "./send-list-items-container/send-list-items-container.component"; 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 new file mode 100644 index 00000000000..f6e13e6c122 --- /dev/null +++ b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.html @@ -0,0 +1,44 @@ + + +

+ {{ "allSends" | i18n }} +

+ {{ sends.length }} +
+ + + +
+
+ + + {{ send.name }} +
+
+ +
+
+
+
+
+
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 new file mode 100644 index 00000000000..5bee85d385c --- /dev/null +++ b/libs/tools/send/send-ui/src/send-list-items-container/send-list-items-container.component.ts @@ -0,0 +1,45 @@ +import { CommonModule } from "@angular/common"; +import { Component, Input } from "@angular/core"; +import { RouterLink } from "@angular/router"; + +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 { + BadgeModule, + ButtonModule, + IconButtonModule, + ItemModule, + SectionComponent, + SectionHeaderComponent, + TypographyModule, +} from "@bitwarden/components"; + +import { ContainerComponent } from "../../../../../components/src/container/container.component"; + +@Component({ + imports: [ + CommonModule, + ItemModule, + ButtonModule, + BadgeModule, + IconButtonModule, + SectionComponent, + TypographyModule, + JslibModule, + SectionHeaderComponent, + RouterLink, + ContainerComponent, + ], + selector: "app-send-list-items-container", + templateUrl: "send-list-items-container.component.html", + standalone: true, +}) +export class SendListItemsContainerComponent { + sendType = SendType; + /** + * The list of sends to display. + */ + @Input() + sends: SendView[] = []; +} From a18d509409731039708c02ec11cf524c5c60a541 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Thu, 18 Jul 2024 16:54:22 -0700 Subject: [PATCH 2/3] 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")), + }); + } } From 0d726fd8f050ed515b8ba7e09f2225b4b26a3a44 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Fri, 19 Jul 2024 10:24:08 -0700 Subject: [PATCH 3/3] finalize send list container --- apps/browser/src/_locales/en/messages.json | 3 +++ apps/desktop/src/locales/en/messages.json | 24 ------------------- apps/web/src/locales/en/messages.json | 3 +++ .../send-list-items-container.component.html | 8 ++++--- .../send-list-items-container.component.ts | 4 +++- 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 5b306fdb2a7..63d5f9eb9cb 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -1996,6 +1996,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." diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index abbdfef84a0..31de4095827 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -1937,30 +1937,6 @@ "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/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 73396c39c16..560803c87e0 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -4350,6 +4350,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." 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 feb87eda39e..6a4c6a308ed 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 @@ -9,7 +9,7 @@ @@ -40,7 +41,8 @@ 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 8a3078489fc..ef7232e97a0 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 @@ -69,6 +69,8 @@ export class SendListItemsContainerComponent { return false; } + await this.sendApiService.delete(s.id); + try { this.toastService.showToast({ variant: "success", @@ -80,7 +82,7 @@ export class SendListItemsContainerComponent { } } - async copy(s: SendView) { + async copySendLink(s: SendView) { const env = await firstValueFrom(this.environmentService.environment$); const link = env.getSendUrl() + s.accessId + "/" + s.urlB64Key; this.platformUtilsService.copyToClipboard(link);