From 325699d036bdd22d4eaa4fe31023b5cb52fb5899 Mon Sep 17 00:00:00 2001 From: sokol Date: Wed, 18 Feb 2026 18:01:38 +0300 Subject: [PATCH] ui: move validation warning to tab header as badge --- src/componets/content/ConfigTemplate.tsx | 16 +--------------- src/componets/content/Content.tsx | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/componets/content/ConfigTemplate.tsx b/src/componets/content/ConfigTemplate.tsx index a81a699..0a503d1 100644 --- a/src/componets/content/ConfigTemplate.tsx +++ b/src/componets/content/ConfigTemplate.tsx @@ -21,10 +21,6 @@ export function ConfigTemplate(props: ConfigTemplateProps) { } }, [props.config.template.content, mode]); - // Validate placeholders (check if @placeholders@ have matching params) - const missingPlaceholders = props.config.validatePlaceholders(); - const hasValidationWarnings = missingPlaceholders.length > 0; - function handleEdit() { setOriginalContent(props.config.template.content); setDraftContent(props.config.template.content); @@ -71,21 +67,11 @@ export function ConfigTemplate(props: ConfigTemplateProps) {
{mode === 'view' ? ( <> -
+
- {hasValidationWarnings && ( - - ⚠ {missingPlaceholders.length} placeholder(s) without params - - )}
- {hasValidationWarnings && ( -
- Missing parameters: {missingPlaceholders.join(", ")} -
- )} {props.config.template.content || "{}"} diff --git a/src/componets/content/Content.tsx b/src/componets/content/Content.tsx index a7ee77a..89441e5 100644 --- a/src/componets/content/Content.tsx +++ b/src/componets/content/Content.tsx @@ -10,9 +10,13 @@ import { ConfigTemplate } from "./ConfigTemplate"; export function Content(props: { config: Config, env: Env, onTemplateSaved: (newContent: string) => void }) { const [selectTab, setTab] = useState(ContentType.Env); + // Validate placeholders for warning badge + const missingPlaceholders = props.config.validatePlaceholders(); + const hasValidationWarnings = missingPlaceholders.length > 0; + return ( <> - setTab(id)} selectedTab={selectTab} /> + setTab(id)} selectedTab={selectTab} hasValidationWarnings={hasValidationWarnings} />
{selectTab == ContentType.Env ? () : ""} {selectTab == ContentType.Json ? () : ""} @@ -30,7 +34,7 @@ enum ContentType { Test = 3 } -function ContentTabs(props: { onSelected: (id: ContentType) => void, selectedTab: ContentType }) { +function ContentTabs(props: { onSelected: (id: ContentType) => void, selectedTab: ContentType, hasValidationWarnings: boolean }) { function clickHandler(type: ContentType) { props.onSelected(type); } @@ -45,7 +49,12 @@ function ContentTabs(props: { onSelected: (id: ContentType) => void, selectedTab clickHandler(ContentType.Env)}>Env
  • - clickHandler(ContentType.Json)} >Content Template + clickHandler(ContentType.Json)} > + Content Template + {props.hasValidationWarnings && ( + ! + )} +
  • clickHandler(ContentType.Raw)}>Raw template