From 6d9223fac7b339f6fce5312650cccc70f33047ca Mon Sep 17 00:00:00 2001 From: Jordan Aasen <166539328+jaasen-livefront@users.noreply.github.com> Date: Tue, 24 Sep 2024 00:26:25 -0700 Subject: [PATCH] [PM-12505] - add delete send button to footer (#11187) * add delete send button to footer * add basic error handling * update copy. user bitAction * use arrow function. remove border class --- apps/browser/src/_locales/en/messages.json | 4 ++ .../add-edit/send-add-edit.component.html | 9 ++++ .../add-edit/send-add-edit.component.ts | 45 ++++++++++++++++++- .../send-list-items-container.component.ts | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 900c3b37caa7..8c08caec3530 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -2374,6 +2374,10 @@ "message": "Are you sure you want to delete this Send?", "description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated." }, + "deleteSendPermanentConfirmation": { + "message": "Are you sure you want to permanently delete this Send?", + "description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated." + }, "editSend": { "message": "Edit Send", "description": "'Send' is a noun and the name of a feature called 'Bitwarden Send'. It should not be translated." diff --git a/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.html b/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.html index 3e9a8d7c50da..7f723cc73643 100644 --- a/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.html +++ b/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.html @@ -13,5 +13,14 @@ + diff --git a/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.ts b/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.ts index 49526bb032b7..91311ab7e7a1 100644 --- a/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.ts +++ b/apps/browser/src/tools/popup/send-v2/add-edit/send-add-edit.component.ts @@ -8,8 +8,16 @@ import { map, switchMap } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { SendType } from "@bitwarden/common/tools/send/enums/send-type"; +import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction"; import { SendId } from "@bitwarden/common/types/guid"; -import { AsyncActionsModule, ButtonModule, SearchModule } from "@bitwarden/components"; +import { + AsyncActionsModule, + ButtonModule, + DialogService, + IconButtonModule, + SearchModule, + ToastService, +} from "@bitwarden/components"; import { DefaultSendFormConfigService, SendFormConfig, @@ -58,6 +66,7 @@ export type AddEditQueryParams = Partial>; JslibModule, FormsModule, ButtonModule, + IconButtonModule, PopupPageComponent, PopupHeaderComponent, PopupFooterComponent, @@ -81,6 +90,9 @@ export class SendAddEditComponent { private location: Location, private i18nService: I18nService, private addEditFormConfigService: SendFormConfigService, + private sendApiService: SendApiService, + private toastService: ToastService, + private dialogService: DialogService, ) { this.subscribeToParams(); } @@ -92,6 +104,37 @@ export class SendAddEditComponent { this.location.back(); } + deleteSend = async () => { + const confirmed = await this.dialogService.openSimpleDialog({ + title: { key: "deleteSend" }, + content: { key: "deleteSendPermanentConfirmation" }, + type: "warning", + }); + + if (!confirmed) { + return; + } + + try { + await this.sendApiService.delete(this.config.originalSend?.id); + } catch (e) { + this.toastService.showToast({ + variant: "error", + title: null, + message: e.message, + }); + return; + } + + this.location.back(); + + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("deletedSend"), + }); + }; + /** * Subscribes to the route query parameters and builds the configuration based on the parameters. */ 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 2dd8078fd7ae..a0f10c2cea98 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 @@ -64,7 +64,7 @@ export class SendListItemsContainerComponent { async deleteSend(s: SendView): Promise { const confirmed = await this.dialogService.openSimpleDialog({ title: { key: "deleteSend" }, - content: { key: "deleteSendConfirmation" }, + content: { key: "deleteSendPermanentConfirmation" }, type: "warning", });