Display message when TagList is empty

Co-authored-by: Andrew Watkins <andrew.watkinz@gmail.com>
Co-authored-by: Chris Henn <chris.henn@influxdata.com>
pull/10616/head
Christopher Henn 2018-05-31 10:04:53 -07:00 committed by Andrew Watkins
parent 93a4786130
commit 9b4654c76f
4 changed files with 47 additions and 28 deletions

View File

@ -1,4 +1,4 @@
import React, {PureComponent} from 'react'
import React, {PureComponent, MouseEvent} from 'react'
import {SchemaFilter, Service} from 'src/types'
import TagListItem from 'src/ifql/components/TagListItem'
@ -24,18 +24,32 @@ export default class TagList extends PureComponent<Props, State> {
public render() {
const {db, service, tags, filter} = this.props
if (tags.length) {
return (
<>
{tags.map(t => (
<TagListItem
key={t}
db={db}
tagKey={t}
service={service}
filter={filter}
/>
))}
</>
)
}
return (
<>
{tags.map(t => (
<TagListItem
key={t}
db={db}
tagKey={t}
service={service}
filter={filter}
/>
))}
</>
<div className="ifql-schema-tree ifql-tree-node">
<div className="ifql-schema-item no-hover" onClick={this.handleClick}>
<div className="no-results">No more tag keys.</div>
</div>
</div>
)
}
private handleClick(e: MouseEvent<HTMLDivElement>) {
e.stopPropagation()
}
}

View File

@ -61,12 +61,12 @@ export default class TagValueList extends PureComponent<Props> {
}
private get buttonValue(): string | JSX.Element {
const {isLoadingMoreValues, loadMoreCount} = this.props
const {isLoadingMoreValues, loadMoreCount, tagKey} = this.props
if (isLoadingMoreValues) {
return <LoadingSpinner />
}
return `Load next ${loadMoreCount} values`
return `Load next ${loadMoreCount} values for ${tagKey}`
}
}

View File

@ -48,18 +48,20 @@ class TagValueListItem extends PureComponent<Props, State> {
{this.isLoading && <LoaderSkeleton />}
{!this.isLoading && (
<>
<div className="ifql-schema--filter">
<input
className="form-control input-sm"
placeholder={`Filter within ${db}`}
type="text"
spellCheck={false}
autoComplete="off"
value={searchTerm}
onClick={this.handleInputClick}
onChange={this.onSearch}
/>
</div>
{!!this.tags.length && (
<div className="ifql-schema--filter">
<input
className="form-control input-sm"
placeholder={`Filter within ${db}`}
type="text"
spellCheck={false}
autoComplete="off"
value={searchTerm}
onClick={this.handleInputClick}
onChange={this.onSearch}
/>
</div>
)}
<TagList
db={db}
service={service}

View File

@ -113,7 +113,10 @@ $ifql-tree-line: 2px;
}
.increase-values-limit {
margin-left: 8px;
width: 160px;
padding: 0 10px;
}
.no-results {
margin-left: 8px;
}
}