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:
parent
f20d3e72b9
commit
757461d58b
140 changed files with 1805 additions and 2872 deletions
|
@ -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>
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue