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) { const status = getStatus(node); const isDeleting = node.metadata?.annotations?.['portainer.io/removing-node'] === 'true'; if (isDeleting) { return Removing; } return (
{status} {node.spec?.unschedulable && ( SchedulingDisabled )}
); } function getStatus(node: NodeRowData) { return ( // only look for the ready type to identify if the node is either ready or not ready node.status?.conditions?.find( (condition) => condition.status === 'True' && condition.type === 'Ready' )?.type ?? 'Not Ready' ); }