stackdriver: fix default value bug

This commit is contained in:
Erik Sundell 2018-11-01 10:14:28 +01:00
parent 042d156e5f
commit fcf39a0839
2 changed files with 3 additions and 3 deletions

View File

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

View File

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