Skip to content

Commit

Permalink
BackendSrv: Fix error alert logic (#26453)
Browse files Browse the repository at this point in the history
(cherry picked from commit fba329f)
  • Loading branch information
torkelo authored and hugohaggmark committed Aug 5, 2020
1 parent dbb3750 commit b076394
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions public/app/features/templating/template_srv.ts
Expand Up @@ -298,7 +298,8 @@ export class TemplateSrv implements BaseTemplateSrv {

variableExists(expression: string) {
const name = this.getVariableName(expression);
return name && this.getVariableAtIndex(name) !== void 0;
const variable = name && this.getVariableAtIndex(name);
return variable !== null && variable !== undefined;
}

highlightVariablesAsHtml(str: string) {
Expand Down Expand Up @@ -458,7 +459,7 @@ export class TemplateSrv implements BaseTemplateSrv {
return value.join(',');
}

private getVariableAtIndex = (name: string): any => {
private getVariableAtIndex(name: string) {
if (!name) {
return;
}
Expand All @@ -468,11 +469,11 @@ export class TemplateSrv implements BaseTemplateSrv {
}

return this.index[name];
};
}

private getAdHocVariables = (): any[] => {
private getAdHocVariables(): any[] {
return this.dependencies.getFilteredVariables(isAdHoc);
};
}
}

// Expose the template srv
Expand Down

0 comments on commit b076394

Please sign in to comment.