feat: add extended placeholder validation

This commit is contained in:
sokol
2026-02-18 17:50:26 +03:00
parent 0b347c5c94
commit 5cc15eb87a
2 changed files with 60 additions and 1 deletions

View File

@@ -21,6 +21,10 @@ 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);
@@ -67,11 +71,21 @@ export function ConfigTemplate(props: ConfigTemplateProps) {
<div className="config-template-editor">
{mode === 'view' ? (
<>
<div className="mb-2">
<div className="mb-2 d-flex gap-2 align-items-center">
<button className="btn btn-primary btn-sm" onClick={handleEdit}>
Edit
</button>
{hasValidationWarnings && (
<span className="text-warning">
{missingPlaceholders.length} placeholder(s) without params
</span>
)}
</div>
{hasValidationWarnings && (
<div className="alert alert-warning py-2 px-3 mb-2" style={{ fontSize: '0.875rem' }}>
<strong>Missing parameters:</strong> {missingPlaceholders.join(", ")}
</div>
)}
<Highlight className="language-json">
{props.config.template.content || "{}"}
</Highlight>