1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 15:25:22 +02:00

refactor(edge/jobs): migrate results table to react [EE-4679] (#10663)

This commit is contained in:
Chaim Lev-Ari 2024-04-08 13:18:59 +03:00 committed by GitHub
parent dc9d7ae3f1
commit d88ef03ddb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 223 additions and 139 deletions

View file

@ -0,0 +1,60 @@
import { CellContext, createColumnHelper } from '@tanstack/react-table';
import { Button } from '@@/buttons';
import { LogsStatus } from '../../types';
import { DecoratedJobResult, getTableMeta } from './types';
const columnHelper = createColumnHelper<DecoratedJobResult>();
export const columns = [
columnHelper.accessor('Endpoint.Name', {
header: 'Environment',
meta: {
className: 'w-1/2',
},
}),
columnHelper.display({
header: 'Actions',
cell: ActionsCell,
meta: {
className: 'w-1/2',
},
}),
];
function ActionsCell({
row: { original: item },
table,
}: CellContext<DecoratedJobResult, unknown>) {
const tableMeta = getTableMeta(table.options.meta);
switch (item.LogsStatus) {
case LogsStatus.Pending:
return (
<>
Logs marked for collection, please wait until the logs are available.
</>
);
case LogsStatus.Collected:
return (
<>
<Button onClick={() => tableMeta.downloadLogs(item.EndpointId)}>
Download logs
</Button>
<Button onClick={() => tableMeta.clearLogs(item.EndpointId)}>
Clear logs
</Button>
</>
);
case LogsStatus.Idle:
default:
return (
<Button onClick={() => tableMeta.collectLogs(item.EndpointId)}>
Retrieve logs
</Button>
);
}
}