Fix dropdown populating via normalizd parsers, rename selected var names for clarity
parent
b25cff0b6d
commit
2e5118ecf7
|
@ -2,7 +2,8 @@ import React, {PropTypes, Component} from 'react'
|
|||
import Dropdown from 'shared/components/Dropdown'
|
||||
|
||||
import {showDatabases} from 'shared/apis/metaQuery'
|
||||
import showDatabasesParser from 'shared/parsing/showDatabases'
|
||||
import parsers from 'shared/parsing'
|
||||
const {databases: showDatabasesParser} = parsers
|
||||
|
||||
class DatabaseDropdown extends Component {
|
||||
constructor(props) {
|
||||
|
@ -45,10 +46,10 @@ class DatabaseDropdown extends Component {
|
|||
const {databases} = showDatabasesParser(data)
|
||||
|
||||
this.setState({databases})
|
||||
const selectedText = databases.includes(database)
|
||||
const selectedDatabaseText = databases.includes(database)
|
||||
? database
|
||||
: databases[0] || 'No databases'
|
||||
onSelectDatabase({text: selectedText})
|
||||
onSelectDatabase({text: selectedDatabaseText})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
onErrorThrown(error)
|
||||
|
|
|
@ -3,7 +3,8 @@ import _ from 'lodash'
|
|||
|
||||
import Dropdown from 'shared/components/Dropdown'
|
||||
import {showMeasurements} from 'shared/apis/metaQuery'
|
||||
import showMeasurementsParser from 'shared/parsing/showMeasurements'
|
||||
import parsers from 'shared/parsing'
|
||||
const {measurements: showMeasurementsParser} = parsers
|
||||
|
||||
class MeasurementDropdown extends Component {
|
||||
constructor(props) {
|
||||
|
@ -51,12 +52,13 @@ class MeasurementDropdown extends Component {
|
|||
|
||||
try {
|
||||
const {data} = await showMeasurements(proxy, database)
|
||||
const {measurementSets} = showMeasurementsParser(data)
|
||||
this.setState({measurements: measurementSets[0].measurements})
|
||||
const selectedText = measurementSets.includes(measurement)
|
||||
const {measurements} = showMeasurementsParser(data)
|
||||
|
||||
this.setState({measurements})
|
||||
const selectedMeasurementText = measurements.includes(measurement)
|
||||
? measurement
|
||||
: _.get(measurementSets, ['0', 'measurements', '0'], 'No measurements')
|
||||
onSelectMeasurement({text: selectedText})
|
||||
: measurements[0] || 'No measurements'
|
||||
onSelectMeasurement({text: selectedMeasurementText})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
onErrorThrown(error)
|
||||
|
|
|
@ -2,7 +2,8 @@ import React, {PropTypes, Component} from 'react'
|
|||
|
||||
import Dropdown from 'shared/components/Dropdown'
|
||||
import {showTagKeys} from 'shared/apis/metaQuery'
|
||||
import showTagKeysParser from 'shared/parsing/showTagKeys'
|
||||
import parsers from 'shared/parsing'
|
||||
const {tagKeys: showTagKeysParser} = parsers
|
||||
|
||||
class TagKeyDropdown extends Component {
|
||||
constructor(props) {
|
||||
|
@ -57,10 +58,10 @@ class TagKeyDropdown extends Component {
|
|||
const {tagKeys} = showTagKeysParser(data)
|
||||
|
||||
this.setState({tagKeys})
|
||||
const selectedText = tagKeys.includes(tagKey)
|
||||
const selectedTagKeyText = tagKeys.includes(tagKey)
|
||||
? tagKey
|
||||
: tagKeys[0] || 'No tags'
|
||||
onSelectTagKey({text: selectedText})
|
||||
onSelectTagKey({text: selectedTagKeyText})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
onErrorThrown(error)
|
||||
|
|
Loading…
Reference in New Issue