mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
feat(docker): migrate files table to react [EE-4663] (#8916)
This commit is contained in:
parent
146681e1c7
commit
09f60c3277
24 changed files with 529 additions and 229 deletions
|
@ -12,6 +12,7 @@ import {
|
|||
getFacetedMinMaxValues,
|
||||
getExpandedRowModel,
|
||||
TableOptions,
|
||||
TableMeta,
|
||||
} from '@tanstack/react-table';
|
||||
import { ReactNode, useMemo } from 'react';
|
||||
import clsx from 'clsx';
|
||||
|
@ -30,10 +31,11 @@ import { BasicTableSettings } from './types';
|
|||
import { DatatableContent } from './DatatableContent';
|
||||
import { createSelectColumn } from './select-column';
|
||||
import { TableRow } from './TableRow';
|
||||
import { type TableState as GlobalTableState } from './useTableState';
|
||||
|
||||
export interface Props<
|
||||
D extends Record<string, unknown>,
|
||||
TSettings extends BasicTableSettings = BasicTableSettings
|
||||
TMeta extends TableMeta<D> = TableMeta<D>
|
||||
> extends AutomationTestingProps {
|
||||
dataset: D[];
|
||||
columns: TableOptions<D>['columns'];
|
||||
|
@ -53,16 +55,17 @@ export interface Props<
|
|||
highlightedItemId?: string;
|
||||
onPageChange?(page: number): void;
|
||||
|
||||
settingsManager: TSettings & {
|
||||
search: string;
|
||||
setSearch: (value: string) => void;
|
||||
};
|
||||
settingsManager: GlobalTableState<BasicTableSettings>;
|
||||
renderRow?(row: Row<D>, highlightedItemId?: string): ReactNode;
|
||||
getRowCanExpand?(row: Row<D>): boolean;
|
||||
noWidget?: boolean;
|
||||
meta?: TMeta;
|
||||
}
|
||||
|
||||
export function Datatable<D extends Record<string, unknown>>({
|
||||
export function Datatable<
|
||||
D extends Record<string, unknown>,
|
||||
TMeta extends TableMeta<D> = TableMeta<D>
|
||||
>({
|
||||
columns,
|
||||
dataset,
|
||||
renderTableSettings = () => null,
|
||||
|
@ -85,7 +88,8 @@ export function Datatable<D extends Record<string, unknown>>({
|
|||
noWidget,
|
||||
getRowCanExpand,
|
||||
'data-cy': dataCy,
|
||||
}: Props<D>) {
|
||||
meta,
|
||||
}: Props<D, TMeta>) {
|
||||
const isServerSidePagination = typeof pageCount !== 'undefined';
|
||||
const enableRowSelection = getIsSelectionEnabled(
|
||||
disableSelect,
|
||||
|
@ -127,6 +131,7 @@ export function Datatable<D extends Record<string, unknown>>({
|
|||
getExpandedRowModel: getExpandedRowModel(),
|
||||
getRowCanExpand,
|
||||
...(isServerSidePagination ? { manualPagination: true, pageCount } : {}),
|
||||
meta,
|
||||
});
|
||||
|
||||
const tableState = tableInstance.getState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue