diff --git a/components/data-grids/firewall-rules-data-grid.tsx b/components/data-grids/firewall-rules-data-grid.tsx index 45a266c5..4d3b0f43 100644 --- a/components/data-grids/firewall-rules-data-grid.tsx +++ b/components/data-grids/firewall-rules-data-grid.tsx @@ -1,12 +1,12 @@ "use client" +import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid" + import { useMemo } from "react" import { type ColumnDef, - getCoreRowModel, - getSortedRowModel, - useReactTable, -} from "@tanstack/react-table-v8" + useTable, +} from "@tanstack/react-table" import type { FirewallRule } from "@/lib/data" import { FormToggle } from "@/components/form-kit" import { cn } from "@/lib/utils" @@ -18,15 +18,15 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" -import { DataGridShell } from "@/components/data-grids/shared/legacy-data-grid-shell" +import { DataGridShell } from "@/components/data-grids/shared/data-grid-shell" import { DATA_GRID_CELL_PAD, DATA_GRID_CELL_PAD_FIRST, DATA_GRID_CELL_PAD_LAST, DATA_GRID_CONTAINER_CLASS, -} from "@/components/data-grids/shared/legacy-data-grid-layout" -import { DataGridSortHeader } from "@/components/data-grids/shared/legacy-data-grid-sort-header" -import { DataGridContainer, DataGridTableDndRowHandle, DataGridTableDndRows } from "@/components/reui/legacy-data-grid" +} from "@/components/data-grids/shared/data-grid-layout" +import { DataGridSortHeader } from "@/components/data-grids/shared/data-grid-sort-header" +import { DataGridContainer, DataGridTableDndRowHandle, DataGridTableDndRows } from "@/components/reui/data-grid" import type { DragEndEvent } from "@dnd-kit/core" import { EmptyState } from "@/components/empty-state" import { @@ -112,7 +112,7 @@ function FirewallRulesDataGrid({ const reorderable = Boolean(onReorder) const indexPad = reorderable ? DATA_GRID_CELL_PAD : DATA_GRID_CELL_PAD_FIRST - const columns = useMemo[]>( + const columns = useMemo[]>( () => [ ...(reorderable ? [{ @@ -125,7 +125,7 @@ function FirewallRulesDataGrid({ headerClassName: DATA_GRID_CELL_PAD_FIRST, cellClassName: DATA_GRID_CELL_PAD_FIRST, }, - } satisfies ColumnDef] + } satisfies ColumnDef] : []), { id: "index", @@ -157,7 +157,7 @@ function FirewallRulesDataGrid({ ), meta: { headerTitle: "Сервер", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD }, - } satisfies ColumnDef] + } satisfies ColumnDef] : []), { id: "chain", @@ -318,11 +318,12 @@ function FirewallRulesDataGrid({ [onEdit, onToggle, onDelete, showServer, reorderable, indexPad], ) - const table = useReactTable({ + const table = useTable({ + features: dataGridFeatures, + manualPagination: true, data: indexedRules, columns, - getCoreRowModel: getCoreRowModel(), - ...(reorderable ? {} : { getSortedRowModel: getSortedRowModel() }), + manualSorting: reorderable, enableSorting: !reorderable, getRowId: (row) => row.id, }) diff --git a/components/data-grids/firewall-scenario-rules-data-grid.tsx b/components/data-grids/firewall-scenario-rules-data-grid.tsx index a45f26ce..a83a4c8c 100644 --- a/components/data-grids/firewall-scenario-rules-data-grid.tsx +++ b/components/data-grids/firewall-scenario-rules-data-grid.tsx @@ -1,18 +1,19 @@ "use client" +import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid" + import { useMemo } from "react" import { type ColumnDef, - getCoreRowModel, - useReactTable, -} from "@tanstack/react-table-v8" + useTable, +} from "@tanstack/react-table" import { ActionBadge, ChainBadge } from "@/components/data-grids/firewall-rules-data-grid" -import { DataGridShell } from "@/components/data-grids/shared/legacy-data-grid-shell" +import { DataGridShell } from "@/components/data-grids/shared/data-grid-shell" import { DATA_GRID_CELL_PAD, DATA_GRID_CELL_PAD_FIRST, DATA_GRID_CELL_PAD_LAST, -} from "@/components/data-grids/shared/legacy-data-grid-layout" +} from "@/components/data-grids/shared/data-grid-layout" import { cn } from "@/lib/utils" import { PowerIcon, Trash2Icon } from "lucide-react" @@ -53,7 +54,7 @@ function FirewallScenarioRulesDataGrid({ [rules], ) - const columns = useMemo[]>( + const columns = useMemo[]>( () => [ { id: "index", @@ -154,7 +155,7 @@ function FirewallScenarioRulesDataGrid({ cell: ({ row }) => { const index = row.original._index - 1 return ( -
+