({ proxyContextValue })
| 113 | }; |
| 114 | |
| 115 | const ProxySettingsSub: FC<ProxySettingsSubProps> = ({ proxyContextValue }) => { |
| 116 | const selectedProxy = proxyContextValue?.proxy.proxy; |
| 117 | const latency = selectedProxy |
| 118 | ? proxyContextValue?.proxyLatencies[selectedProxy?.id] |
| 119 | : undefined; |
| 120 | const [open, setOpen] = useState(false); |
| 121 | |
| 122 | if (!selectedProxy) { |
| 123 | return null; |
| 124 | } |
| 125 | |
| 126 | return ( |
| 127 | <Collapsible open={open} onOpenChange={setOpen}> |
| 128 | <CollapsibleTrigger asChild> |
| 129 | <DropdownMenuItem |
| 130 | className={cn(itemStyles.default, open ? itemStyles.open : "")} |
| 131 | onClick={(e) => { |
| 132 | e.preventDefault(); |
| 133 | setOpen((prev) => !prev); |
| 134 | }} |
| 135 | > |
| 136 | Workspace proxy settings: |
| 137 | <span className="leading-none flex items-center gap-1"> |
| 138 | <ExternalImage |
| 139 | className="w-4 h-4" |
| 140 | src={selectedProxy.icon_url} |
| 141 | alt={selectedProxy.name} |
| 142 | /> |
| 143 | {latency && <Latency latency={latency.latencyMS} />} |
| 144 | </span> |
| 145 | <ChevronRightIcon |
| 146 | className={cn("ml-auto", open ? "rotate-90" : "")} |
| 147 | /> |
| 148 | </DropdownMenuItem> |
| 149 | </CollapsibleTrigger> |
| 150 | <CollapsibleContent> |
| 151 | {proxyContextValue.proxies && |
| 152 | sortProxiesByLatency( |
| 153 | proxyContextValue.proxies, |
| 154 | proxyContextValue.proxyLatencies, |
| 155 | ).map((p) => { |
| 156 | const latency = proxyContextValue.proxyLatencies[p.id]; |
| 157 | return ( |
| 158 | <DropdownMenuItem |
| 159 | className={cn(itemStyles.default, itemStyles.sub)} |
| 160 | key={p.id} |
| 161 | onClick={(e) => { |
| 162 | e.preventDefault(); |
| 163 | |
| 164 | if (!p.healthy) { |
| 165 | toast.error("Failed to select proxy.", { |
| 166 | description: "Please select a healthy workspace proxy.", |
| 167 | }); |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | proxyContextValue.setProxy(p); |
| 172 | setOpen(false); |
nothing calls this directly
no test coverage detected