feat(fluxWizard): allow to load more values

pull/5861/head
Pavel Zavora 2022-02-11 12:15:00 +01:00
parent ebcf311e3d
commit 88e4ccbfcc
2 changed files with 21 additions and 3 deletions

View File

@ -25,6 +25,8 @@ import {
increaseKeysLimit,
increaseValuesLimit,
} from './actions/tags'
import {ButtonShape, ComponentSize, IconFont} from 'src/reusable_ui/types'
import {Button} from 'src/reusable_ui'
const SEARCH_DEBOUNCE_MS = 400
@ -71,6 +73,7 @@ const TagSelectorBody = (props: Props) => {
onSelectKey,
valuesSearchTerm,
onChangeValuesSearchTerm,
onIncreaseValuesLimit,
onSearchValues,
keysSearchTerm,
onChangeKeysSearchTerm,
@ -110,6 +113,10 @@ const TagSelectorBody = (props: Props) => {
onIncreaseKeysLimit()
debouncer.call(() => onSearchKeys(), SEARCH_DEBOUNCE_MS)
}
function onLoadMoreValues() {
onIncreaseValuesLimit()
debouncer.call(() => onSearchValues(), SEARCH_DEBOUNCE_MS)
}
const placeholderText =
aggregateFunctionType === 'group'
@ -170,12 +177,12 @@ const TagSelectorBody = (props: Props) => {
/>
) : undefined}
</BuilderCard.Menu>
<TagSelectorValues {...props} />
<TagSelectorValues {...props} onLoadMoreValues={onLoadMoreValues} />
</>
)
}
const TagSelectorValues = (props: Props) => {
const TagSelectorValues = (props: Props & {onLoadMoreValues: () => void}) => {
const {
aggregateFunctionType,
keysStatus,
@ -186,6 +193,7 @@ const TagSelectorValues = (props: Props) => {
valuesTruncated,
tagValues: selectedValues,
onSelectValues,
onLoadMoreValues,
} = props
if (aggregateFunctionType === 'filter') {
if (keysStatus === RemoteDataState.NotStarted) {
@ -259,7 +267,16 @@ const TagSelectorValues = (props: Props) => {
})}
{valuesTruncated && aggregateFunctionType === 'filter' ? (
<div className="flux-query-builder--list-item" key={`__truncated`}>
Truncated
<Button
text="Load More Values"
onClick={e => {
e.stopPropagation()
onLoadMoreValues()
}}
size={ComponentSize.ExtraSmall}
shape={ButtonShape.StretchToFit}
icon={IconFont.Plus}
/>
</div>
) : undefined}
</div>

View File

@ -155,6 +155,7 @@ const loadTagSelectorValuesThunk = (
key: tagState.tagKey,
searchTerm: tagState.valuesSearchTerm,
timeRange,
limit: tagState.valuesLimit,
})
values = data.result
valuesTruncated = data.truncated