fix(templating): improved detection of nested template variables, fixes #4986, fixes #4987

This commit is contained in:
Torkel Ödegaard 2016-05-12 10:41:15 +02:00
parent 0201ac24e7
commit 35f55cabf0
3 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
# 3.0.2 Stable (unreleased) # 3.0.2 Stable (unreleased)
* **Templating**: Fixed issue mixing row repeat and panel repeats, fixes [#4988](https://github.com/grafana/grafana/issues/4988) * **Templating**: Fixed issue mixing row repeat and panel repeats, fixes [#4988](https://github.com/grafana/grafana/issues/4988)
* **Templating**: Fixed issue detecting dependencies in nested variables, fixes [#4987](https://github.com/grafana/grafana/issues/4987), fixes [#4986](https://github.com/grafana/grafana/issues/4986)
# 3.0.1 Stable (2016-05-11) # 3.0.1 Stable (2016-05-11)

View File

@ -97,7 +97,8 @@ function (angular, _) {
if (!str) { if (!str) {
return false; return false;
} }
return str.indexOf('$' + variableName) !== -1 || str.indexOf('[[' + variableName + ']]') !== -1; var match = this._regex.exec(str);
return match && (match[1] === variableName || match[2] === variableName);
}; };
this.highlightVariablesAsHtml = function(str) { this.highlightVariablesAsHtml = function(str) {

View File

@ -190,6 +190,11 @@ define([
expect(contains).to.be(true); expect(contains).to.be(true);
}); });
it('should not find it if only part matches with $var syntax', function() {
var contains = _templateSrv.containsVariable('this.$ServerDomain.filters', 'Server');
expect(contains).to.be(false);
});
it('should find it with [[var]] syntax', function() { it('should find it with [[var]] syntax', function() {
var contains = _templateSrv.containsVariable('this.[[test]].filters', 'test'); var contains = _templateSrv.containsVariable('this.[[test]].filters', 'test');
expect(contains).to.be(true); expect(contains).to.be(true);