mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Explore: Show log line if there is an interpolated link (#65489)
* Add back log lines changes
This reverts commit f43ef18732.
* Bring in @torkelo ’s changes to template_srv, implement with new format
* Enable functionality
* Remove non relevant test
* Fix tests, add @ifrost suggested tests and clarifying comment
* Add test around static link logic
This commit is contained in:
@@ -185,17 +185,19 @@ describe('ensureStringValues', () => {
|
||||
|
||||
describe('containsVariable', () => {
|
||||
it.each`
|
||||
value | expected
|
||||
${''} | ${false}
|
||||
${'$var'} | ${true}
|
||||
${{ thing1: '${var}' }} | ${true}
|
||||
${{ thing1: '${var:fmt}' }} | ${true}
|
||||
${{ thing1: ['1', '${var}'] }} | ${true}
|
||||
${{ thing1: ['1', '[[var]]'] }} | ${true}
|
||||
${{ thing1: ['1', '[[var:fmt]]'] }} | ${true}
|
||||
${{ thing1: { thing2: '${var}' } }} | ${true}
|
||||
${{ params: [['param', '$var']] }} | ${true}
|
||||
${{ params: [['param', '${var}']] }} | ${true}
|
||||
value | expected
|
||||
${''} | ${false}
|
||||
${'$var'} | ${true}
|
||||
${{ thing1: '${var}' }} | ${true}
|
||||
${{ thing1: '${var:fmt}' }} | ${true}
|
||||
${{ thing1: '${var.fieldPath}' }} | ${true}
|
||||
${{ thing1: '${var.fieldPath:fmt}' }} | ${true}
|
||||
${{ thing1: ['1', '${var}'] }} | ${true}
|
||||
${{ thing1: ['1', '[[var]]'] }} | ${true}
|
||||
${{ thing1: ['1', '[[var:fmt]]'] }} | ${true}
|
||||
${{ thing1: { thing2: '${var}' } }} | ${true}
|
||||
${{ params: [['param', '$var']] }} | ${true}
|
||||
${{ params: [['param', '${var}']] }} | ${true}
|
||||
`('when called with value:$value then result should be:$expected', ({ value, expected }) => {
|
||||
expect(containsVariable(value, 'var')).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -16,9 +16,10 @@ import { QueryVariableModel, TransactionStatus, VariableModel, VariableRefresh,
|
||||
|
||||
/*
|
||||
* This regex matches 3 types of variable reference with an optional format specifier
|
||||
* \$(\w+) $var1
|
||||
* \[\[(\w+?)(?::(\w+))?\]\] [[var2]] or [[var2:fmt2]]
|
||||
* \${(\w+)(?::(\w+))?} ${var3} or ${var3:fmt3}
|
||||
* There are 6 capture groups that replace will return
|
||||
* \$(\w+) $var1
|
||||
* \[\[(\w+?)(?::(\w+))?\]\] [[var2]] or [[var2:fmt2]]
|
||||
* \${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?} ${var3} or ${var3.fieldPath} or ${var3:fmt3} (or ${var3.fieldPath:fmt3} but that is not a separate capture group)
|
||||
*/
|
||||
export const variableRegex = /\$(\w+)|\[\[(\w+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user