From 8ec551780963781788dc9cd0a980ccaec0c2ced4 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:30:39 -0500 Subject: [PATCH] Add premium dialog when trying to navigate to attachments without premium permissions (#11387) --- .../vault-item-dialog/vault-item-dialog.component.ts | 8 ++++++++ .../web/src/app/vault/individual-vault/vault.component.ts | 6 ++++++ 2 files changed, 14 insertions(+) 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 4969ea2b16..d3d0703605 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 @@ -207,6 +207,7 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { private accountService: AccountService, private router: Router, private billingAccountProfileStateService: BillingAccountProfileStateService, + private premiumUpgradeService: PremiumUpgradePromptService, ) { this.updateTitle(); } @@ -297,6 +298,13 @@ export class VaultItemDialogComponent implements OnInit, OnDestroy { }; openAttachmentsDialog = async () => { + const canAccessAttachments = await firstValueFrom(this.canAccessAttachments$); + + if (!canAccessAttachments) { + await this.premiumUpgradeService.promptForPremium(); + return; + } + const dialogRef = this.dialogService.open( AttachmentsV2Component, { diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 734ab5acf1..aac686f21a 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -611,6 +611,12 @@ export class VaultComponent implements OnInit, OnDestroy { const result = await lastValueFrom(this.vaultItemDialogRef.closed); this.vaultItemDialogRef = undefined; + // When the dialog is closed for a premium upgrade, return early as the user + // should be navigated to the subscription settings elsewhere + if (result === VaultItemDialogResult.PremiumUpgrade) { + return; + } + // If the dialog was closed by deleting the cipher, refresh the vault. if (result === VaultItemDialogResult.Deleted || result === VaultItemDialogResult.Saved) { this.refresh();