From 1c6ba204bec4163deab5641e43ed71f1a098ad21 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Wed, 30 May 2018 16:31:29 -0700 Subject: [PATCH] Display proper count in load more button Co-authored-by: Andrew Watkins Co-authored-by: Chris Henn --- ui/src/ifql/components/TagListItem.tsx | 6 ++++++ ui/src/ifql/components/TagValueList.tsx | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/src/ifql/components/TagListItem.tsx b/ui/src/ifql/components/TagListItem.tsx index 5951b8df0a..ecf209da33 100644 --- a/ui/src/ifql/components/TagListItem.tsx +++ b/ui/src/ifql/components/TagListItem.tsx @@ -256,6 +256,12 @@ export default class TagListItem extends PureComponent { } } + private get loadMoreCount(): number { + const {count, limit} = this.state + + return Math.min(Math.abs(count - limit), explorer.TAG_VALUES_LIMIT) + } + private get isFetchable(): boolean { const {isOpen, loadingAll} = this.state diff --git a/ui/src/ifql/components/TagValueList.tsx b/ui/src/ifql/components/TagValueList.tsx index 1470407fa7..63f91eab3b 100644 --- a/ui/src/ifql/components/TagValueList.tsx +++ b/ui/src/ifql/components/TagValueList.tsx @@ -13,6 +13,7 @@ interface Props { isLoadingMoreValues: boolean onLoadMoreValues: () => void shouldShowMoreValues: boolean + loadMoreCount: number } export default class TagValueList extends PureComponent { @@ -60,12 +61,12 @@ export default class TagValueList extends PureComponent { } private get buttonValue(): string | JSX.Element { - const {isLoadingMoreValues} = this.props + const {isLoadingMoreValues, loadMoreCount} = this.props if (isLoadingMoreValues) { return } - return `Load next ${explorer.TAG_VALUES_LIMIT} values` + return `Load next ${loadMoreCount} values` } }