Skip to content

Commit 5dc8507

Browse files
authored
Merge pull request #2675 from RedisInsight/fe/bugfix/RI-5003-fix-non-zero-scan-cursor
#RI-5003 show scan more always when next cursor is non-zero
2 parents 3db811f + 8345293 commit 5dc8507

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

redisinsight/ui/src/components/keys-summary/KeysSummary.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const KeysSummary = (props: Props) => {
3535

3636
const resultsLength = items.length
3737
const scannedDisplay = resultsLength > scanned ? resultsLength : scanned
38+
const notAccurateScanned = totalItemsCount
39+
&& scanned >= totalItemsCount
40+
&& nextCursor
41+
&& nextCursor !== '0'
42+
? '~' : ''
3843

3944
return (
4045
<>
@@ -51,7 +56,7 @@ const KeysSummary = (props: Props) => {
5156
</b>
5257
<EuiTextColor color="subdued">
5358
{'Scanned '}
54-
<span data-testid="keys-number-of-scanned">{numberWithSpaces(scannedDisplay)}</span>
59+
<span data-testid="keys-number-of-scanned">{notAccurateScanned}{numberWithSpaces(scannedDisplay)}</span>
5560
{' / '}
5661
<span data-testid="keys-total">{nullableNumberWithSpaces(totalItemsCount)}</span>
5762
<span

redisinsight/ui/src/components/scan-more/ScanMore.spec.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('ScanMore', () => {
1414
const handleClick = jest.fn()
1515

1616
const renderer = render(
17-
<ScanMore {...instance(mockedProps)} loadMoreItems={handleClick} totalItemsCount={1} />
17+
<ScanMore {...instance(mockedProps)} loadMoreItems={handleClick} scanned={1} totalItemsCount={2} />
1818
)
1919

2020
expect(renderer).toBeTruthy()
@@ -23,9 +23,17 @@ describe('ScanMore', () => {
2323
expect(handleClick).toHaveBeenCalledTimes(1)
2424
})
2525

26-
it('should button be hidden when totalItemsCount < scanned ', () => {
26+
it('should show button when totalItemsCount < scanned and nextCursor is not zero', () => {
2727
const { queryByTestId } = render(
28-
<ScanMore {...instance(mockedProps)} scanned={2} totalItemsCount={1} />
28+
<ScanMore {...instance(mockedProps)} scanned={2} totalItemsCount={1} nextCursor="123" />
29+
)
30+
31+
expect(queryByTestId('scan-more')).toBeInTheDocument()
32+
})
33+
34+
it('should hide button when totalItemsCount < scanned and nextCursor is zero', () => {
35+
const { queryByTestId } = render(
36+
<ScanMore {...instance(mockedProps)} scanned={2} totalItemsCount={1} nextCursor="0" />
2937
)
3038

3139
expect(queryByTestId('scan-more')).not.toBeInTheDocument()

redisinsight/ui/src/components/scan-more/ScanMore.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ScanMore = ({
3131
nextCursor,
3232
}: Props) => (
3333
<>
34-
{((scanned < totalItemsCount || isNull(totalItemsCount)))
34+
{((scanned || isNull(totalItemsCount)))
3535
&& nextCursor !== '0'
3636
&& (
3737
<EuiButton

redisinsight/ui/src/components/virtual-table/VirtualTable.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ describe('VirtualTable', () => {
161161

162162
expect(scanMoreBtn).toBeInTheDocument()
163163
})
164-
it('Scan more button should no be in the document when total == scanned', () => {
164+
// obsolete test. todo: review and remove or refactor
165+
xit('Scan more button should no be in the document when total == scanned', () => {
165166
const { queryByTestId } = render(
166167
<VirtualTable
167168
{...instance(mockedProps)}

0 commit comments

Comments
 (0)