diff --git a/webapp/src/components/Params.tsx b/webapp/src/components/Params.tsx index ff90ec3..248ab2f 100644 --- a/webapp/src/components/Params.tsx +++ b/webapp/src/components/Params.tsx @@ -11,6 +11,16 @@ const EMPTY_KIND: ParamDeclaration['kind'] = 'string' // sharing the same label set (ticket 038). 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 /// 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. @@ -301,15 +311,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD title={p.elapsed_since_last ? undefined : p.message_match_regex} > {p.name} ({p.kind} - {p.elapsed_since_last - ? ', 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}` - : ''} + {paramBadgeSuffix(p)} ) ))}