2023-10-16 20:19:08 +00:00
|
|
|
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 (
|
2024-04-23 04:16:41 +00:00
|
|
|
<div className="inline-flex whitespace-nowrap gap-x-2">
|
2023-10-16 20:19:08 +00:00
|
|
|
<StatusBadge color={status === 'Ready' ? 'success' : 'warning'}>
|
|
|
|
{status}
|
|
|
|
</StatusBadge>
|
|
|
|
{node.spec?.unschedulable && (
|
2024-04-23 04:16:41 +00:00
|
|
|
<StatusBadge color="warning">SchedulingDisabled</StatusBadge>
|
2023-10-16 20:19:08 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStatus(node: NodeRowData) {
|
|
|
|
return (
|
|
|
|
node.status?.conditions?.find((condition) => condition.status === 'True')
|
|
|
|
?.type ?? 'Not ready'
|
|
|
|
);
|
|
|
|
}
|