Merge pull request #11458 from influxdata/fixes/dont-show-add-when-no-tags

When all tags have selector, don't show add button
pull/11464/head
Brandon Farmer 2019-01-22 17:03:08 -08:00 committed by GitHub
commit 7e9c6ef7f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 9 deletions

View File

@ -14,16 +14,21 @@ import FunctionSelector from 'src/shared/components/FunctionSelector'
import {loadBuckets, addTagSelector} from 'src/shared/actions/v2/queryBuilder' import {loadBuckets, addTagSelector} from 'src/shared/actions/v2/queryBuilder'
// Utils // Utils
import {getActiveQuery} from 'src/shared/selectors/timeMachines' import {
getActiveQuery,
getActiveTimeMachine,
} from 'src/shared/selectors/timeMachines'
// Styles // Styles
import 'src/shared/components/TimeMachineQueryBuilder.scss' import 'src/shared/components/TimeMachineQueryBuilder.scss'
// Types // Types
import {AppState} from 'src/types/v2' import {AppState} from 'src/types/v2'
import {RemoteDataState} from 'src/types'
interface StateProps { interface StateProps {
tagFiltersLength: number tagFiltersLength: number
moreTags: boolean
} }
interface DispatchProps { interface DispatchProps {
@ -41,7 +46,7 @@ class TimeMachineQueryBuilder extends PureComponent<Props, State> {
} }
public render() { public render() {
const {tagFiltersLength, onAddTagSelector} = this.props const {tagFiltersLength} = this.props
return ( return (
<div className="query-builder"> <div className="query-builder">
@ -56,12 +61,7 @@ class TimeMachineQueryBuilder extends PureComponent<Props, State> {
{range(tagFiltersLength).map(i => ( {range(tagFiltersLength).map(i => (
<TagSelector key={i} index={i} /> <TagSelector key={i} index={i} />
))} ))}
<Button {this.addButton}
shape={ButtonShape.Square}
icon={IconFont.Plus}
onClick={onAddTagSelector}
customClass="query-builder--add-tag-selector"
/>
</div> </div>
</FancyScrollbar> </FancyScrollbar>
<FunctionSelector /> <FunctionSelector />
@ -69,12 +69,35 @@ class TimeMachineQueryBuilder extends PureComponent<Props, State> {
</div> </div>
) )
} }
private get addButton(): JSX.Element {
const {moreTags, onAddTagSelector} = this.props
if (!moreTags) {
return null
}
return (
<Button
shape={ButtonShape.Square}
icon={IconFont.Plus}
onClick={onAddTagSelector}
customClass="query-builder--add-tag-selector"
/>
)
}
} }
const mstp = (state: AppState): StateProps => { const mstp = (state: AppState): StateProps => {
const tagFiltersLength = getActiveQuery(state).builderConfig.tags.length const tagFiltersLength = getActiveQuery(state).builderConfig.tags.length
const tags = getActiveTimeMachine(state).queryBuilder.tags
return {tagFiltersLength} const {keys, keysStatus} = tags[tags.length - 1]
return {
tagFiltersLength,
moreTags: !(keys.length === 0 && keysStatus === RemoteDataState.Done),
}
} }
const mdtp = { const mdtp = {