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 c7d0ac0f1d6..292851044aa 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,6 +204,14 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { ), ); + protected async showRestore() { + return ( + this.filter?.type === "trash" && + this.cipher?.isDeleted && + (await firstValueFrom(this.canDeleteCipher$)) + ); + } + protected get loadingForm() { return this.loadForm && !this.formReady; } @@ -229,40 +237,6 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { return this.cipher != undefined && (this.params.mode === "view" || this.loadingForm); } - protected get showRestore() { - return this.filter?.type === "trash" && this.canRestoreCipher && !!this.params.restore; - } - - /** - * Whether the user can restore a given cipher from the trash - * Rules for when a cipher can be restored: - * - the cipher is deleted - * - AND one or more of the following: - * - the cipher is a personal item (doesn't belong to an organization) - * - the cipher belongs to a collection that the user can manage - * - the user is an admin of the organization to which the cipher belongs - */ - protected get canRestoreCipher() { - if (!this.cipher || !this.cipher.isDeleted) { - return false; - } - - if (this.cipher.organizationId == null) { - return true; - } - - const collection = this.collections.find((c) => this.cipher.collectionIds.includes(c.id)); - if (collection?.manage) { - return true; - } - - if (this.organization?.isAdmin) { - return true; - } - - return false; - } - /** * Flag to initialize/attach the form component. */