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
41
app/react/components/datatables/ExpandableDatatableRow.tsx
Normal file
41
app/react/components/datatables/ExpandableDatatableRow.tsx
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { CSSProperties, ReactNode } from 'react';
|
||||
import { Row } from 'react-table';
|
||||
|
||||
import { TableRow } from './TableRow';
|
||||
|
||||
interface Props<D extends Record<string, unknown>> {
|
||||
row: Row<D>;
|
||||
className?: string;
|
||||
role?: string;
|
||||
style?: CSSProperties;
|
||||
disableSelect?: boolean;
|
||||
renderSubRow(row: Row<D>): ReactNode;
|
||||
}
|
||||
|
||||
export function ExpandableDatatableTableRow<D extends Record<string, unknown>>({
|
||||
row,
|
||||
className,
|
||||
role,
|
||||
style,
|
||||
disableSelect,
|
||||
renderSubRow,
|
||||
}: Props<D>) {
|
||||
return (
|
||||
<>
|
||||
<TableRow<D>
|
||||
cells={row.cells}
|
||||
className={className}
|
||||
role={role}
|
||||
style={style}
|
||||
/>
|
||||
{row.isExpanded && (
|
||||
<tr>
|
||||
{!disableSelect && <td />}
|
||||
<td colSpan={disableSelect ? row.cells.length : row.cells.length - 1}>
|
||||
{renderSubRow(row)}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue