refactor: extract badgeStateColor function for reuse across log components

This commit is contained in:
faytranevozter
2024-12-27 08:48:36 +07:00
parent 27252cf58d
commit 985b8bc2e0
3 changed files with 4 additions and 30 deletions

View File

@@ -31,7 +31,7 @@ export const DockerLogs = dynamic(
},
);
const badgeStateColor = (state: string) => {
export const badgeStateColor = (state: string) => {
switch (state) {
case "running":
return "green";

View File

@@ -1,3 +1,4 @@
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
import { Badge } from "@/components/ui/badge";
import {
Card,
@@ -36,20 +37,7 @@ interface Props {
serverId?: string;
}
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";
}
};
badgeStateColor;
export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
const [option, setOption] = useState<"swarm" | "native">("native");

View File

@@ -1,3 +1,4 @@
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
import { Badge } from "@/components/ui/badge";
import {
Card,
@@ -36,21 +37,6 @@ interface Props {
appType: "stack" | "docker-compose";
}
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";
}
};
export const ShowDockerLogsCompose = ({
appName,
appType,