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({
|
function StatusCell({
|
||||||
getValue,
|
getValue,
|
||||||
|
row: { original: container },
|
||||||
}: CellContext<DockerContainer, ContainerStatus>) {
|
}: CellContext<DockerContainer, ContainerStatus>) {
|
||||||
const status = getValue();
|
const status = getValue();
|
||||||
|
|
||||||
|
@ -35,6 +36,13 @@ function StatusCell({
|
||||||
|
|
||||||
const statusClassName = getClassName();
|
const statusClassName = getClassName();
|
||||||
|
|
||||||
|
let transformedStatus: ContainerStatus | string = status;
|
||||||
|
if (transformedStatus === ContainerStatus.Exited) {
|
||||||
|
transformedStatus = `${transformedStatus} - code ${extractExitCode(
|
||||||
|
container.StatusText
|
||||||
|
)}`;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={clsx('label', `label-${statusClassName}`, {
|
className={clsx('label', `label-${statusClassName}`, {
|
||||||
|
@ -42,7 +50,7 @@ function StatusCell({
|
||||||
})}
|
})}
|
||||||
title={hasHealthCheck ? 'This container has a health check' : ''}
|
title={hasHealthCheck ? 'This container has a health check' : ''}
|
||||||
>
|
>
|
||||||
{status}
|
{transformedStatus}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -64,4 +72,10 @@ function StatusCell({
|
||||||
return 'success';
|
return 'success';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractExitCode(statusText: string) {
|
||||||
|
const regex = /\((\d+)\)/;
|
||||||
|
const match = statusText.match(regex);
|
||||||
|
return match ? match[1] : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue