mirror of https://github.com/portainer/portainer
fix(docker/container): show exit code in status column if needs [EE-5760] (#10916)
parent
4e7d1c7088
commit
c6505a6647
|
@ -24,6 +24,7 @@ export const state = columnHelper.accessor('Status', {
|
|||
|
||||
function StatusCell({
|
||||
getValue,
|
||||
row: { original: container },
|
||||
}: CellContext<DockerContainer, ContainerStatus>) {
|
||||
const status = getValue();
|
||||
|
||||
|
@ -35,6 +36,13 @@ function StatusCell({
|
|||
|
||||
const statusClassName = getClassName();
|
||||
|
||||
let transformedStatus: ContainerStatus | string = status;
|
||||
if (transformedStatus === ContainerStatus.Exited) {
|
||||
transformedStatus = `${transformedStatus} - code ${extractExitCode(
|
||||
container.StatusText
|
||||
)}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className={clsx('label', `label-${statusClassName}`, {
|
||||
|
@ -42,7 +50,7 @@ function StatusCell({
|
|||
})}
|
||||
title={hasHealthCheck ? 'This container has a health check' : ''}
|
||||
>
|
||||
{status}
|
||||
{transformedStatus}
|
||||
</span>
|
||||
);
|
||||
|
||||
|
@ -64,4 +72,10 @@ function StatusCell({
|
|||
return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
function extractExitCode(statusText: string) {
|
||||
const regex = /\((\d+)\)/;
|
||||
const match = statusText.match(regex);
|
||||
return match ? match[1] : '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue