From 38126bc5950245be8e2284603dbae061b1390741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 20 Feb 2017 09:31:50 +0100 Subject: [PATCH] fix(templating): fixed issue detecting template variable dependency, fixes #7354 --- CHANGELOG.md | 1 + public/app/features/templating/specs/variable_specs.ts | 7 ++++++- public/app/features/templating/variable.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc24bcda89d..30dd5f132d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ * **OAuth**: Redirect to original page when logging in with OAuth [#7513](https://github.com/grafana/grafana/issues/7513) * **Annotations**: Wrap text in annotations tooltip [#7542](https://github.com/grafana/grafana/pull/7542), thx [@xginn8](https://github.com/xginn8) * **Templating**: Fixes error when using numeric sort on empty strings [#7382](https://github.com/grafana/grafana/issues/7382) +* **Templating**: Fixed issue detecting template variable dependency [#7354](https://github.com/grafana/grafana/issues/7354) # 4.1.2 (2017-02-13) diff --git a/public/app/features/templating/specs/variable_specs.ts b/public/app/features/templating/specs/variable_specs.ts index 9a974eae695..0031c2df79a 100644 --- a/public/app/features/templating/specs/variable_specs.ts +++ b/public/app/features/templating/specs/variable_specs.ts @@ -12,10 +12,15 @@ describe('containsVariable', function() { }); it('should not find it if only part matches with $var syntax', function() { - var contains = containsVariable('this.$ServerDomain.filters', 'Server'); + var contains = containsVariable('this.$serverDomain.filters', 'server'); expect(contains).to.be(false); }); + it('should find it if it ends with variable and passing multiple test strings', function() { + var contains = containsVariable('show field keys from $pgmetric', 'test string2', 'pgmetric'); + expect(contains).to.be(true); + }); + it('should find it with [[var]] syntax', function() { var contains = containsVariable('this.[[test]].filters', 'test'); expect(contains).to.be(true); diff --git a/public/app/features/templating/variable.ts b/public/app/features/templating/variable.ts index 381f1ea7a3c..d451b66ffb1 100644 --- a/public/app/features/templating/variable.ts +++ b/public/app/features/templating/variable.ts @@ -23,7 +23,7 @@ export function containsVariable(...args: any[]) { var str = args[0] || ''; for (var i = 1; i < args.length-1; i++) { - str += args[i] || ''; + str += ' ' + args[i] || ''; } variableName = kbn.regexEscape(variableName);