implement datatable sorting on non-analytics tables. (website/board/link/pixel/team/admin)
This commit is contained in:
1 parent
b5c4dbfa56
commit
5ccfb6d0a5
39 files changed
+322
-100
No files matched your search
@@ -2,6 +2,7 @@ import { DataColumn, DataTable, type DataTableProps, Row } from '@umami/react-ze
|
||||
import Link from '@/components/common/Link';
|
||||
import { DateDistance } from '@/components/common/DateDistance';
|
||||
import { ExternalLink } from '@/components/common/ExternalLink';
|
||||
import { SortableLabel } from '@/components/common/SortableLabel';
|
||||
import { useMessages, useNavigation, useSlug } from '@/components/hooks';
|
||||
import { LinkDeleteButton } from './LinkDeleteButton';
|
||||
import { LinkEditButton } from './LinkEditButton';
|
||||
@@ -17,23 +18,27 @@ export function LinksTable({ showActions, ...props }: LinksTableProps) {
|
||||
|
||||
return (
|
||||
<DataTable {...props}>
|
||||
<DataColumn id="name" label={t(labels.name)}>
|
||||
<DataColumn id="name" label={<SortableLabel label={t(labels.name)} sortKey="name" />}>
|
||||
{({ id, name }: any) => {
|
||||
return <Link href={renderUrl(`/links/${id}`)}>{name}</Link>;
|
||||
}}
|
||||
</DataColumn>
|
||||
<DataColumn id="slug" label={t(labels.link)}>
|
||||
<DataColumn id="slug" label={<SortableLabel label={t(labels.link)} sortKey="slug" />}>
|
||||
{({ slug }: any) => {
|
||||
const url = getSlugUrl(slug);
|
||||
return <ExternalLink href={url}>{url}</ExternalLink>;
|
||||
}}
|
||||
</DataColumn>
|
||||
<DataColumn id="url" label={t(labels.destinationUrl)}>
|
||||
<DataColumn id="url" label={<SortableLabel label={t(labels.destinationUrl)} sortKey="url" />}>
|
||||
{({ url }: any) => {
|
||||
return <ExternalLink href={url}>{url}</ExternalLink>;
|
||||
}}
|
||||
</DataColumn>
|
||||
<DataColumn id="created" label={t(labels.created)} width="200px">
|
||||
<DataColumn
|
||||
id="created"
|
||||
label={<SortableLabel label={t(labels.created)} sortKey="createdAt" defaultDirection="desc" />}
|
||||
width="200px"
|
||||
>
|
||||
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
|
||||
</DataColumn>
|
||||
{showActions && (
|
||||
|
||||
Reference in new issue
Block a user