From 0b62afb0f8acdfdd166d1dbebe955865abed90e8 Mon Sep 17 00:00:00 2001 From: Marc Sportiello Date: Fri, 17 Jul 2026 14:48:15 +0200 Subject: [PATCH] fix(email-composer): hide template buttons when templates are disabled --- components/email/email-composer.tsx | 45 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/components/email/email-composer.tsx b/components/email/email-composer.tsx index 44a67ca5..f0249c76 100644 --- a/components/email/email-composer.tsx +++ b/components/email/email-composer.tsx @@ -55,6 +55,7 @@ import { RichTextEditor } from "@/components/email/rich-text-editor"; import type { Editor } from "@tiptap/react"; import { htmlToPlainText as htmlToPlainTextShared } from "@/lib/html-to-text"; import { fileStorage } from "@/lib/plugin-storage"; +import { usePolicyStore } from "@/stores/policy-store"; /** * Derives the text/plain alternative from the composer's HTML body, preserving @@ -290,6 +291,9 @@ export function EmailComposer({ : []; const primaryIdentity = activeIdentities[0] ?? null; + const { isFeatureEnabled } = usePolicyStore(); + const templatesEnabled = isFeatureEnabled('templatesEnabled'); + // The signature identity used when embedding the signature into the initial // body for "above quote" mode. Mirrors the signatureIdentity derivation // below, but uses initialData (or primary) since selectedIdentityId state @@ -1132,6 +1136,7 @@ export function EmailComposer({ const tag = target?.tagName?.toLowerCase(); if (tag === 'input' || tag === 'textarea' || tag === 'select') return; if (target?.getAttribute('contenteditable') === 'true') return; + if (!templatesEnabled) return; if (e.key === 't' && !e.ctrlKey && !e.metaKey && !e.altKey) { e.preventDefault(); setShowTemplatePicker(true); @@ -1139,7 +1144,7 @@ export function EmailComposer({ }; window.addEventListener('keydown', handleTemplateKey); return () => window.removeEventListener('keydown', handleTemplateKey); - }, []); + }, [templatesEnabled]); const addFiles = useCallback(async (files: File[]) => { if (!client || files.length === 0) return; @@ -2562,24 +2567,26 @@ export function EmailComposer({ > - - + {templatesEnabled && <> + + + } {/* Sign/encrypt controls are contributed by crypto plugins via the composer-toolbar slot (rendered below). */}