(event: React.FormEvent<HTMLFormElement>)
| 306 | }; |
| 307 | |
| 308 | const addProfile = (event: React.FormEvent<HTMLFormElement>): void => { |
| 309 | event.preventDefault(); |
| 310 | const origin = draft.origin.trim(); |
| 311 | if (!origin) { |
| 312 | setError("Enter a server origin."); |
| 313 | return; |
| 314 | } |
| 315 | if (draft.authMode !== "none" && !draft.secret.trim()) { |
| 316 | setError("Enter the credential value."); |
| 317 | return; |
| 318 | } |
| 319 | |
| 320 | const auth = draftAuth(draft); |
| 321 | const input: ExecutorServerConnectionInput = { |
| 322 | kind: "http", |
| 323 | origin, |
| 324 | ...(draft.displayName.trim() ? { displayName: draft.displayName.trim() } : {}), |
| 325 | ...(auth ? { auth } : {}), |
| 326 | }; |
| 327 | const next = upsertExecutorServerProfile(snapshot, input); |
| 328 | const active = next ? getActiveExecutorServerProfile(next) : null; |
| 329 | if (!next || !active) { |
| 330 | setError("Enter a valid http or https origin."); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | setError(null); |
| 335 | setDraft(emptyDraft); |
| 336 | setShowCustomServer(false); |
| 337 | persistSnapshot(next); |
| 338 | setServerConnection(active); |
| 339 | }; |
| 340 | const trigger = |
| 341 | props.variant === "header" ? ( |
| 342 | <Button |
nothing calls this directly
no test coverage detected