From b1171416a720242613a4ca3b7a11d934a5aa215d Mon Sep 17 00:00:00 2001 From: David Crespo Date: Fri, 6 Mar 2026 15:13:07 -0600 Subject: [PATCH] fix transit IPs link + link styling in TextInputHint --- app/forms/instance-create.tsx | 12 ++++------ app/forms/network-interface-edit.tsx | 36 +++++++++++++--------------- app/ui/lib/TextInput.tsx | 17 +++++++------ 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/app/forms/instance-create.tsx b/app/forms/instance-create.tsx index d5f249042..a1872401f 100644 --- a/app/forms/instance-create.tsx +++ b/app/forms/instance-create.tsx @@ -77,7 +77,7 @@ import { PageHeader, PageTitle } from '~/ui/lib/PageHeader' import { RadioCard } from '~/ui/lib/Radio' import { Slash } from '~/ui/lib/Slash' import { Tabs } from '~/ui/lib/Tabs' -import { TextInputHint } from '~/ui/lib/TextInput' +import { HintLink, TextInputHint } from '~/ui/lib/TextInput' import { TipIcon } from '~/ui/lib/TipIcon' import { Tooltip } from '~/ui/lib/Tooltip' import { Wrap } from '~/ui/util/wrap' @@ -1122,12 +1122,8 @@ const PRESETS = [ const UserDataDescription = () => ( <> Data or scripts to be passed to cloud-init as{' '} - - user data - {' '} - - (examples) - {' '} - if the selected boot image supports it. Maximum size 32 KiB. + user data{' '} + (examples) if the selected boot + image supports it. Maximum size 32 KiB. ) diff --git a/app/forms/network-interface-edit.tsx b/app/forms/network-interface-edit.tsx index ea0823cca..8bd206ccd 100644 --- a/app/forms/network-interface-edit.tsx +++ b/app/forms/network-interface-edit.tsx @@ -7,6 +7,7 @@ */ import { useEffect } from 'react' import { useForm } from 'react-hook-form' +import { match } from 'ts-pattern' import { api, @@ -28,7 +29,7 @@ import { FieldLabel } from '~/ui/lib/FieldLabel' import { Message } from '~/ui/lib/Message' import { ClearAndAddButtons, MiniTable } from '~/ui/lib/MiniTable' import { SideModalFormDocs } from '~/ui/lib/ModalLinks' -import { TextInputHint } from '~/ui/lib/TextInput' +import { HintLink, TextInputHint } from '~/ui/lib/TextInput' import { KEYS } from '~/ui/util/keys' import { parseIpNet, validateIpNet } from '~/util/ip' import { docLinks, links } from '~/util/links' @@ -70,16 +71,14 @@ export function EditNetworkInterfaceForm({ // Determine what IP versions this NIC supports const { ipStack } = editing - const supportsV4 = ipStack.type === 'v4' || ipStack.type === 'dual_stack' - const supportsV6 = ipStack.type === 'v6' || ipStack.type === 'dual_stack' - const supportedVersions = - supportsV4 && supportsV6 ? 'both IPv4 and IPv6' : supportsV4 ? 'IPv4' : 'IPv6' - const exampleIPs = - supportsV4 && supportsV6 - ? '192.168.0.0/16 or fd00::/64' - : supportsV4 - ? '192.168.0.0/16' - : 'fd00::/64' + const { supportedVersions, exampleIPs } = match(ipStack.type) + .with('v4', () => ({ supportedVersions: 'IPv4', exampleIPs: '192.168.0.0/16' })) + .with('v6', () => ({ supportedVersions: 'IPv6', exampleIPs: 'fd00::/64' })) + .with('dual_stack', () => ({ + supportedVersions: 'both IPv4 and IPv6', + exampleIPs: '192.168.0.0/16 or fd00::/64', + })) + .exhaustive() const transitIpsForm = useForm({ defaultValues: { transitIp: '' } }) const transitIpValue = transitIpsForm.watch('transitIp') @@ -123,11 +122,8 @@ export function EditNetworkInterfaceForm({ Transit IPs - An IP network, like {exampleIPs}. -
- - Learn more about transit IPs. - + These allow an instance to opt into traffic from a wider address range. Learn + more in the Networking guide.
( -
_a]:text-raise mt-1 [&_>_a]:underline', - className - )} - > +
{children}
) +export type HintLinkProps = { href: string; children: React.ReactNode } + +/** External link styled for use inside a TextInputHint */ +export const HintLink = ({ href, children }: HintLinkProps) => ( + + {children} + +) + export const TextInputError = ({ children }: { children: string }) => { useEffect(() => announce(children, 'assertive'), [children]) return
{children}