浏览代码

Merge pull request #13133 from grafana/13132_query_variable

Fix error when new variables created but not yet added/saved
Marcus Efraimsson 7 年之前
父节点
当前提交
7c88436a9b
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      public/app/features/templating/variable_srv.ts

+ 5 - 4
public/app/features/templating/variable_srv.ts

@@ -122,12 +122,13 @@ export class VariableSrv {
     }
 
     const g = this.createGraph();
-    const promises = g
-      .getNode(variable.name)
-      .getOptimizedInputEdges()
-      .map(e => {
+    const node = g.getNode(variable.name);
+    let promises = [];
+    if (node) {
+      promises = node.getOptimizedInputEdges().map(e => {
         return this.updateOptions(this.variables.find(v => v.name === e.inputNode.name));
       });
+    }
 
     return this.$q.all(promises).then(() => {
       if (emitChangeEvents) {