mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
refactor(ui/datatables): migrate views to use datatable component [EE-4064] (#7609)
This commit is contained in:
parent
0f0513c684
commit
fe8e834dbf
90 changed files with 1714 additions and 2717 deletions
33
app/react/components/datatables/ExpandableDatatable.tsx
Normal file
33
app/react/components/datatables/ExpandableDatatable.tsx
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { Row } from 'react-table';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { ExpandableDatatableTableRow } from './ExpandableDatatableRow';
|
||||
import { Datatable, Props as DatatableProps } from './Datatable';
|
||||
|
||||
interface Props<D extends Record<string, unknown>>
|
||||
extends Omit<DatatableProps<D>, 'renderRow' | 'expandable'> {
|
||||
renderSubRow(row: Row<D>): ReactNode;
|
||||
}
|
||||
|
||||
export function ExpandableDatatable<D extends Record<string, unknown>>({
|
||||
renderSubRow,
|
||||
...props
|
||||
}: Props<D>) {
|
||||
return (
|
||||
<Datatable<D>
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...props}
|
||||
expandable
|
||||
renderRow={(row, { key, className, role, style }) => (
|
||||
<ExpandableDatatableTableRow<D>
|
||||
key={key}
|
||||
row={row}
|
||||
className={className}
|
||||
role={role}
|
||||
style={style}
|
||||
renderSubRow={renderSubRow}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue