Use QueryTabList component
parent
e949ac9091
commit
86e5dc217b
|
@ -2,6 +2,7 @@ import React, {PropTypes} from 'react'
|
||||||
|
|
||||||
import QueryBuilder from './QueryBuilder'
|
import QueryBuilder from './QueryBuilder'
|
||||||
import QueryMakerTab from './QueryMakerTab'
|
import QueryMakerTab from './QueryMakerTab'
|
||||||
|
import QueryTabList from 'src/dashboards/components/QueryTabList'
|
||||||
import buildInfluxQLQuery from 'utils/influxql'
|
import buildInfluxQLQuery from 'utils/influxql'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
|
||||||
|
@ -42,7 +43,18 @@ const QueryMaker = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {height, top, layout} = this.props
|
const {
|
||||||
|
height,
|
||||||
|
top,
|
||||||
|
layout,
|
||||||
|
queries,
|
||||||
|
timeRange,
|
||||||
|
onAddQuery,
|
||||||
|
onDeleteQuery,
|
||||||
|
activeQueryIndex,
|
||||||
|
setActiveQueryIndex,
|
||||||
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames('query-maker', {
|
className={classnames('query-maker', {
|
||||||
|
@ -50,7 +62,14 @@ const QueryMaker = React.createClass({
|
||||||
})}
|
})}
|
||||||
style={{height, top}}
|
style={{height, top}}
|
||||||
>
|
>
|
||||||
{this.renderQueryTabList()}
|
<QueryTabList
|
||||||
|
queries={queries}
|
||||||
|
timeRange={timeRange}
|
||||||
|
onAddQuery={onAddQuery}
|
||||||
|
onDeleteQuery={onDeleteQuery}
|
||||||
|
activeQueryIndex={activeQueryIndex}
|
||||||
|
setActiveQueryIndex={setActiveQueryIndex}
|
||||||
|
/>
|
||||||
{this.renderQueryBuilder()}
|
{this.renderQueryBuilder()}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -109,47 +128,6 @@ const QueryMaker = React.createClass({
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
renderQueryTabList() {
|
|
||||||
const {
|
|
||||||
queries,
|
|
||||||
activeQueryIndex,
|
|
||||||
onDeleteQuery,
|
|
||||||
timeRange,
|
|
||||||
setActiveQueryIndex,
|
|
||||||
onAddQuery,
|
|
||||||
} = this.props
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="query-maker--tabs">
|
|
||||||
{queries.map((q, i) => {
|
|
||||||
return (
|
|
||||||
<QueryMakerTab
|
|
||||||
isActive={i === activeQueryIndex}
|
|
||||||
key={i}
|
|
||||||
queryIndex={i}
|
|
||||||
query={q}
|
|
||||||
onSelect={setActiveQueryIndex}
|
|
||||||
onDelete={onDeleteQuery}
|
|
||||||
queryTabText={
|
|
||||||
q.rawText ||
|
|
||||||
buildInfluxQLQuery(timeRange, q) ||
|
|
||||||
`Query ${i + 1}`
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
{this.props.children}
|
|
||||||
<div
|
|
||||||
className="query-maker--new btn btn-sm btn-primary"
|
|
||||||
onClick={onAddQuery}
|
|
||||||
data-test="new-query-button"
|
|
||||||
>
|
|
||||||
<span className="icon plus" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
QueryMaker.defaultProps = {
|
QueryMaker.defaultProps = {
|
||||||
|
|
Loading…
Reference in New Issue