|
| 1 | +import { type JSX } from 'react'; |
| 2 | +import { clsx } from 'clsx'; |
| 3 | +import { ServerIcon, CpuChipIcon, CircleStackIcon, ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline'; |
| 4 | + |
| 5 | +import { Dialog } from '@/components/Overlays/Dialog'; |
| 6 | +import { getClusterSpec, CLUSTER_COLORS } from '@/constants/eip7870'; |
| 7 | +import type { ClusterSpecsModalProps } from './ClusterSpecsModal.types'; |
| 8 | + |
| 9 | +/** |
| 10 | + * Modal displaying detailed hardware specifications for an EIP-7870 reference node cluster. |
| 11 | + */ |
| 12 | +export function ClusterSpecsModal({ open, onClose, clusterName }: ClusterSpecsModalProps): JSX.Element { |
| 13 | + const cluster = clusterName ? getClusterSpec(clusterName) : null; |
| 14 | + const clusterColor = clusterName ? CLUSTER_COLORS[clusterName] : 'text-muted'; |
| 15 | + |
| 16 | + if (!cluster) { |
| 17 | + return ( |
| 18 | + <Dialog open={open} onClose={onClose} title="Unknown Cluster" size="sm"> |
| 19 | + <p className="text-sm text-muted">No hardware specifications found for this cluster.</p> |
| 20 | + </Dialog> |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + return ( |
| 25 | + <Dialog |
| 26 | + open={open} |
| 27 | + onClose={onClose} |
| 28 | + title={ |
| 29 | + <span className="flex items-center gap-2"> |
| 30 | + <ServerIcon className={clsx('size-5', clusterColor)} /> |
| 31 | + <span>{cluster.name} cluster</span> |
| 32 | + <span className="rounded-xs bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent">EIP-7870</span> |
| 33 | + </span> |
| 34 | + } |
| 35 | + size="md" |
| 36 | + > |
| 37 | + <div className="space-y-4"> |
| 38 | + {/* CPU Section */} |
| 39 | + <div className="rounded-xs border border-border bg-surface/50 p-4"> |
| 40 | + <div className="mb-3 flex items-center gap-2"> |
| 41 | + <CpuChipIcon className="size-4 text-muted" /> |
| 42 | + <span className="text-sm font-medium text-foreground">CPU</span> |
| 43 | + </div> |
| 44 | + <div className="space-y-2 text-sm"> |
| 45 | + <div className="flex justify-between"> |
| 46 | + <span className="text-muted">Model</span> |
| 47 | + <span className="font-medium text-foreground">{cluster.cpu.model}</span> |
| 48 | + </div> |
| 49 | + <div className="flex justify-between"> |
| 50 | + <span className="text-muted">Cores / Threads</span> |
| 51 | + <span className="font-medium text-foreground"> |
| 52 | + {cluster.cpu.cores}c / {cluster.cpu.threads}t |
| 53 | + </span> |
| 54 | + </div> |
| 55 | + <div className="flex justify-between"> |
| 56 | + <span className="text-muted">Max Frequency</span> |
| 57 | + <span className="font-medium text-foreground">{cluster.cpu.maxFrequency}</span> |
| 58 | + </div> |
| 59 | + <div className="flex justify-between"> |
| 60 | + <span className="text-muted">Passmark (Single / Multi)</span> |
| 61 | + <span className="font-medium text-foreground"> |
| 62 | + {cluster.cpu.passmarkSingle} / {cluster.cpu.passmarkMulti} |
| 63 | + </span> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + |
| 68 | + {/* Memory Section */} |
| 69 | + <div className="rounded-xs border border-border bg-surface/50 p-4"> |
| 70 | + <div className="mb-3 flex items-center gap-2"> |
| 71 | + <svg className="size-4 text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}> |
| 72 | + <path |
| 73 | + strokeLinecap="round" |
| 74 | + strokeLinejoin="round" |
| 75 | + d="M8 9h8M8 13h6M3 17V7a2 2 0 012-2h14a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2z" |
| 76 | + /> |
| 77 | + </svg> |
| 78 | + <span className="text-sm font-medium text-foreground">Memory</span> |
| 79 | + </div> |
| 80 | + <div className="space-y-2 text-sm"> |
| 81 | + <div className="flex justify-between"> |
| 82 | + <span className="text-muted">Total</span> |
| 83 | + <span className="font-medium text-foreground">{cluster.memory.total}</span> |
| 84 | + </div> |
| 85 | + <div className="flex justify-between"> |
| 86 | + <span className="text-muted">Type</span> |
| 87 | + <span className="font-medium text-foreground">{cluster.memory.type}</span> |
| 88 | + </div> |
| 89 | + <div className="flex justify-between"> |
| 90 | + <span className="text-muted">Speed</span> |
| 91 | + <span className="font-medium text-foreground">{cluster.memory.speed}</span> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + |
| 96 | + {/* Storage Section */} |
| 97 | + <div className="rounded-xs border border-border bg-surface/50 p-4"> |
| 98 | + <div className="mb-3 flex items-center gap-2"> |
| 99 | + <CircleStackIcon className="size-4 text-muted" /> |
| 100 | + <span className="text-sm font-medium text-foreground">Storage</span> |
| 101 | + </div> |
| 102 | + <div className="space-y-2 text-sm"> |
| 103 | + <div className="flex justify-between"> |
| 104 | + <span className="text-muted">Model</span> |
| 105 | + <span className="font-medium text-foreground">{cluster.storage.model}</span> |
| 106 | + </div> |
| 107 | + <div className="flex justify-between"> |
| 108 | + <span className="text-muted">Capacity</span> |
| 109 | + <span className="font-medium text-foreground">{cluster.storage.capacity}</span> |
| 110 | + </div> |
| 111 | + <div className="flex justify-between"> |
| 112 | + <span className="text-muted">Interface</span> |
| 113 | + <span className="font-medium text-foreground">{cluster.storage.interface}</span> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + </div> |
| 117 | + |
| 118 | + {/* Footer info */} |
| 119 | + <div className="flex items-center justify-between border-t border-border pt-4"> |
| 120 | + <p className="text-xs text-muted">Reference nodes controlled by ethPandaOps</p> |
| 121 | + <a |
| 122 | + href="https://eips.ethereum.org/EIPS/eip-7870" |
| 123 | + target="_blank" |
| 124 | + rel="noopener noreferrer" |
| 125 | + className="flex items-center gap-1 text-xs text-accent hover:underline" |
| 126 | + > |
| 127 | + View EIP-7870 |
| 128 | + <ArrowTopRightOnSquareIcon className="size-3" /> |
| 129 | + </a> |
| 130 | + </div> |
| 131 | + </div> |
| 132 | + </Dialog> |
| 133 | + ); |
| 134 | +} |
0 commit comments