mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
feat(templating): don't persist template variable options when variable has refresh enabled, closes #6586
This commit is contained in:
parent
eafe0d6bfa
commit
9d5928ddd6
@ -9,6 +9,7 @@
|
||||
|
||||
### Enhancements
|
||||
* **Singlestat**: Support repeated template variables in prefix/postfix [#6595](https://github.com/grafana/grafana/issues/6595)
|
||||
* **Templating**: Don't persist variable options with refresh option [#6586](https://github.com/grafana/grafana/issues/6586)
|
||||
|
||||
# 4.0-beta1 (2016-11-09)
|
||||
|
||||
|
@ -32,6 +32,12 @@ export class DatasourceVariable implements Variable {
|
||||
|
||||
getSaveModel() {
|
||||
assignModelProperties(this.model, this, this.defaults);
|
||||
|
||||
// dont persist options
|
||||
if (this.refresh !== 0) {
|
||||
this.model.options = [];
|
||||
}
|
||||
|
||||
return this.model;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,12 @@ export class QueryVariable implements Variable {
|
||||
getSaveModel() {
|
||||
// copy back model properties to model
|
||||
assignModelProperties(this.model, this, this.defaults);
|
||||
|
||||
// remove options
|
||||
if (this.refresh !== 0) {
|
||||
this.model.options = [];
|
||||
}
|
||||
|
||||
return this.model;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,15 @@ describe('QueryVariable', function() {
|
||||
expect(model.sort).to.be(50);
|
||||
});
|
||||
|
||||
});
|
||||
it('if refresh != 0 then remove options in presisted mode', () => {
|
||||
var variable = new QueryVariable({}, null, null, null, null);
|
||||
variable.options = [{text: 'test'}];
|
||||
variable.refresh = 1;
|
||||
|
||||
var model = variable.getSaveModel();
|
||||
expect(model.options.length).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user