feat: add badge component to display container state with color coding

This commit is contained in:
faytranevozter
2024-12-27 01:44:46 +07:00
parent f69fb7684b
commit 27252cf58d
3 changed files with 66 additions and 5 deletions
@@ -1,3 +1,4 @@
import { Badge } from "@/components/ui/badge";
import {
Card,
CardContent,
@@ -30,6 +31,21 @@ export const DockerLogs = dynamic(
},
);
const badgeStateColor = (state: string) => {
switch (state) {
case "running":
return "green";
case "exited":
case "shutdown":
return "red";
case "accepted":
case "created":
return "blue";
default:
return "default";
}
};
interface Props {
appName: string;
serverId?: string;
@@ -123,7 +139,9 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
value={container.containerId}
>
{container.name} ({container.containerId}){" "}
{container.state}
<Badge variant={badgeStateColor(container.state)}>
{container.state}
</Badge>
</SelectItem>
))}
</div>
@@ -135,7 +153,10 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
value={container.containerId}
>
{container.name} ({container.containerId}@{container.node}
) {container.state}
)
<Badge variant={badgeStateColor(container.state)}>
{container.state}
</Badge>
</SelectItem>
))}
</>