mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 13:25:26 +02:00
refactor(docker/swarm): migrate nodes table to react [EE-4672] (#10184)
This commit is contained in:
parent
fbdbd277f7
commit
bf85a8861d
18 changed files with 210 additions and 255 deletions
|
@ -0,0 +1,38 @@
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import { NodeViewModel } from '@/docker/models/node';
|
||||
|
||||
import { Link } from '@@/Link';
|
||||
|
||||
import { isTableMeta } from '../types';
|
||||
|
||||
import { columnHelper } from './column-helper';
|
||||
|
||||
export const name = columnHelper.accessor('Hostname', {
|
||||
header: 'Name',
|
||||
cell: Cell,
|
||||
});
|
||||
|
||||
function Cell({
|
||||
getValue,
|
||||
row: { original: item },
|
||||
table: {
|
||||
options: { meta },
|
||||
},
|
||||
}: CellContext<NodeViewModel, NodeViewModel['Hostname']>) {
|
||||
if (!isTableMeta(meta)) {
|
||||
throw new Error('Invalid table meta');
|
||||
}
|
||||
|
||||
const value = getValue();
|
||||
|
||||
if (!meta.haveAccessToNode) {
|
||||
return <>{value}</>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link to="docker.nodes.node" params={{ id: item.Id }}>
|
||||
{value}
|
||||
</Link>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue