Readd possibility to add containers as apps to boards (#1276)

This commit is contained in:
Meier Lukas
2023-09-10 14:28:13 +02:00
committed by GitHub
parent f35f6debaf
commit d05c0023cd
13 changed files with 266 additions and 123 deletions

View File

@@ -0,0 +1,53 @@
import { Badge, BadgeProps, MantineSize } from '@mantine/core';
import Dockerode from 'dockerode';
import { useTranslation } from 'next-i18next';
export interface ContainerStateProps {
state: Dockerode.ContainerInfo['State'];
}
export default function ContainerState(props: ContainerStateProps) {
const { state } = props;
const { t } = useTranslation('modules/docker');
const options: {
size: MantineSize;
radius: MantineSize;
variant: BadgeProps['variant'];
} = {
size: 'md',
radius: 'md',
variant: 'outline',
};
switch (state) {
case 'running': {
return (
<Badge color="green" {...options}>
{t('table.states.running')}
</Badge>
);
}
case 'created': {
return (
<Badge color="cyan" {...options}>
{t('table.states.created')}
</Badge>
);
}
case 'exited': {
return (
<Badge color="red" {...options}>
{t('table.states.stopped')}
</Badge>
);
}
default: {
return (
<Badge color="purple" {...options}>
{t('table.states.unknown')}
</Badge>
);
}
}
}