1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-29 18:29:44 +02:00

fix(pods): represent pod container statuses correctly [r8s-416] (#910)

This commit is contained in:
Ali 2025-07-21 15:05:08 +12:00 committed by GitHub
parent eaa2be017d
commit 55cc250d2e
12 changed files with 996 additions and 61 deletions

View file

@ -1,6 +1,9 @@
import { CellContext } from '@tanstack/react-table';
import { Badge, BadgeType } from '@@/Badge';
import { pluralize } from '@/react/common/string-utils';
import { Badge } from '@@/Badge';
import { Tooltip } from '@@/Tip/Tooltip';
import { ContainerRowData } from '../types';
@ -11,19 +14,24 @@ export const status = columnHelper.accessor('status', {
cell: StatusCell,
});
function StatusCell({ getValue }: CellContext<ContainerRowData, string>) {
return <Badge type={getContainerStatusType(getValue())}>{getValue()}</Badge>;
}
function StatusCell({
getValue,
}: CellContext<ContainerRowData, ContainerRowData['status']>) {
const statusData = getValue();
function getContainerStatusType(status: string): BadgeType {
switch (status.toLowerCase()) {
case 'running':
return 'success';
case 'waiting':
return 'warn';
case 'terminated':
return 'info';
default:
return 'danger';
}
return (
<Badge type={statusData.type}>
<div className="flex items-center gap-1">
<span>
{statusData.status}
{statusData.restartCount &&
` (Restarted ${statusData.restartCount} ${pluralize(
statusData.restartCount,
'time'
)})`}
</span>
</div>
{statusData.message && <Tooltip message={statusData.message} />}
</Badge>
);
}