1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 06:49:40 +02:00

chore(deps): upgrade react-table to v8 [EE-4837] (#8245)

This commit is contained in:
Chaim Lev-Ari 2023-05-02 13:42:16 +07:00 committed by GitHub
parent f20d3e72b9
commit 757461d58b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
140 changed files with 1805 additions and 2872 deletions

View file

@ -1,30 +1,36 @@
import { CellProps, Column } from 'react-table';
import { ColumnDef, CellContext } from '@tanstack/react-table';
import { Link } from '@@/Link';
export function buildNameColumn<T extends Record<string, unknown>>(
nameKey: string,
nameKey: keyof T,
idKey: string,
path: string
) {
const name: Column<T> = {
Header: 'Name',
accessor: (row) => row[nameKey],
): ColumnDef<T> {
const cell = createCell<T>();
return {
header: 'Name',
accessorKey: nameKey,
id: 'name',
Cell: NameCell,
disableFilters: true,
Filter: () => null,
canHide: false,
sortType: 'string',
cell,
enableSorting: true,
sortingFn: 'text',
};
return name;
function createCell<T extends Record<string, unknown>>() {
return function NameCell({ renderValue, row }: CellContext<T, unknown>) {
const name = renderValue() || '';
function NameCell({ value: name, row }: CellProps<T, string>) {
return (
<Link to={path} params={{ id: row.original[idKey] }} title={name}>
{name}
</Link>
);
if (typeof name !== 'string') {
return null;
}
return (
<Link to={path} params={{ id: row.original[idKey] }} title={name}>
{name}
</Link>
);
};
}
}