Variables: Do not update variable from url when value is the same (#23220)

pull/23249/head
Torkel Ödegaard 5 years ago committed by GitHub
parent 1814dc5afc
commit 49d2910e39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      public/app/features/templating/variable_srv.ts

@ -330,9 +330,12 @@ export class VariableSrv {
for (const v of this.variables) {
const key = `var-${v.name}`;
if (vars.hasOwnProperty(key)) {
update.push(v.setValueFromUrl(vars[key]));
if (this.isVariableUrlValueDifferentFromCurrent(v, vars[key])) {
update.push(v.setValueFromUrl(vars[key]));
}
}
}
if (update.length) {
Promise.all(update).then(() => {
this.dashboard.templateVariableValueUpdated();
@ -341,6 +344,11 @@ export class VariableSrv {
}
}
isVariableUrlValueDifferentFromCurrent(variable: any, urlValue: any) {
// lodash _.isEqual handles array of value equality checks as well
return !_.isEqual(variable.current.value, urlValue);
}
updateUrlParamsWithCurrentVariables() {
// update url
const params = this.$location.search();

Loading…
Cancel
Save