1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-06-20 09:35:22 +02:00

PM-171 remove confirmation alerts for restoring an item (#5799)

* remove confirmation alerts for restoring an item from trash and remove bulk-restore-dialog from vault individual and org
This commit is contained in:
Jason Ng 2023-08-15 15:15:13 -04:00 committed by GitHub
parent 15f29c5fb1
commit 8593966a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 8 additions and 185 deletions

View File

@ -1446,9 +1446,6 @@
"restoreItem": {
"message": "Restore item"
},
"restoreItemConfirmation": {
"message": "Are you sure you want to restore this item?"
},
"restoredItem": {
"message": "Item restored"
},

View File

@ -1512,12 +1512,6 @@
"permanentlyDeletedItem": {
"message": "Item permanently deleted"
},
"restoreItem": {
"message": "Restore item"
},
"restoreItemConfirmation": {
"message": "Are you sure you want to restore this item?"
},
"restoredItem": {
"message": "Item restored"
},

View File

@ -4,22 +4,11 @@ import { SharedModule } from "../../../shared";
import { BulkDeleteDialogComponent } from "./bulk-delete-dialog/bulk-delete-dialog.component";
import { BulkMoveDialogComponent } from "./bulk-move-dialog/bulk-move-dialog.component";
import { BulkRestoreDialogComponent } from "./bulk-restore-dialog/bulk-restore-dialog.component";
import { BulkShareDialogComponent } from "./bulk-share-dialog/bulk-share-dialog.component";
@NgModule({
imports: [SharedModule],
declarations: [
BulkDeleteDialogComponent,
BulkMoveDialogComponent,
BulkRestoreDialogComponent,
BulkShareDialogComponent,
],
exports: [
BulkDeleteDialogComponent,
BulkMoveDialogComponent,
BulkRestoreDialogComponent,
BulkShareDialogComponent,
],
declarations: [BulkDeleteDialogComponent, BulkMoveDialogComponent, BulkShareDialogComponent],
exports: [BulkDeleteDialogComponent, BulkMoveDialogComponent, BulkShareDialogComponent],
})
export class BulkDialogsModule {}

View File

@ -1,14 +0,0 @@
<bit-simple-dialog>
<span bitDialogTitle>
{{ "restoreSelected" | i18n }}
</span>
<span bitDialogContent>
{{ "restoreSelectedItemsDesc" | i18n : cipherIds.length }}
</span>
<ng-container bitDialogFooter>
<button bitButton type="submit" buttonType="primary" [bitAction]="submit">
{{ "restore" | i18n }}
</button>
<button bitButton type="button" (click)="cancel()">{{ "cancel" | i18n }}</button>
</ng-container>
</bit-simple-dialog>

View File

@ -1,67 +0,0 @@
import { DialogConfig, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog";
import { Component, Inject } from "@angular/core";
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
export interface BulkRestoreDialogParams {
cipherIds: string[];
organization?: Organization;
}
export enum BulkRestoreDialogResult {
Restored = "restored",
Canceled = "canceled",
}
/**
* Strongly typed helper to open a BulkRestoreDialog
* @param dialogService Instance of the dialog service that will be used to open the dialog
* @param config Configuration for the dialog
*/
export const openBulkRestoreDialog = (
dialogService: DialogServiceAbstraction,
config: DialogConfig<BulkRestoreDialogParams>
) => {
return dialogService.open<BulkRestoreDialogResult, BulkRestoreDialogParams>(
BulkRestoreDialogComponent,
config
);
};
@Component({
templateUrl: "bulk-restore-dialog.component.html",
})
export class BulkRestoreDialogComponent {
cipherIds: string[];
organization?: Organization;
constructor(
@Inject(DIALOG_DATA) params: BulkRestoreDialogParams,
private dialogRef: DialogRef<BulkRestoreDialogResult>,
private cipherService: CipherService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService
) {
this.cipherIds = params.cipherIds ?? [];
this.organization = params.organization;
}
submit = async () => {
const asAdmin = this.organization?.canEditAnyCollection;
await this.cipherService.restoreManyWithServer(this.cipherIds, this.organization?.id, asAdmin);
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItems"));
this.close(BulkRestoreDialogResult.Restored);
};
protected cancel() {
this.close(BulkRestoreDialogResult.Canceled);
}
private close(result: BulkRestoreDialogResult) {
this.dialogRef.close(result);
}
}

View File

@ -75,10 +75,6 @@ import {
BulkMoveDialogResult,
openBulkMoveDialog,
} from "./bulk-action-dialogs/bulk-move-dialog/bulk-move-dialog.component";
import {
BulkRestoreDialogResult,
openBulkRestoreDialog,
} from "./bulk-action-dialogs/bulk-restore-dialog/bulk-restore-dialog.component";
import {
BulkShareDialogResult,
openBulkShareDialog,
@ -683,16 +679,6 @@ export class VaultComponent implements OnInit, OnDestroy {
return;
}
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "restoreItemConfirmation" },
content: { key: "restoreItem" },
type: SimpleDialogType.WARNING,
});
if (!confirmed) {
return false;
}
try {
await this.cipherService.restoreWithServer(c.id);
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));
@ -717,14 +703,9 @@ export class VaultComponent implements OnInit, OnDestroy {
return;
}
const dialog = openBulkRestoreDialog(this.dialogService, {
data: { cipherIds: selectedCipherIds },
});
const result = await lastValueFrom(dialog.closed);
if (result === BulkRestoreDialogResult.Restored) {
this.refresh();
}
await this.cipherService.restoreManyWithServer(selectedCipherIds);
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItems"));
this.refresh();
}
async deleteCipher(c: CipherView): Promise<boolean> {

View File

@ -71,10 +71,6 @@ import {
BulkDeleteDialogResult,
openBulkDeleteDialog,
} from "../individual-vault/bulk-action-dialogs/bulk-delete-dialog/bulk-delete-dialog.component";
import {
BulkRestoreDialogResult,
openBulkRestoreDialog,
} from "../individual-vault/bulk-action-dialogs/bulk-restore-dialog/bulk-restore-dialog.component";
import { RoutedVaultFilterBridgeService } from "../individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../individual-vault/vault-filter/services/routed-vault-filter.service";
import { createFilterFunction } from "../individual-vault/vault-filter/shared/models/filter-function";
@ -669,16 +665,6 @@ export class VaultComponent implements OnInit, OnDestroy {
return;
}
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "restoreItem" },
content: { key: "restoreItemConfirmation" },
type: SimpleDialogType.WARNING,
});
if (!confirmed) {
return false;
}
try {
const asAdmin = this.organization?.canEditAnyCollection;
await this.cipherService.restoreWithServer(c.id, asAdmin);
@ -704,14 +690,9 @@ export class VaultComponent implements OnInit, OnDestroy {
return;
}
const dialog = openBulkRestoreDialog(this.dialogService, {
data: { cipherIds: selectedCipherIds, organization: this.organization },
});
const result = await lastValueFrom(dialog.closed);
if (result === BulkRestoreDialogResult.Restored) {
this.refresh();
}
await this.cipherService.restoreManyWithServer(selectedCipherIds);
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItems"));
this.refresh();
}
async deleteCipher(c: CipherView): Promise<boolean> {

View File

@ -3842,30 +3842,12 @@
"restoreSelected": {
"message": "Restore selected"
},
"restoreItem": {
"message": "Restore item"
},
"restoredItem": {
"message": "Item restored"
},
"restoredItems": {
"message": "Items restored"
},
"restoreItemConfirmation": {
"message": "Are you sure you want to restore this item?"
},
"restoreItems": {
"message": "Restore items"
},
"restoreSelectedItemsDesc": {
"message": "You have selected $COUNT$ item(s) to restore. Are you sure you want to restore these items?",
"placeholders": {
"count": {
"content": "$1",
"example": "150"
}
}
},
"restoredItemId": {
"message": "Item $ID$ restored",
"placeholders": {

View File

@ -433,16 +433,6 @@ export class AddEditComponent implements OnInit, OnDestroy {
return false;
}
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "restoreItem" },
content: { key: "restoreItemConfirmation" },
type: SimpleDialogType.WARNING,
});
if (!confirmed) {
return false;
}
try {
this.restorePromise = this.restoreCipher();
await this.restorePromise;

View File

@ -209,16 +209,6 @@ export class ViewComponent implements OnDestroy, OnInit {
return false;
}
const confirmed = await this.dialogService.openSimpleDialog({
title: { key: "restoreItem" },
content: { key: "restoreItemConfirmation" },
type: SimpleDialogType.WARNING,
});
if (!confirmed) {
return false;
}
try {
await this.restoreCipher();
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));