Skip to content

Commit 73e802f

Browse files
committed
Added loading and warning bottom elements for table.
1 parent e776a66 commit 73e802f

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

src/components/tableV2/core/rows.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const Rows = ({
4040

4141
if (!lastItem) return
4242

43-
if (lastItem.index >= rows.length - 1 && hasNextPage && !loading) loadMore()
44-
}, [virtualRows])
43+
if (lastItem.index === rows.length - 1 && hasNextPage && !loading) loadMore()
44+
}, [virtualRows, loading])
4545

4646
const paddingTop = virtualRows.length > 0 ? virtualRows?.[0]?.start || 0 : 0
4747

src/components/tableV2/netdataTable.js

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
useReactTable,
99
} from "@tanstack/react-table"
1010
import Flex from "src/components/templates/flex"
11+
import { Text } from "src/components/typography"
12+
import { IconComponents, Icon } from "src/components/icon"
1113
import { comparison, select, includesString } from "./helpers/filterFns"
1214
import useColumns from "./features/useColumns"
1315
import makePagination from "./features/pagination"
@@ -172,6 +174,8 @@ const NetdataTable = ({
172174
testPrefix,
173175
})
174176

177+
const { hasNextPage, loading, warning } = virtualizeOptions
178+
175179
return (
176180
<TableProvider onHoverCell={onHoverCell}>
177181
<Flex height="100%" overflow="hidden" width="100%" column>
@@ -183,39 +187,53 @@ const NetdataTable = ({
183187
searchValue={globalFilter}
184188
/>
185189
) : null}
186-
<Flex ref={scrollParentRef} overflow="auto" width="100%" height="100%">
187-
{enableColumnPinning && (
188-
<ColumnPinning
190+
<Flex column ref={scrollParentRef} overflow="auto" width="100%" height="100%">
191+
<Flex>
192+
{enableColumnPinning && (
193+
<ColumnPinning
194+
enableResize={enableResize}
195+
disableClickRow={disableClickRow}
196+
onClickRow={onClickRow}
197+
testPrefixCallback={testPrefixCallback}
198+
enableSorting={enableSorting}
199+
table={table}
200+
headers={table.getLeftFlatHeaders()}
201+
testPrefix={testPrefix}
202+
dataGa={dataGa}
203+
scrollParentRef={scrollParentRef}
204+
virtualizeOptions={virtualizeOptions}
205+
coloredSortedColumn={enableSorting && coloredSortedColumn}
206+
/>
207+
)}
208+
<MainTable
209+
scrollParentRef={scrollParentRef}
189210
enableResize={enableResize}
190211
disableClickRow={disableClickRow}
191212
onClickRow={onClickRow}
192213
testPrefixCallback={testPrefixCallback}
193214
enableSorting={enableSorting}
215+
enableColumnPinning={enableColumnPinning}
194216
table={table}
195-
headers={table.getLeftFlatHeaders()}
196-
testPrefix={testPrefix}
197217
dataGa={dataGa}
198-
scrollParentRef={scrollParentRef}
218+
tableRef={tableRef}
219+
testPrefix={testPrefix}
199220
virtualizeOptions={virtualizeOptions}
200221
coloredSortedColumn={enableSorting && coloredSortedColumn}
222+
{...rest}
201223
/>
224+
</Flex>
225+
{!hasNextPage && !loading && !!warning && (
226+
<Flex alignItems="center" justifyContent="center" gap={2} padding={[4]} width="100%">
227+
<Icon name="warning_triangle_hollow" color="warning" />{" "}
228+
<Text color="warningText">{warning}</Text>
229+
</Flex>
230+
)}
231+
232+
{hasNextPage && loading && (
233+
<Flex alignItems="center" justifyContent="center" gap={2} padding={[4]} width="100%">
234+
<IconComponents.LoaderIcon /> <Text>Loading more...</Text>
235+
</Flex>
202236
)}
203-
<MainTable
204-
scrollParentRef={scrollParentRef}
205-
enableResize={enableResize}
206-
disableClickRow={disableClickRow}
207-
onClickRow={onClickRow}
208-
testPrefixCallback={testPrefixCallback}
209-
enableSorting={enableSorting}
210-
enableColumnPinning={enableColumnPinning}
211-
table={table}
212-
dataGa={dataGa}
213-
tableRef={tableRef}
214-
testPrefix={testPrefix}
215-
virtualizeOptions={virtualizeOptions}
216-
coloredSortedColumn={enableSorting && coloredSortedColumn}
217-
{...rest}
218-
/>
219237
</Flex>
220238
{enablePagination && makePagination({ table })}
221239
</Flex>

0 commit comments

Comments
 (0)