| gio | a2a845c | 2025-05-08 11:27:14 +0000 | [diff] [blame] | 1 | import { ReactElement } from "react"; |
| 2 | import { SiGithub, SiMongodb, SiPostgresql } from "react-icons/si"; |
| 3 | import { GrServices } from "react-icons/gr"; |
| 4 | import { GoFileDirectoryFill } from "react-icons/go"; |
| 5 | import { TbWorldWww } from "react-icons/tb"; |
| 6 | import { PiNetwork } from "react-icons/pi"; |
| gio | cc5ce58 | 2025-06-25 07:45:21 +0400 | [diff] [blame^] | 7 | import { AiOutlineGlobal } from "react-icons/ai"; |
| 8 | import { Bot } from "lucide-react"; |
| gio | 4867946 | 2025-05-21 04:27:27 +0000 | [diff] [blame] | 9 | import { Terminal } from "lucide-react"; |
| gio | cc5ce58 | 2025-06-25 07:45:21 +0400 | [diff] [blame^] | 10 | import { AppNode, Access } from "config"; |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 11 | |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 12 | type Props = { |
| gio | 6914832 | 2025-06-19 23:16:12 +0400 | [diff] [blame] | 13 | node: AppNode | undefined; |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 14 | className?: string; |
| 15 | }; |
| 16 | |
| gio | 6914832 | 2025-06-19 23:16:12 +0400 | [diff] [blame] | 17 | export function Icon({ node, className }: Props): ReactElement { |
| 18 | if (!node) { |
| 19 | return <></>; |
| 20 | } |
| 21 | switch (node.type) { |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 22 | case "app": |
| gio | 6914832 | 2025-06-19 23:16:12 +0400 | [diff] [blame] | 23 | if (node.data.type === "sketch:latest") { |
| 24 | return <Bot className={className} />; |
| 25 | } else { |
| 26 | return <GrServices className={className} />; |
| 27 | } |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 28 | case "github": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 29 | return <SiGithub className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 30 | case "gateway-https": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 31 | return <TbWorldWww className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 32 | case "gateway-tcp": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 33 | return <PiNetwork className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 34 | case "mongodb": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 35 | return <SiMongodb className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 36 | case "postgresql": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 37 | return <SiPostgresql className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 38 | case "volume": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 39 | return <GoFileDirectoryFill className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 40 | case "network": |
| gio | 0b4002c | 2025-05-11 15:48:51 +0000 | [diff] [blame] | 41 | return <AiOutlineGlobal className={className} />; |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 42 | default: |
| gio | 6914832 | 2025-06-19 23:16:12 +0400 | [diff] [blame] | 43 | throw new Error(`MUST NOT REACH! ${node.type}`); |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 44 | } |
| 45 | } |
| gio | 4867946 | 2025-05-21 04:27:27 +0000 | [diff] [blame] | 46 | |
| gio | cc5ce58 | 2025-06-25 07:45:21 +0400 | [diff] [blame^] | 47 | export function AccessType({ access, className }: { access: Access; className?: string }) { |
| 48 | switch (access.type) { |
| gio | 4867946 | 2025-05-21 04:27:27 +0000 | [diff] [blame] | 49 | case "https": |
| gio | cc5ce58 | 2025-06-25 07:45:21 +0400 | [diff] [blame^] | 50 | if (access.agentName) { |
| 51 | return <Bot className={className} />; |
| 52 | } else { |
| 53 | return <TbWorldWww className={className} />; |
| 54 | } |
| gio | 4867946 | 2025-05-21 04:27:27 +0000 | [diff] [blame] | 55 | case "ssh": |
| 56 | return <Terminal className={className} />; |
| 57 | case "tcp": |
| 58 | case "udp": |
| 59 | return <PiNetwork className={className} />; |
| 60 | case "postgresql": |
| 61 | return <SiPostgresql className={className} />; |
| 62 | case "mongodb": |
| 63 | return <SiMongodb className={className} />; |
| 64 | } |
| 65 | } |