diff --git a/components/data-grids/gre-tunnels-data-grid.tsx b/components/data-grids/gre-tunnels-data-grid.tsx
index e13216c7..d24524b5 100644
--- a/components/data-grids/gre-tunnels-data-grid.tsx
+++ b/components/data-grids/gre-tunnels-data-grid.tsx
@@ -1,8 +1,8 @@
"use client"
-import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
+import { DataGridContainer, DataGridScrollArea, DataGridTable, dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
-import { useMemo } from "react"
+import { useEffect, useMemo } from "react"
import {
type ColumnDef,
useTable,
@@ -129,6 +129,7 @@ function GreTunnelsDataGrid({
() => [
{
id: "name",
+ size: 160,
accessorKey: "name",
header: ({ column }) => (
@@ -138,7 +139,7 @@ function GreTunnelsDataGrid({
const srv = serverMap.get(t.serverId)
return (
-
{t.name}
+
{t.name}
{srv && }
{srv?.name ?? t.serverId}
@@ -154,6 +155,7 @@ function GreTunnelsDataGrid({
},
{
id: "endpoints",
+ size: 144,
header: () => Эндпоинты,
enableSorting: false,
cell: ({ row }) => {
@@ -175,6 +177,7 @@ function GreTunnelsDataGrid({
},
{
id: "innerIp",
+ size: 136,
header: () => Внутренний IP,
enableSorting: false,
cell: ({ row }) => {
@@ -190,6 +193,7 @@ function GreTunnelsDataGrid({
},
{
id: "pool",
+ size: 96,
accessorKey: "poolId",
header: ({ column }) => ,
cell: ({ row }) => (
@@ -201,6 +205,7 @@ function GreTunnelsDataGrid({
},
{
id: "ipsec",
+ size: 112,
header: () => IPsec,
enableSorting: false,
cell: ({ row }) => ,
@@ -208,6 +213,7 @@ function GreTunnelsDataGrid({
},
{
id: "encryption",
+ size: 160,
header: () => Шифрование,
enableSorting: false,
cell: ({ row }) => {
@@ -236,6 +242,7 @@ function GreTunnelsDataGrid({
},
{
id: "mtu",
+ size: 72,
accessorKey: "mtu",
header: ({ column }) => ,
cell: ({ row }) => (
@@ -249,6 +256,7 @@ function GreTunnelsDataGrid({
},
{
id: "keepalive",
+ size: 104,
header: () => Keepalive,
enableSorting: false,
cell: ({ row }) => {
@@ -263,6 +271,7 @@ function GreTunnelsDataGrid({
},
{
id: "status",
+ size: 112,
accessorKey: "status",
header: ({ column }) => ,
cell: ({ row }) => unknownServerIds?.has(row.original.serverId) ? Неизвестно : ,
@@ -281,9 +290,10 @@ function GreTunnelsDataGrid({
variant="ghost"
size="icon"
className={cn(
- "size-7 opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",
+ "size-11 shrink-0",
)}
title="Предпросмотр кода RouterOS"
+ aria-label={`Просмотр кода: ${t.name}`}
onClick={(e) => {
e.stopPropagation()
onCodePreview(t)
@@ -299,8 +309,8 @@ function GreTunnelsDataGrid({
variant="outline"
size="icon"
className={cn(
- "size-8 shrink-0 border-border/60 bg-background/80 text-muted-foreground shadow-none",
- "opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100",
+ "size-11 shrink-0 border-border/60 bg-background/80 text-muted-foreground shadow-none",
+ "opacity-100",
"data-popup-open:opacity-100",
)}
aria-label={`Действия: ${t.name}`}
@@ -338,7 +348,7 @@ function GreTunnelsDataGrid({
)
},
- size: 88,
+ size: 112,
meta: { headerClassName: DATA_GRID_CELL_PAD_LAST, cellClassName: DATA_GRID_CELL_PAD_LAST },
},
],
@@ -347,12 +357,20 @@ function GreTunnelsDataGrid({
const table = useTable({
features: dataGridFeatures,
- manualPagination: true,
+ manualPagination: false,
+ autoResetPageIndex: false,
+ initialState: { pagination: { pageIndex: 0, pageSize: 50 }, columnPinning: { start: ["name"], end: [] } },
data: tunnels,
columns,
getRowId: row => JSON.stringify([row.serverId, row.id]),
})
+ const { pageIndex, pageSize } = table.state.pagination
+ useEffect(() => {
+ const lastPage = Math.max(0, Math.ceil(tunnels.length / pageSize) - 1)
+ if (pageIndex > lastPage) table.setPageIndex(lastPage)
+ }, [tunnels.length, pageIndex, pageSize, table])
+
if (tunnels.length === 0) {
return (