From 9b4654c76f6b5f59b1a8c4d037a336f40098f7cc Mon Sep 17 00:00:00 2001 From: Christopher Henn Date: Thu, 31 May 2018 10:04:53 -0700 Subject: [PATCH] Display message when TagList is empty Co-authored-by: Andrew Watkins Co-authored-by: Chris Henn --- ui/src/ifql/components/TagList.tsx | 38 +++++++++++++------ ui/src/ifql/components/TagValueList.tsx | 4 +- ui/src/ifql/components/TagValueListItem.tsx | 26 +++++++------ .../time-machine/ifql-explorer.scss | 7 +++- 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/ui/src/ifql/components/TagList.tsx b/ui/src/ifql/components/TagList.tsx index 6fabaf3f2f..f0936fbf80 100644 --- a/ui/src/ifql/components/TagList.tsx +++ b/ui/src/ifql/components/TagList.tsx @@ -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 { public render() { const {db, service, tags, filter} = this.props + if (tags.length) { + return ( + <> + {tags.map(t => ( + + ))} + + ) + } + return ( - <> - {tags.map(t => ( - - ))} - +
+
+
No more tag keys.
+
+
) } + + private handleClick(e: MouseEvent) { + e.stopPropagation() + } } diff --git a/ui/src/ifql/components/TagValueList.tsx b/ui/src/ifql/components/TagValueList.tsx index 63f91eab3b..da18390626 100644 --- a/ui/src/ifql/components/TagValueList.tsx +++ b/ui/src/ifql/components/TagValueList.tsx @@ -61,12 +61,12 @@ export default class TagValueList extends PureComponent { } private get buttonValue(): string | JSX.Element { - const {isLoadingMoreValues, loadMoreCount} = this.props + const {isLoadingMoreValues, loadMoreCount, tagKey} = this.props if (isLoadingMoreValues) { return } - return `Load next ${loadMoreCount} values` + return `Load next ${loadMoreCount} values for ${tagKey}` } } diff --git a/ui/src/ifql/components/TagValueListItem.tsx b/ui/src/ifql/components/TagValueListItem.tsx index 37407bd9b4..81056dd154 100644 --- a/ui/src/ifql/components/TagValueListItem.tsx +++ b/ui/src/ifql/components/TagValueListItem.tsx @@ -48,18 +48,20 @@ class TagValueListItem extends PureComponent { {this.isLoading && } {!this.isLoading && ( <> -
- -
+ {!!this.tags.length && ( +
+ +
+ )}