mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49: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
44
app/react/docker/components/FilesTable/columns/index.ts
Normal file
44
app/react/docker/components/FilesTable/columns/index.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
import {
|
||||
CellContext,
|
||||
ColumnDef,
|
||||
ColumnDefTemplate,
|
||||
} from '@tanstack/react-table';
|
||||
|
||||
import { humanize, isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
|
||||
import { FileData } from '../types';
|
||||
|
||||
import { columnHelper } from './helper';
|
||||
import { NameCell } from './NameCell';
|
||||
import { ActionsCell } from './ActionsCell';
|
||||
|
||||
export const columns = [
|
||||
columnHelper.accessor('Name', {
|
||||
header: 'Name',
|
||||
cell: NameCell,
|
||||
}),
|
||||
columnHelper.accessor('Size', {
|
||||
header: 'Size',
|
||||
cell: hideIfCustom(({ getValue }) => humanize(getValue())),
|
||||
}),
|
||||
columnHelper.accessor('ModTime', {
|
||||
header: 'Last modification',
|
||||
cell: hideIfCustom(({ getValue }) => isoDateFromTimestamp(getValue())),
|
||||
}),
|
||||
columnHelper.display({
|
||||
header: 'Actions',
|
||||
cell: hideIfCustom(ActionsCell),
|
||||
}),
|
||||
columnHelper.accessor('Dir', {}), // workaround, to enable sorting by Dir (put directory first)
|
||||
] as ColumnDef<FileData>[];
|
||||
|
||||
function hideIfCustom<TValue>(
|
||||
template: ColumnDefTemplate<CellContext<FileData, TValue>>
|
||||
): ColumnDefTemplate<CellContext<FileData, TValue>> {
|
||||
return (props) => {
|
||||
if (props.row.original.custom) {
|
||||
return null;
|
||||
}
|
||||
return typeof template === 'string' ? template : template(props);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue