blob: 6bded3af24b0028e5e1354f2c0d89c097a27801a [file] [log] [blame]
gioa2a845c2025-05-08 11:27:14 +00001import { ReactElement } from "react";
2import { SiGithub, SiMongodb, SiPostgresql } from "react-icons/si";
3import { GrServices } from "react-icons/gr";
4import { GoFileDirectoryFill } from "react-icons/go";
5import { TbWorldWww } from "react-icons/tb";
6import { PiNetwork } from "react-icons/pi";
gio69148322025-06-19 23:16:12 +04007import { AiOutlineGlobal } from "react-icons/ai"; // Corrected import source
8import { Bot } from "lucide-react"; // Bot import
gio48679462025-05-21 04:27:27 +00009import { Terminal } from "lucide-react";
10import { z } from "zod";
gio69148322025-06-19 23:16:12 +040011import { AppNode, accessSchema } from "config";
gio5f2f1002025-03-20 18:38:48 +040012
gio0b4002c2025-05-11 15:48:51 +000013type Props = {
gio69148322025-06-19 23:16:12 +040014 node: AppNode | undefined;
gio0b4002c2025-05-11 15:48:51 +000015 className?: string;
16};
17
gio69148322025-06-19 23:16:12 +040018export function Icon({ node, className }: Props): ReactElement {
19 if (!node) {
20 return <></>;
21 }
22 switch (node.type) {
giod0026612025-05-08 13:00:36 +000023 case "app":
gio69148322025-06-19 23:16:12 +040024 if (node.data.type === "sketch:latest") {
25 return <Bot className={className} />;
26 } else {
27 return <GrServices className={className} />;
28 }
giod0026612025-05-08 13:00:36 +000029 case "github":
gio0b4002c2025-05-11 15:48:51 +000030 return <SiGithub className={className} />;
giod0026612025-05-08 13:00:36 +000031 case "gateway-https":
gio0b4002c2025-05-11 15:48:51 +000032 return <TbWorldWww className={className} />;
giod0026612025-05-08 13:00:36 +000033 case "gateway-tcp":
gio0b4002c2025-05-11 15:48:51 +000034 return <PiNetwork className={className} />;
giod0026612025-05-08 13:00:36 +000035 case "mongodb":
gio0b4002c2025-05-11 15:48:51 +000036 return <SiMongodb className={className} />;
giod0026612025-05-08 13:00:36 +000037 case "postgresql":
gio0b4002c2025-05-11 15:48:51 +000038 return <SiPostgresql className={className} />;
giod0026612025-05-08 13:00:36 +000039 case "volume":
gio0b4002c2025-05-11 15:48:51 +000040 return <GoFileDirectoryFill className={className} />;
giod0026612025-05-08 13:00:36 +000041 case "network":
gio0b4002c2025-05-11 15:48:51 +000042 return <AiOutlineGlobal className={className} />;
giod0026612025-05-08 13:00:36 +000043 default:
gio69148322025-06-19 23:16:12 +040044 throw new Error(`MUST NOT REACH! ${node.type}`);
giod0026612025-05-08 13:00:36 +000045 }
46}
gio48679462025-05-21 04:27:27 +000047
48export function AccessType({ type, className }: { type: z.infer<typeof accessSchema>["type"]; className?: string }) {
49 switch (type) {
50 case "https":
51 return <TbWorldWww className={className} />;
52 case "ssh":
53 return <Terminal className={className} />;
54 case "tcp":
55 case "udp":
56 return <PiNetwork className={className} />;
57 case "postgresql":
58 return <SiPostgresql className={className} />;
59 case "mongodb":
60 return <SiMongodb className={className} />;
61 }
62}