1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-12 10:14:10 +01:00

add delete send button to footer

This commit is contained in:
jaasen-livefront 2024-09-20 16:38:43 -07:00
parent 9a89ef9b4f
commit 13ba396e53
No known key found for this signature in database
2 changed files with 44 additions and 1 deletions

View File

@ -13,5 +13,14 @@
<button bitButton type="submit" form="sendForm" buttonType="primary" #submitBtn>
{{ "save" | i18n }}
</button>
<button
*ngIf="config?.mode !== 'add'"
type="button"
buttonType="danger"
class="tw-border-0 tw-ml-auto bwi-lg"
bitIconButton="bwi-trash"
(click)="deleteSend()"
appA11yTitle="{{ 'delete' | i18n }}"
></button>
</popup-footer>
</popup-page>

View File

@ -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<Record<keyof QueryParams, string>>;
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,28 @@ export class SendAddEditComponent {
this.location.back();
}
async deleteSend() {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "deleteSend" },
content: { key: "deleteSendConfirmation" },
type: "warning",
});
if (!confirmed) {
return false;
}
await this.sendApiService.delete(this.config.originalSend?.id);
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.
*/