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:
parent
15f29c5fb1
commit
8593966a71
|
@ -1446,9 +1446,6 @@
|
||||||
"restoreItem": {
|
"restoreItem": {
|
||||||
"message": "Restore item"
|
"message": "Restore item"
|
||||||
},
|
},
|
||||||
"restoreItemConfirmation": {
|
|
||||||
"message": "Are you sure you want to restore this item?"
|
|
||||||
},
|
|
||||||
"restoredItem": {
|
"restoredItem": {
|
||||||
"message": "Item restored"
|
"message": "Item restored"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1512,12 +1512,6 @@
|
||||||
"permanentlyDeletedItem": {
|
"permanentlyDeletedItem": {
|
||||||
"message": "Item permanently deleted"
|
"message": "Item permanently deleted"
|
||||||
},
|
},
|
||||||
"restoreItem": {
|
|
||||||
"message": "Restore item"
|
|
||||||
},
|
|
||||||
"restoreItemConfirmation": {
|
|
||||||
"message": "Are you sure you want to restore this item?"
|
|
||||||
},
|
|
||||||
"restoredItem": {
|
"restoredItem": {
|
||||||
"message": "Item restored"
|
"message": "Item restored"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,22 +4,11 @@ import { SharedModule } from "../../../shared";
|
||||||
|
|
||||||
import { BulkDeleteDialogComponent } from "./bulk-delete-dialog/bulk-delete-dialog.component";
|
import { BulkDeleteDialogComponent } from "./bulk-delete-dialog/bulk-delete-dialog.component";
|
||||||
import { BulkMoveDialogComponent } from "./bulk-move-dialog/bulk-move-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";
|
import { BulkShareDialogComponent } from "./bulk-share-dialog/bulk-share-dialog.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [SharedModule],
|
imports: [SharedModule],
|
||||||
declarations: [
|
declarations: [BulkDeleteDialogComponent, BulkMoveDialogComponent, BulkShareDialogComponent],
|
||||||
BulkDeleteDialogComponent,
|
exports: [BulkDeleteDialogComponent, BulkMoveDialogComponent, BulkShareDialogComponent],
|
||||||
BulkMoveDialogComponent,
|
|
||||||
BulkRestoreDialogComponent,
|
|
||||||
BulkShareDialogComponent,
|
|
||||||
],
|
|
||||||
exports: [
|
|
||||||
BulkDeleteDialogComponent,
|
|
||||||
BulkMoveDialogComponent,
|
|
||||||
BulkRestoreDialogComponent,
|
|
||||||
BulkShareDialogComponent,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class BulkDialogsModule {}
|
export class BulkDialogsModule {}
|
||||||
|
|
|
@ -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>
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -75,10 +75,6 @@ import {
|
||||||
BulkMoveDialogResult,
|
BulkMoveDialogResult,
|
||||||
openBulkMoveDialog,
|
openBulkMoveDialog,
|
||||||
} from "./bulk-action-dialogs/bulk-move-dialog/bulk-move-dialog.component";
|
} 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 {
|
import {
|
||||||
BulkShareDialogResult,
|
BulkShareDialogResult,
|
||||||
openBulkShareDialog,
|
openBulkShareDialog,
|
||||||
|
@ -683,16 +679,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = await this.dialogService.openSimpleDialog({
|
|
||||||
title: { key: "restoreItemConfirmation" },
|
|
||||||
content: { key: "restoreItem" },
|
|
||||||
type: SimpleDialogType.WARNING,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.cipherService.restoreWithServer(c.id);
|
await this.cipherService.restoreWithServer(c.id);
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));
|
||||||
|
@ -717,14 +703,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dialog = openBulkRestoreDialog(this.dialogService, {
|
await this.cipherService.restoreManyWithServer(selectedCipherIds);
|
||||||
data: { cipherIds: selectedCipherIds },
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItems"));
|
||||||
});
|
this.refresh();
|
||||||
|
|
||||||
const result = await lastValueFrom(dialog.closed);
|
|
||||||
if (result === BulkRestoreDialogResult.Restored) {
|
|
||||||
this.refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteCipher(c: CipherView): Promise<boolean> {
|
async deleteCipher(c: CipherView): Promise<boolean> {
|
||||||
|
|
|
@ -71,10 +71,6 @@ import {
|
||||||
BulkDeleteDialogResult,
|
BulkDeleteDialogResult,
|
||||||
openBulkDeleteDialog,
|
openBulkDeleteDialog,
|
||||||
} from "../individual-vault/bulk-action-dialogs/bulk-delete-dialog/bulk-delete-dialog.component";
|
} 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 { 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 { RoutedVaultFilterService } from "../individual-vault/vault-filter/services/routed-vault-filter.service";
|
||||||
import { createFilterFunction } from "../individual-vault/vault-filter/shared/models/filter-function";
|
import { createFilterFunction } from "../individual-vault/vault-filter/shared/models/filter-function";
|
||||||
|
@ -669,16 +665,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = await this.dialogService.openSimpleDialog({
|
|
||||||
title: { key: "restoreItem" },
|
|
||||||
content: { key: "restoreItemConfirmation" },
|
|
||||||
type: SimpleDialogType.WARNING,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const asAdmin = this.organization?.canEditAnyCollection;
|
const asAdmin = this.organization?.canEditAnyCollection;
|
||||||
await this.cipherService.restoreWithServer(c.id, asAdmin);
|
await this.cipherService.restoreWithServer(c.id, asAdmin);
|
||||||
|
@ -704,14 +690,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dialog = openBulkRestoreDialog(this.dialogService, {
|
await this.cipherService.restoreManyWithServer(selectedCipherIds);
|
||||||
data: { cipherIds: selectedCipherIds, organization: this.organization },
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItems"));
|
||||||
});
|
this.refresh();
|
||||||
|
|
||||||
const result = await lastValueFrom(dialog.closed);
|
|
||||||
if (result === BulkRestoreDialogResult.Restored) {
|
|
||||||
this.refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteCipher(c: CipherView): Promise<boolean> {
|
async deleteCipher(c: CipherView): Promise<boolean> {
|
||||||
|
|
|
@ -3842,30 +3842,12 @@
|
||||||
"restoreSelected": {
|
"restoreSelected": {
|
||||||
"message": "Restore selected"
|
"message": "Restore selected"
|
||||||
},
|
},
|
||||||
"restoreItem": {
|
|
||||||
"message": "Restore item"
|
|
||||||
},
|
|
||||||
"restoredItem": {
|
"restoredItem": {
|
||||||
"message": "Item restored"
|
"message": "Item restored"
|
||||||
},
|
},
|
||||||
"restoredItems": {
|
"restoredItems": {
|
||||||
"message": "Items restored"
|
"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": {
|
"restoredItemId": {
|
||||||
"message": "Item $ID$ restored",
|
"message": "Item $ID$ restored",
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
|
|
|
@ -433,16 +433,6 @@ export class AddEditComponent implements OnInit, OnDestroy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = await this.dialogService.openSimpleDialog({
|
|
||||||
title: { key: "restoreItem" },
|
|
||||||
content: { key: "restoreItemConfirmation" },
|
|
||||||
type: SimpleDialogType.WARNING,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.restorePromise = this.restoreCipher();
|
this.restorePromise = this.restoreCipher();
|
||||||
await this.restorePromise;
|
await this.restorePromise;
|
||||||
|
|
|
@ -209,16 +209,6 @@ export class ViewComponent implements OnDestroy, OnInit {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = await this.dialogService.openSimpleDialog({
|
|
||||||
title: { key: "restoreItem" },
|
|
||||||
content: { key: "restoreItemConfirmation" },
|
|
||||||
type: SimpleDialogType.WARNING,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.restoreCipher();
|
await this.restoreCipher();
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("restoredItem"));
|
||||||
|
|
Loading…
Reference in New Issue