fix(ui): ограничить строки ресурсов мониторинга

This commit is contained in:
Denozordec committed 2026-10-04 02:54:33 +07:00
1 parent 76a5e81fd4
commit 2762f073a0
7 files changed
+93 -13

No files matched your search

@@ -56,14 +56,12 @@ function DataGridShell<TData extends object>({
tableClassNames={tableClassNames}
>
{children ?? (
<>
<DataGridContainer border={false} className={DATA_GRID_CONTAINER_CLASS}>
<DataGridTable />
</DataGridContainer>
{pagination && recordCount > 0 && (
<DataGridPagination className="px-5 pb-3" />
)}
</>
<DataGridContainer border={false} className={DATA_GRID_CONTAINER_CLASS}>
<DataGridTable />
</DataGridContainer>
)}
{pagination && recordCount > 0 && (
<DataGridPagination className="px-5 pb-3" />
)}
</DataGrid>
)
@@ -2,7 +2,7 @@
import { DataGridContainer, DataGridScrollArea, DataGridTable, dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
import { useMemo } from "react"
import { useMemo, useEffect } from "react"
import {
type ColumnDef,
useTable,
@@ -349,12 +349,20 @@ function UptimeResourcesDataGrid({ rows }: UptimeResourcesDataGridProps) {
const table = useTable({
features: dataGridFeatures,
manualPagination: true,
manualPagination: false,
autoResetPageIndex: false,
initialState: { pagination: { pageIndex: 0, pageSize: 50 } },
data: rows,
columns,
getRowId: (row) => row.serverId,
})
const { pageIndex, pageSize } = table.state.pagination
useEffect(() => {
const lastPage = Math.max(0, Math.ceil(rows.length / pageSize) - 1)
if (pageIndex > lastPage) table.setPageIndex(lastPage)
}, [rows.length, pageSize, pageIndex, table])
if (rows.length === 0) {
return (
<EmptyState
@@ -369,6 +377,7 @@ function UptimeResourcesDataGrid({ rows }: UptimeResourcesDataGridProps) {
<DataGridShell
table={table}
recordCount={rows.length}
pagination={rows.length > 50 || table.state.pagination.pageSize !== 50}
tableClassNames={{
headerRow: "border-b border-border bg-muted/30",
bodyRow: cn(