implement datatable sorting on non-analytics tables. (website/board/link/pixel/team/admin)

This commit is contained in:
Francis Cao committed 2026-05-07 10:46:03 -07:00
1 parent b5c4dbfa56
commit 5ccfb6d0a5
39 files changed
+322 -100

No files matched your search

+11 -3
View File
@@ -2,6 +2,7 @@ import { DataColumn, DataTable, Icon, MenuItem, Modal, Row, Text } from '@umami/
import Link from '@/components/common/Link';
import { useState } from 'react';
import { DateDistance } from '@/components/common/DateDistance';
import { SortableLabel } from '@/components/common/SortableLabel';
import { useMessages } from '@/components/hooks';
import { Edit, Trash } from '@/components/icons';
import { MenuButton } from '@/components/input/MenuButton';
@@ -22,10 +23,14 @@ export function UsersTable({
return (
<>
<DataTable data={data} {...props}>
<DataColumn id="username" label={t(labels.username)} width="2fr">
<DataColumn
id="username"
label={<SortableLabel label={t(labels.username)} sortKey="username" />}
width="2fr"
>
{(row: any) => <Link href={`/admin/users/${row.id}`}>{row.username}</Link>}
</DataColumn>
<DataColumn id="role" label={t(labels.role)}>
<DataColumn id="role" label={<SortableLabel label={t(labels.role)} sortKey="role" />}>
{(row: any) =>
t(labels[Object.keys(ROLES).find(key => ROLES[key] === row.role)] || labels.unknown)
}
@@ -33,7 +38,10 @@ export function UsersTable({
<DataColumn id="websites" label={t(labels.websites)}>
{(row: any) => row._count.websites}
</DataColumn>
<DataColumn id="created" label={t(labels.created)}>
<DataColumn
id="created"
label={<SortableLabel label={t(labels.created)} sortKey="createdAt" defaultDirection="desc" />}
>
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
</DataColumn>
{showActions && (