2022-06-27 19:25:26 +02:00
|
|
|
import { Badge, BadgeVariant, MantineSize } from '@mantine/core';
|
2022-08-22 09:50:54 +02:00
|
|
|
import { useTranslation } from 'next-i18next';
|
2022-06-27 19:25:26 +02:00
|
|
|
import Dockerode from 'dockerode';
|
|
|
|
|
|
|
|
|
|
export interface ContainerStateProps {
|
|
|
|
|
state: Dockerode.ContainerInfo['State'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function ContainerState(props: ContainerStateProps) {
|
|
|
|
|
const { state } = props;
|
2022-08-22 09:50:54 +02:00
|
|
|
|
2022-08-25 11:07:25 +02:00
|
|
|
const { t } = useTranslation('modules/docker');
|
2022-08-22 09:50:54 +02:00
|
|
|
|
2022-06-27 19:25:26 +02:00
|
|
|
const options: {
|
|
|
|
|
size: MantineSize;
|
|
|
|
|
radius: MantineSize;
|
|
|
|
|
variant: BadgeVariant;
|
|
|
|
|
} = {
|
|
|
|
|
size: 'md',
|
|
|
|
|
radius: 'md',
|
|
|
|
|
variant: 'outline',
|
|
|
|
|
};
|
|
|
|
|
switch (state) {
|
|
|
|
|
case 'running': {
|
|
|
|
|
return (
|
|
|
|
|
<Badge color="green" {...options}>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('table.states.running')}
|
2022-06-27 19:25:26 +02:00
|
|
|
</Badge>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
case 'created': {
|
|
|
|
|
return (
|
|
|
|
|
<Badge color="cyan" {...options}>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('table.states.created')}
|
2022-06-27 19:25:26 +02:00
|
|
|
</Badge>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
case 'exited': {
|
|
|
|
|
return (
|
|
|
|
|
<Badge color="red" {...options}>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('table.states.stopped')}
|
2022-06-27 19:25:26 +02:00
|
|
|
</Badge>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
return (
|
|
|
|
|
<Badge color="purple" {...options}>
|
2022-08-22 09:50:54 +02:00
|
|
|
{t('table.states.unknown')}
|
2022-06-27 19:25:26 +02:00
|
|
|
</Badge>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|