fix(ui): перенести таблицы Firewall и проверить порядок правил

This commit is contained in:
Denozordec committed 2026-09-14 13:39:47 +07:00
1 parent 45530cdb99
commit f81b35308b
4 files changed
+154 -23

No files matched your search

@@ -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<ColumnDef<FirewallRule & { _index: number }>[]>(
const columns = useMemo<ColumnDef<DataGridFeatures, FirewallRule & { _index: number }>[]>(
() => [
...(reorderable
? [{
@@ -125,7 +125,7 @@ function FirewallRulesDataGrid({
headerClassName: DATA_GRID_CELL_PAD_FIRST,
cellClassName: DATA_GRID_CELL_PAD_FIRST,
},
} satisfies ColumnDef<FirewallRule & { _index: number }>]
} satisfies ColumnDef<DataGridFeatures, FirewallRule & { _index: number }>]
: []),
{
id: "index",
@@ -157,7 +157,7 @@ function FirewallRulesDataGrid({
</span>
),
meta: { headerTitle: "Сервер", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD },
} satisfies ColumnDef<FirewallRule & { _index: number }>]
} satisfies ColumnDef<DataGridFeatures, FirewallRule & { _index: number }>]
: []),
{
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,
})