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

View File

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