Extract paramBadgeSuffix helper from nested ternary chain

Replace the 4-deep nested ternary building each declared-param badge's
suffix text with a small if/else-if helper (paramBadgeSuffix), called
from the badge JSX. No behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TeyhRfMYjMditek6geDRoQ
This commit is contained in:
Hugh Kaznowski
2026-09-07 10:44:24 +01:00
co-authored by Claude Sonnet 5
parent 1014aeaf68
commit 28689b1b8d
+11 -9
View File
@@ -11,6 +11,16 @@ const EMPTY_KIND: ParamDeclaration['kind'] = 'string'
// sharing the same label set (ticket 038). // sharing the same label set (ticket 038).
type ExtractionSource = 'regex' | 'json_field' | 'elapsed_since_last' type ExtractionSource = 'regex' | 'json_field' | 'elapsed_since_last'
// The parenthesized suffix shown after a declared-param badge's kind, e.g. "(string, group path)" —
// one of five possible forms depending on how the param's value is produced.
function paramBadgeSuffix(p: ParamDeclaration): string {
if (p.elapsed_since_last) return ', elapsed since previous'
if (p.kind === 'boolean') return ''
if (p.json_field_path) return `, json field ${p.json_field_path}`
if (p.capture_group !== p.name) return `, group ${p.capture_group}`
return ''
}
/// A JSON *object* (not an array/scalar) parses cleanly and pretty-prints with braces — the same /// A JSON *object* (not an array/scalar) parses cleanly and pretty-prints with braces — the same
/// shape a JSON field path can be read from, so this is the "line looks like JSON" gate that /// shape a JSON field path can be read from, so this is the "line looks like JSON" gate that
/// unlocks the "JSON field" extraction option. /// unlocks the "JSON field" extraction option.
@@ -301,15 +311,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
title={p.elapsed_since_last ? undefined : p.message_match_regex} title={p.elapsed_since_last ? undefined : p.message_match_regex}
> >
{p.name} ({p.kind} {p.name} ({p.kind}
{p.elapsed_since_last {paramBadgeSuffix(p)}
? ', elapsed since previous'
: p.kind === 'boolean'
? ''
: p.json_field_path
? `, json field ${p.json_field_path}`
: p.capture_group !== p.name
? `, group ${p.capture_group}`
: ''}
) )
</button> </button>
))} ))}