From 07cda85d396d8c5dd3c66b6c539a69dbffaad991 Mon Sep 17 00:00:00 2001 From: JaredScar Date: Mon, 26 Jan 2026 17:23:55 -0500 Subject: [PATCH] Implement dynamic cipher creation permissions in vault header and new cipher menu components --- .../vault-header/vault-header.component.html | 2 +- .../vault-header/vault-header.component.ts | 7 +++++++ .../new-cipher-menu.component.ts | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/web/src/app/vault/individual-vault/vault-header/vault-header.component.html b/apps/web/src/app/vault/individual-vault/vault-header/vault-header.component.html index af4eb182eec..d2f5cc38013 100644 --- a/apps/web/src/app/vault/individual-vault/vault-header/vault-header.component.html +++ b/apps/web/src/app/vault/individual-vault/vault-header/vault-header.component.html @@ -76,7 +76,7 @@
{ + cipherMenuItems$ = combineLatest([ + this.restrictedItemTypesService.restricted$, + toObservable(this.canCreateCipher), + toObservable(this.canCreateSshKey), + ]).pipe( + map(([restrictedTypes, canCreateCipher, canCreateSshKey]) => { + // If user cannot create ciphers at all, return empty array + if (!canCreateCipher) { + return []; + } return CIPHER_MENU_ITEMS.filter((item) => { - if (!this.canCreateSshKey() && item.type === CipherType.SshKey) { + if (!canCreateSshKey && item.type === CipherType.SshKey) { return false; } return !restrictedTypes.some((restrictedType) => restrictedType.cipherType === item.type);