feat: add extended placeholder validation
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user