Merge pull request #4407 from influxdata/flux/error-for-dynamic-source-without-flux

Add tooltip for dynamic source that does not support flux
pull/4404/head
Alirie Gray 2018-09-10 16:28:34 -07:00 committed by GitHub
commit 423c0e38ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 27 deletions

View File

@ -1,9 +1,10 @@
// Libraries
import React, {SFC} from 'react'
// Componentes
// Components
import SourceDropdown from 'src/flux/components/SourceDropdown'
import {Radio} from 'src/reusable_ui'
import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip'
// Types
import * as QueriesModels from 'src/types/queries'
@ -55,28 +56,36 @@ const SourceSelector: SFC<Props> = ({
onChangeService={onChangeService}
onSelectDynamicSource={onSelectDynamicSource}
/>
{isDynamicSourceSelected && (
<Radio>
<Radio.Button
id="flux-source"
titleText="Flux"
value="Flux"
onClick={toggleFlux}
active={isFluxSource}
disabled={!sourceSupportsFlux}
>
Flux
</Radio.Button>
<Radio.Button
id="influxql-source"
titleText="InfluxQL"
value="InfluxQL"
onClick={toggleFlux}
active={!isFluxSource}
disabled={!sourceSupportsFlux}
>
InfluxQL
</Radio.Button>
</Radio>
)}
{isDynamicSourceSelected &&
sourceSupportsFlux && (
<Radio>
<Radio.Button
id="flux-source"
titleText="Flux"
value="Flux"
onClick={toggleFlux}
active={isFluxSource}
>
Flux
</Radio.Button>
<Radio.Button
id="influxql-source"
titleText="InfluxQL"
value="InfluxQL"
onClick={toggleFlux}
active={!isFluxSource}
>
InfluxQL
</Radio.Button>
</Radio>
!sourceSupportsFlux && (
<QuestionMarkTooltip
tipID="token"
tipContent={`<p>The current source does not support Flux.</p>`}
/>
)}
</div>
)

View File

@ -405,16 +405,15 @@ class TimeMachine extends PureComponent<Props, State> {
private get source(): Source {
const {source, sources, queryDrafts} = this.props
const {selectedSource, useDynamicSource} = this.state
if (selectedSource) {
return selectedSource
}
// return current source
if (useDynamicSource) {
return source
}
if (selectedSource) {
return selectedSource
}
const queryDraft = _.get(queryDrafts, 0)
const querySource = _.get(queryDraft, 'source')