Add warning dialog when clearing generator history (#11711)

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith 2024-10-25 17:44:12 +02:00 committed by GitHub
parent fa537638bf
commit ab98bef28f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -1797,6 +1797,12 @@
"generatorHistory": { "generatorHistory": {
"message": "Generator history" "message": "Generator history"
}, },
"clearGeneratorHistoryTitle": {
"message": "Clear generator history"
},
"cleargGeneratorHistoryDescription": {
"message": "If you continue, all entries will be permanently deleted from generator's history. Are you sure you want to continue?"
},
"back": { "back": {
"message": "Back" "message": "Back"
}, },

View File

@ -6,7 +6,7 @@ import { BehaviorSubject, distinctUntilChanged, firstValueFrom, map, switchMap }
import { JslibModule } from "@bitwarden/angular/jslib.module"; import { JslibModule } from "@bitwarden/angular/jslib.module";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { ButtonModule, ContainerComponent } from "@bitwarden/components"; import { ButtonModule, ContainerComponent, DialogService } from "@bitwarden/components";
import { import {
CredentialGeneratorHistoryComponent as CredentialGeneratorHistoryToolsComponent, CredentialGeneratorHistoryComponent as CredentialGeneratorHistoryToolsComponent,
EmptyCredentialHistoryComponent, EmptyCredentialHistoryComponent,
@ -42,6 +42,7 @@ export class CredentialGeneratorHistoryComponent {
constructor( constructor(
private accountService: AccountService, private accountService: AccountService,
private history: GeneratorHistoryService, private history: GeneratorHistoryService,
private dialogService: DialogService,
) { ) {
this.accountService.activeAccount$ this.accountService.activeAccount$
.pipe( .pipe(
@ -61,6 +62,16 @@ export class CredentialGeneratorHistoryComponent {
} }
clear = async () => { clear = async () => {
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "clearGeneratorHistoryTitle" },
content: { key: "cleargGeneratorHistoryDescription" },
type: "warning",
acceptButtonText: { key: "clearHistory" },
cancelButtonText: { key: "cancel" },
});
if (confirmed) {
await this.history.clear(await firstValueFrom(this.userId$)); await this.history.clear(await firstValueFrom(this.userId$));
}
}; };
} }