mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 14:29:40 +02:00
refactor(cluster): migrate nodes datatable to react [EE-4962] (#10459)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
b346fd7f39
commit
0e47f22c0a
25 changed files with 448 additions and 219 deletions
|
@ -0,0 +1,44 @@
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import { StatusBadge } from '@@/StatusBadge';
|
||||
|
||||
import { NodeRowData } from '../types';
|
||||
|
||||
import { columnHelper } from './helper';
|
||||
|
||||
export const status = columnHelper.accessor((row) => getStatus(row), {
|
||||
header: 'Status',
|
||||
cell: StatusCell,
|
||||
});
|
||||
|
||||
function StatusCell({
|
||||
row: { original: node },
|
||||
}: CellContext<NodeRowData, string>) {
|
||||
const status = getStatus(node);
|
||||
|
||||
const isDeleting =
|
||||
node.metadata?.annotations?.['portainer.io/removing-node'] === 'true';
|
||||
if (isDeleting) {
|
||||
return <StatusBadge color="warning">Removing</StatusBadge>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="whitespace-nowrap">
|
||||
<StatusBadge color={status === 'Ready' ? 'success' : 'warning'}>
|
||||
{status}
|
||||
</StatusBadge>
|
||||
{node.spec?.unschedulable && (
|
||||
<StatusBadge color="warning" className="mt-2">
|
||||
SchedulingDisabled
|
||||
</StatusBadge>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function getStatus(node: NodeRowData) {
|
||||
return (
|
||||
node.status?.conditions?.find((condition) => condition.status === 'True')
|
||||
?.type ?? 'Not ready'
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue