Skip to content

Commit c17a6fb

Browse files
committed
Add conditional pagination
1 parent 3bffbf8 commit c17a6fb

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

redisinsight/ui/src/pages/autodiscover-sentinel/sentinel-databases-result/components/SentinelDatabasesResult/SentinelDatabasesResult.stories.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
} from 'uiSrc/slices/interfaces'
1010
import { ColumnDef } from 'uiSrc/components/base/layout/table'
1111
import { colFactory } from '../../useSentinelDatabasesResultConfig'
12+
import { fn } from 'storybook/test'
13+
import { faker } from '@faker-js/faker'
1214

1315
let mastersMock: ModifiedSentinelMaster[] = [
1416
{
@@ -115,6 +117,64 @@ export const Default: Story = {
115117
render: () => <DefaultRender />,
116118
}
117119

120+
export const WithManyRows: Story = {
121+
render: () => {
122+
const mastersMock: ModifiedSentinelMaster[] = Array.from(
123+
{ length: 100 },
124+
(_, i) => {
125+
const status = Object.values(AddRedisDatabaseStatus)[
126+
Math.floor(
127+
Math.random() * Object.values(AddRedisDatabaseStatus).length,
128+
)
129+
]
130+
return {
131+
name: `mymaster${i}`,
132+
status,
133+
message: faker.lorem.sentence(),
134+
host: faker.internet.ip(),
135+
port: `${faker.internet.port()}`,
136+
numberOfSlaves: Math.floor(Math.random() * 10) + 1,
137+
id: i.toString(),
138+
alias: `mymaster${i}`,
139+
username: '',
140+
password: '',
141+
db: 1,
142+
...(status === AddRedisDatabaseStatus.Fail
143+
? {
144+
error: {
145+
statusCode: 404,
146+
name: 'Not Found',
147+
},
148+
}
149+
: {}),
150+
}
151+
},
152+
)
153+
154+
const columnsMock = colFactory(
155+
fn(),
156+
fn(),
157+
false,
158+
mastersMock.filter((m) => m.status === AddRedisDatabaseStatus.Success)
159+
.length,
160+
mastersMock.length,
161+
)
162+
163+
return (
164+
<SentinelDatabasesResult
165+
onViewDatabases={fn()}
166+
onBack={fn()}
167+
columns={columnsMock}
168+
masters={mastersMock}
169+
countSuccessAdded={
170+
mastersMock.filter((m) => m.status === AddRedisDatabaseStatus.Success)
171+
.length
172+
}
173+
/>
174+
)
175+
},
176+
}
177+
118178
export const AllValid: Story = {
119179
args: {
120180
columns: colFactory(

redisinsight/ui/src/pages/autodiscover-sentinel/sentinel-databases-result/components/SentinelDatabasesResult/SentinelDatabasesResult.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const SentinelDatabasesResult = ({
110110
</Col>
111111
)}
112112
stripedRows
113+
paginationEnabled={items?.length > 10}
113114
/>
114115
)}
115116
</DatabaseWrapper>

0 commit comments

Comments
 (0)