fix(templating): fixed issue with current data source variable value, fixes #4934
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# 3.0.0 stable (unreleased)
|
||||||
|
|
||||||
|
* **Templating**: Fixed issue with new data source variable not persisting current selected value, fixes [#4934](https://github.com/grafana/grafana/issues/4934)
|
||||||
|
|
||||||
# 3.0.0-beta7 (2016-05-02)
|
# 3.0.0-beta7 (2016-05-02)
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|||||||
@@ -213,8 +213,7 @@ function (angular, _, kbn) {
|
|||||||
this.updateOptions = function(variable) {
|
this.updateOptions = function(variable) {
|
||||||
if (variable.type !== 'query') {
|
if (variable.type !== 'query') {
|
||||||
self._updateNonQueryVariable(variable);
|
self._updateNonQueryVariable(variable);
|
||||||
self.setVariableValue(variable, variable.options[0]);
|
return self.validateVariableSelectionState(variable);
|
||||||
return $q.when([]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return datasourceSrv.get(variable.datasource)
|
return datasourceSrv.get(variable.datasource)
|
||||||
@@ -251,7 +250,7 @@ function (angular, _, kbn) {
|
|||||||
if (_.isArray(variable.current.value)) {
|
if (_.isArray(variable.current.value)) {
|
||||||
self.selectOptionsForCurrentValue(variable);
|
self.selectOptionsForCurrentValue(variable);
|
||||||
} else {
|
} else {
|
||||||
var currentOption = _.findWhere(variable.options, { text: variable.current.text });
|
var currentOption = _.findWhere(variable.options, {text: variable.current.text});
|
||||||
if (currentOption) {
|
if (currentOption) {
|
||||||
return self.setVariableValue(variable, currentOption, true);
|
return self.setVariableValue(variable, currentOption, true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ define([
|
|||||||
|
|
||||||
describeUpdateVariable('update custom variable', function(scenario) {
|
describeUpdateVariable('update custom variable', function(scenario) {
|
||||||
scenario.setup(function() {
|
scenario.setup(function() {
|
||||||
scenario.variable = { type: 'custom', query: 'hej, hop, asd', name: 'test'};
|
scenario.variable = {type: 'custom', query: 'hej, hop, asd', name: 'test'};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update options array', function() {
|
it('should update options array', function() {
|
||||||
@@ -286,7 +286,13 @@ define([
|
|||||||
|
|
||||||
describeUpdateVariable('datasource variable with regex filter', function(scenario) {
|
describeUpdateVariable('datasource variable with regex filter', function(scenario) {
|
||||||
scenario.setup(function() {
|
scenario.setup(function() {
|
||||||
scenario.variable = {type: 'datasource', query: 'graphite', name: 'test', current: {}, regex: '/pee$/' };
|
scenario.variable = {
|
||||||
|
type: 'datasource',
|
||||||
|
query: 'graphite',
|
||||||
|
name: 'test',
|
||||||
|
current: {value: 'backend4_pee', text: 'backend4_pee'},
|
||||||
|
regex: '/pee$/'
|
||||||
|
};
|
||||||
scenario.metricSources = [
|
scenario.metricSources = [
|
||||||
{name: 'backend1', meta: {id: 'influx'}},
|
{name: 'backend1', meta: {id: 'influx'}},
|
||||||
{name: 'backend2_pee', meta: {id: 'graphite'}},
|
{name: 'backend2_pee', meta: {id: 'graphite'}},
|
||||||
@@ -300,6 +306,10 @@ define([
|
|||||||
expect(scenario.variable.options[0].value).to.be('backend2_pee');
|
expect(scenario.variable.options[0].value).to.be('backend2_pee');
|
||||||
expect(scenario.variable.options[1].value).to.be('backend4_pee');
|
expect(scenario.variable.options[1].value).to.be('backend4_pee');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should keep current value if available', function() {
|
||||||
|
expect(scenario.variable.current.value).to.be('backend4_pee');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user