|
1 | 1 | import packageJson from "../package.json" |
2 | 2 |
|
3 | | -import { Box, Grid, Text } from "@radix-ui/themes" |
| 3 | +import { Box, Grid, Text, Popover, IconButton } from "@radix-ui/themes" |
4 | 4 | import { useApplicationData } from "./hooks/useApplicationData.js" |
| 5 | +import { LuUnplug } from "react-icons/lu" |
| 6 | + |
| 7 | +const ConnectionPopover = ({ children }: { children: React.ReactNode }) => { |
| 8 | + return ( |
| 9 | + <Popover.Root> |
| 10 | + <Popover.Trigger> |
| 11 | + <IconButton |
| 12 | + variant="ghost" |
| 13 | + color="gray" |
| 14 | + radius="full" |
| 15 | + size="1" |
| 16 | + style={{ position: "relative", top: "3px", left: "-1px" }} |
| 17 | + > |
| 18 | + <LuUnplug color="#6f6f6f" /> |
| 19 | + </IconButton> |
| 20 | + </Popover.Trigger> |
| 21 | + <Popover.Content> |
| 22 | + <Text size="2">{children}</Text> |
| 23 | + </Popover.Content> |
| 24 | + </Popover.Root> |
| 25 | + ) |
| 26 | +} |
5 | 27 |
|
6 | 28 | export const ApplicationDataBox = () => { |
7 | 29 | const applicationInfo = useApplicationData() |
8 | 30 |
|
9 | 31 | return ( |
10 | 32 | <Box mt="auto"> |
11 | 33 | <Text size="2"> |
12 | | - <Grid |
13 | | - columns="auto auto" |
14 | | - px="3" |
15 | | - py="3" |
16 | | - width="auto" |
17 | | - gapX="4" |
18 | | - > |
19 | | - <Text weight="bold">Status</Text> <Text color="gray">{applicationInfo ? "Connected" : "Offline"}</Text> |
20 | | - <Text weight="bold">Topic</Text> |
21 | | - <Text color="gray" wrap="nowrap">{applicationInfo ? applicationInfo.topic : "-"}</Text> |
| 34 | + <Grid columns="auto auto" px="3" py="3" width="auto" gapX="4"> |
| 35 | + <Text weight="bold">Upstream</Text>{" "} |
| 36 | + <Text color="gray"> |
| 37 | + {!applicationInfo && <Text color="gray">Offline</Text>} |
| 38 | + {Object.keys(applicationInfo?.networkConfig || {}).length > 0 && ( |
| 39 | + <Text color="gray"> |
| 40 | + libp2p{" "} |
| 41 | + <ConnectionPopover> |
| 42 | + {applicationInfo?.networkConfig.bootstrapList && ( |
| 43 | + <Box>Bootstrap: {JSON.stringify(applicationInfo?.networkConfig.bootstrapList)}</Box> |
| 44 | + )} |
| 45 | + {applicationInfo?.networkConfig.listen && ( |
| 46 | + <Box>Listen: {JSON.stringify(applicationInfo?.networkConfig.listen)}</Box> |
| 47 | + )} |
| 48 | + {applicationInfo?.networkConfig.announce && ( |
| 49 | + <Box>Announce: {JSON.stringify(applicationInfo?.networkConfig.announce)}</Box> |
| 50 | + )} |
| 51 | + </ConnectionPopover> |
| 52 | + </Text> |
| 53 | + )} |
| 54 | + {applicationInfo?.wsConfig.listen && <Text color="gray">Accepting connections</Text>} |
| 55 | + {applicationInfo?.wsConfig.connect && ( |
| 56 | + <Text color="gray"> |
| 57 | + WebSocket <ConnectionPopover>{applicationInfo?.wsConfig.connect}</ConnectionPopover> |
| 58 | + </Text> |
| 59 | + )} |
| 60 | + {Object.keys(applicationInfo?.networkConfig || {}).length === 0 && |
| 61 | + !applicationInfo?.wsConfig.listen && |
| 62 | + !applicationInfo?.wsConfig.connect && <Text color="gray">No connection</Text>} |
| 63 | + </Text> |
| 64 | + <Text weight="bold">Topic</Text> |
| 65 | + <Text color="gray" wrap="nowrap"> |
| 66 | + {applicationInfo ? applicationInfo.topic : "-"} |
| 67 | + </Text> |
22 | 68 | <Text weight="bold">Database</Text>{" "} |
23 | 69 | <Text color="gray">{applicationInfo ? applicationInfo.database : "-"}</Text> |
24 | 70 | <Text weight="bold">Version</Text> <Text color="gray">v{packageJson.version}</Text> |
|
0 commit comments