{build === "enterprise" &&
item.showEE &&
!isUnlocked() && (
@@ -251,8 +253,8 @@ export function SidebarNav({
)}
{!isCollapsed && (
<>
-
+
+ {t(item.title)}
{item.isBeta && (
)}
- {build === "enterprise" &&
- item.showEE &&
- !isUnlocked() && (
-
- {t("licenseBadge")}
-
- )}
+ {build === "enterprise" &&
+ item.showEE &&
+ !isUnlocked() && (
+
+ {t("licenseBadge")}
+
+ )}
>
)}
@@ -283,8 +285,8 @@ export function SidebarNav({
{item.icon && (
{item.icon}
)}
-
{t(item.title)}
-
+
+ {t(item.title)}
{item.isBeta && (
)}
- {build === "enterprise" &&
- item.showEE &&
- !isUnlocked() && (
-
- {t("licenseBadge")}
-
- )}
+ {build === "enterprise" &&
+ item.showEE &&
+ !isUnlocked() && (
+
+ {t("licenseBadge")}
+
+ )}
);
@@ -382,23 +384,22 @@ export function SidebarNav({
{childItem.icon}
)}
-
- {t(childItem.title)}
-
- {childItem.isBeta && (
-
- {t("beta")}
-
- )}
+
+ {t(childItem.title)}
+ {childItem.isBeta && (
+
+ {t("beta")}
+
+ )}
+
{build === "enterprise" &&
childItem.showEE &&
!isUnlocked() && (
{t("licenseBadge")}
diff --git a/src/components/UserDevicesTable.tsx b/src/components/UserDevicesTable.tsx
index 0d903c88..256e0a00 100644
--- a/src/components/UserDevicesTable.tsx
+++ b/src/components/UserDevicesTable.tsx
@@ -1,49 +1,23 @@
"use client";
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
-import { DataTablePagination } from "@app/components/DataTablePagination";
-import { Button } from "@app/components/ui/button";
-import { Card, CardContent, CardHeader } from "@app/components/ui/card";
+import { DataTable } from "@app/components/ui/data-table";
import { ExtendedColumnDef } from "@app/components/ui/data-table";
+import { Button } from "@app/components/ui/button";
import {
DropdownMenu,
- DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
DropdownMenuTrigger
} from "@app/components/ui/dropdown-menu";
-import { Input } from "@app/components/ui/input";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow
-} from "@app/components/ui/table";
import { useEnvContext } from "@app/hooks/useEnvContext";
import { toast } from "@app/hooks/useToast";
import { createApiClient, formatAxiosError } from "@app/lib/api";
-import {
- ColumnFiltersState,
- flexRender,
- getCoreRowModel,
- getFilteredRowModel,
- getPaginationRowModel,
- getSortedRowModel,
- SortingState,
- useReactTable
-} from "@tanstack/react-table";
import {
ArrowRight,
ArrowUpDown,
ArrowUpRight,
- Columns,
- MoreHorizontal,
- RefreshCw,
- Search
+ MoreHorizontal
} from "lucide-react";
import { useTranslations } from "next-intl";
import Link from "next/link";
@@ -52,9 +26,6 @@ import { useMemo, useState, useTransition } from "react";
import { Badge } from "./ui/badge";
import { InfoPopup } from "./ui/info-popup";
-import { useStoredColumnVisibility } from "@app/hooks/useStoredColumnVisibility";
-import { useStoredPageSize } from "@app/hooks/useStoredPageSize";
-
export type ClientRow = {
id: number;
name: string;
@@ -80,11 +51,6 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
const router = useRouter();
const t = useTranslations();
- const [userPageSize, setUserPageSize] = useStoredPageSize(
- "user-clients",
- 20
- );
-
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const [selectedClient, setSelectedClient] = useState
(
null
@@ -93,30 +59,23 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
const api = createApiClient(useEnvContext());
const [isRefreshing, startTransition] = useTransition();
- const [userSorting, setUserSorting] = useState([]);
- const [userColumnFilters, setUserColumnFilters] =
- useState([]);
- const [userGlobalFilter, setUserGlobalFilter] = useState([]);
-
const defaultUserColumnVisibility = {
client: false,
subnet: false
};
- const [userColumnVisibility, setUserColumnVisibility] =
- useStoredColumnVisibility("user-clients", defaultUserColumnVisibility);
-
- const refreshData = async () => {
- try {
- router.refresh();
- console.log("Data refreshed");
- } catch (error) {
- toast({
- title: t("error"),
- description: t("refreshError"),
- variant: "destructive"
- });
- }
+ const refreshData = () => {
+ startTransition(() => {
+ try {
+ router.refresh();
+ } catch (error) {
+ toast({
+ title: t("error"),
+ description: t("refreshError"),
+ variant: "destructive"
+ });
+ }
+ });
};
const deleteClient = (clientId: number) => {
@@ -366,73 +325,7 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
baseColumns.push({
id: "actions",
enableHiding: false,
- header: ({ table }) => {
- const hasHideableColumns = table
- .getAllColumns()
- .some((column) => column.getCanHide());
- if (!hasHideableColumns) {
- return ;
- }
- return (
-
-
-
-
-
-
-
- {t("toggleColumns") || "Toggle columns"}
-
-
- {table
- .getAllColumns()
- .filter((column) => column.getCanHide())
- .map((column) => {
- const columnDef =
- column.columnDef as any;
- const friendlyName =
- columnDef.friendlyName;
- const displayName =
- friendlyName ||
- (typeof columnDef.header ===
- "string"
- ? columnDef.header
- : column.id);
- return (
-
- column.toggleVisibility(
- !!value
- )
- }
- onSelect={(e) =>
- e.preventDefault()
- }
- >
- {displayName}
-
- );
- })}
-
-
-
- );
- },
+ header: () => ,
cell: ({ row }) => {
const clientRow = row.original;
return !clientRow.userId ? (
@@ -487,32 +380,6 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
return baseColumns;
}, [hasRowsWithoutUserId, t]);
- const userTable = useReactTable({
- data: userClients || [],
- columns,
- getCoreRowModel: getCoreRowModel(),
- getPaginationRowModel: getPaginationRowModel(),
- onSortingChange: setUserSorting,
- getSortedRowModel: getSortedRowModel(),
- onColumnFiltersChange: setUserColumnFilters,
- getFilteredRowModel: getFilteredRowModel(),
- onGlobalFilterChange: setUserGlobalFilter,
- onColumnVisibilityChange: setUserColumnVisibility,
- initialState: {
- pagination: {
- pageSize: userPageSize,
- pageIndex: 0
- },
- columnVisibility: userColumnVisibility
- },
- state: {
- sorting: userSorting,
- columnFilters: userColumnFilters,
- globalFilter: userGlobalFilter,
- columnVisibility: userColumnVisibility
- }
- });
-
return (
<>
{selectedClient && (
@@ -535,145 +402,20 @@ export default function UserDevicesTable({ userClients }: ClientTableProps) {
/>
)}
-
-
-
-
-
-
- userTable.setGlobalFilter(
- String(e.target.value)
- )
- }
- className="w-full pl-8"
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
- {userTable
- .getHeaderGroups()
- .map((headerGroup) => (
-
- {headerGroup.headers
- .filter((header) =>
- header.column.getIsVisible()
- )
- .map((header) => (
-
- {header.isPlaceholder
- ? null
- : flexRender(
- header
- .column
- .columnDef
- .header,
- header.getContext()
- )}
-
- ))}
-
- ))}
-
-
- {userTable.getRowModel().rows?.length ? (
- userTable
- .getRowModel()
- .rows.map((row) => (
-
- {row
- .getVisibleCells()
- .map((cell) => (
-
- {flexRender(
- cell.column
- .columnDef
- .cell,
- cell.getContext()
- )}
-
- ))}
-
- ))
- ) : (
-
-
- {t("noResults")}
-
-
- )}
-
-
-
-
-
-
-
-
-
+
>
);
}