From 6e4d94085c4d21fe6a13d88c414660d3750040a4 Mon Sep 17 00:00:00 2001 From: jaasen-livefront Date: Thu, 16 Jan 2025 13:06:13 -0800 Subject: [PATCH] put canRestore in class property --- .../vault-item-dialog/vault-item-dialog.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts b/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts index 292851044aa..d6e72cd65ba 100644 --- a/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts +++ b/apps/web/src/app/vault/components/vault-item-dialog/vault-item-dialog.component.ts @@ -204,7 +204,11 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { ), ); - protected async showRestore() { + /** + * Determines if the user may restore the item. + * A user may restore items if they have delete permissions and the item is in the trash. + */ + protected async canUserRestore() { return ( this.filter?.type === "trash" && this.cipher?.isDeleted && @@ -212,6 +216,8 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { ); } + protected showRestore: boolean; + protected get loadingForm() { return this.loadForm && !this.formReady; } @@ -276,6 +282,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { async ngOnInit() { this.cipher = await this.getDecryptedCipherView(this.formConfig); + this.showRestore = await this.canUserRestore(); if (this.cipher) { if (this.cipher.decryptionFailure) {