fix(docker/container): show exit code in status column if needs [EE-5760] (#10916)

pull/10944/head
Oscar Zhou 2024-01-12 08:21:38 +13:00 committed by GitHub
parent 4e7d1c7088
commit c6505a6647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -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] : '';
}
}