[bugfix] fix metrics/metric control default (#3009)

We should pick an arbitrary metric by default. This broke when
improving the metrics selector recently.
This commit is contained in:
Maxime Beauchemin 2017-06-21 09:31:29 -07:00 committed by GitHub
parent 53dead9c29
commit 593861eac6
1 changed files with 2 additions and 4 deletions

View File

@ -63,8 +63,7 @@ export const controls = {
valueKey: 'metric_name',
optionRenderer: m => <MetricOption metric={m} />,
valueRenderer: m => <MetricOption metric={m} />,
default: control =>
control.choices && control.choices.length > 0 ? [control.choices[0][0]] : null,
default: c => c.options && c.options.length > 0 ? [c.options[0].metric_name] : null,
mapStateToProps: state => ({
options: (state.datasource) ? state.datasource.metrics : [],
}),
@ -100,9 +99,8 @@ export const controls = {
validators: [v.nonEmpty],
optionRenderer: m => <MetricOption metric={m} />,
valueRenderer: m => <MetricOption metric={m} />,
default: c => c.options && c.options.length > 0 ? c.options[0].metric_name : null,
valueKey: 'metric_name',
default: control =>
control.choices && control.choices.length > 0 ? control.choices[0][0] : null,
mapStateToProps: state => ({
options: (state.datasource) ? state.datasource.metrics : [],
}),