Merge pull request #1340 from influxdata/bugfix/no-active-query
Bugfix/no active querypull/1344/head^2
commit
111e5a1c62
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
1. [#1337](https://github.com/influxdata/chronograf/pull/1337): Fix no apps for hosts false negative
|
1. [#1337](https://github.com/influxdata/chronograf/pull/1337): Fix no apps for hosts false negative
|
||||||
|
1. [#1340](https://github.com/influxdata/chronograf/pull/1340): Fix no active query in DE and Cell editing
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
### UI Improvements
|
### UI Improvements
|
||||||
1. [#1335](https://github.com/influxdata/chronograf/pull/1335): Improve UX for sanitized kapacitor settings
|
1. [#1335](https://github.com/influxdata/chronograf/pull/1335): Improve UX for sanitized kapacitor settings
|
||||||
|
1. [#1340](https://github.com/influxdata/chronograf/pull/1340): Automatically switch to table view if meta query
|
||||||
|
|
||||||
## v1.2.0-beta9 [2017-04-21]
|
## v1.2.0-beta9 [2017-04-21]
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,10 @@ import classNames from 'classnames'
|
||||||
import VisHeader from 'src/data_explorer/components/VisHeader'
|
import VisHeader from 'src/data_explorer/components/VisHeader'
|
||||||
import VisView from 'src/data_explorer/components/VisView'
|
import VisView from 'src/data_explorer/components/VisView'
|
||||||
import {GRAPH, TABLE} from 'src/shared/constants'
|
import {GRAPH, TABLE} from 'src/shared/constants'
|
||||||
|
import _ from 'lodash'
|
||||||
|
|
||||||
const {arrayOf, func, number, shape, string} = PropTypes
|
const {arrayOf, func, number, shape, string} = PropTypes
|
||||||
|
const META_QUERY_REGEX = /^show/i
|
||||||
|
|
||||||
const Visualization = React.createClass({
|
const Visualization = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
|
@ -33,18 +35,12 @@ const Visualization = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
const {queryConfigs, activeQueryIndex} = this.props
|
const {activeQueryIndex, queryConfigs} = this.props
|
||||||
if (!queryConfigs.length || activeQueryIndex === null) {
|
const activeQueryText = this.getQueryText(queryConfigs, activeQueryIndex)
|
||||||
return {
|
|
||||||
view: GRAPH,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return activeQueryText.match(META_QUERY_REGEX)
|
||||||
view: typeof queryConfigs[activeQueryIndex].rawText === 'string'
|
? {view: TABLE}
|
||||||
? TABLE
|
: {view: GRAPH}
|
||||||
: GRAPH,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
|
@ -54,19 +50,22 @@ const Visualization = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const {queryConfigs, activeQueryIndex} = nextProps
|
const {activeQueryIndex, queryConfigs} = nextProps
|
||||||
if (
|
const nextQueryText = this.getQueryText(queryConfigs, activeQueryIndex)
|
||||||
!queryConfigs.length ||
|
const queryText = this.getQueryText(
|
||||||
activeQueryIndex === null ||
|
this.props.queryConfigs,
|
||||||
activeQueryIndex === this.props.activeQueryIndex
|
this.props.activeQueryIndex
|
||||||
) {
|
)
|
||||||
|
|
||||||
|
if (queryText === nextQueryText) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeQuery = queryConfigs[activeQueryIndex]
|
if (nextQueryText.match(META_QUERY_REGEX)) {
|
||||||
if (activeQuery && typeof activeQuery.rawText === 'string') {
|
|
||||||
return this.setState({view: TABLE})
|
return this.setState({view: TABLE})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({view: GRAPH})
|
||||||
},
|
},
|
||||||
|
|
||||||
handleToggleView(view) {
|
handleToggleView(view) {
|
||||||
|
@ -125,6 +124,11 @@ const Visualization = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getQueryText(queryConfigs, index) {
|
||||||
|
// rawText can be null
|
||||||
|
return _.get(queryConfigs, [`${index}`, 'rawText'], '') || ''
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Visualization
|
export default Visualization
|
||||||
|
|
|
@ -57,7 +57,7 @@ const DataExplorer = React.createClass({
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
activeQueryIndex: null,
|
activeQueryIndex: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue