Browse Source

stackdriver: fix default value bug

Erik Sundell 7 years ago
parent
commit
fcf39a0839

+ 2 - 2
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx

@@ -57,7 +57,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
       metricTypes,
       metricTypes,
       selectedMetricType,
       selectedMetricType,
       metricDescriptors,
       metricDescriptors,
-      ...await this.getLabels(this.state.selectedMetricType),
+      ...await this.getLabels(selectedMetricType),
     };
     };
     this.setState(state);
     this.setState(state);
   }
   }
@@ -95,7 +95,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
   }
   }
 
 
   componentDidUpdate() {
   componentDidUpdate() {
-    const { metricDescriptors, labels, ...queryModel } = this.state;
+    const { metricDescriptors, labels, metricTypes, services, ...queryModel } = this.state;
     this.props.onChange(queryModel);
     this.props.onChange(queryModel);
   }
   }
 
 

+ 1 - 1
public/app/plugins/datasource/stackdriver/functions.ts

@@ -12,7 +12,7 @@ export const getMetricTypes = (metricDescriptors, metricType, selectedService) =
     name: m.displayName,
     name: m.displayName,
   }));
   }));
   const metricTypeExistInArray = metricTypes.some(m => m.value === metricType);
   const metricTypeExistInArray = metricTypes.some(m => m.value === metricType);
-  const selectedMetricType = metricTypeExistInArray ? metricTypeExistInArray.value : metricTypes[0].value;
+  const selectedMetricType = metricTypeExistInArray ? metricType : metricTypes[0].value;
   return {
   return {
     metricTypes,
     metricTypes,
     selectedMetricType,
     selectedMetricType,