@@ -20,15 +20,19 @@ import {
2020import { DescriptionField } from '~/components/form/fields/DescriptionField'
2121import { NameField } from '~/components/form/fields/NameField'
2222import { TextFieldInner } from '~/components/form/fields/TextField'
23+ import { FormMetadata } from '~/components/form/FormMetadata'
2324import { SideModalForm } from '~/components/form/SideModalForm'
2425import { HL } from '~/components/HL'
2526import { useInstanceSelector } from '~/hooks/use-params'
2627import { addToast } from '~/stores/toast'
28+ import { SubnetNameFromId } from '~/table/cells/SubnetNameCell'
29+ import { CopyableIp } from '~/ui/lib/CopyableIp'
2730import { FormDivider } from '~/ui/lib/Divider'
2831import { FieldLabel } from '~/ui/lib/FieldLabel'
2932import { Message } from '~/ui/lib/Message'
3033import { ClearAndAddButtons , MiniTable } from '~/ui/lib/MiniTable'
3134import { SideModalFormDocs } from '~/ui/lib/ModalLinks'
35+ import { PropertiesTable } from '~/ui/lib/PropertiesTable'
3236import { HintLink , TextInputHint } from '~/ui/lib/TextInput'
3337import { KEYS } from '~/ui/util/keys'
3438import { parseIpNet , validateIpNet } from '~/util/ip'
@@ -56,23 +60,29 @@ export function EditNetworkInterfaceForm({
5660 } ,
5761 } )
5862
59- // Extract transitIps from ipStack for the form
60- const extractedTransitIps =
61- editing . ipStack . type === 'dual_stack'
62- ? [ ...editing . ipStack . value . v4 . transitIps , ...editing . ipStack . value . v6 . transitIps ]
63- : editing . ipStack . value . transitIps
63+ // A NIC has an IPv4 stack, an IPv6 stack, or both
64+ const { ipStack } = editing
65+ const v4 = match ( ipStack )
66+ . with ( { type : 'v4' } , ( { value } ) => value )
67+ . with ( { type : 'dual_stack' } , ( { value } ) => value . v4 )
68+ . with ( { type : 'v6' } , ( ) => null )
69+ . exhaustive ( )
70+ const v6 = match ( ipStack )
71+ . with ( { type : 'v6' } , ( { value } ) => value )
72+ . with ( { type : 'dual_stack' } , ( { value } ) => value . v6 )
73+ . with ( { type : 'v4' } , ( ) => null )
74+ . exhaustive ( )
6475
6576 const defaultValues = {
6677 name : editing . name ,
6778 description : editing . description ,
68- transitIps : extractedTransitIps ,
79+ transitIps : [ ... ( v4 ?. transitIps ?? [ ] ) , ... ( v6 ?. transitIps ?? [ ] ) ] ,
6980 } satisfies InstanceNetworkInterfaceUpdate
7081
7182 const form = useForm ( { defaultValues } )
7283 const transitIps = form . watch ( 'transitIps' ) || [ ]
7384
7485 // Determine what IP versions this NIC supports
75- const { ipStack } = editing
7686 const { supportedVersions, exampleIPs } = match ( ipStack . type )
7787 . with ( 'v4' , ( ) => ( { supportedVersions : 'IPv4' , exampleIPs : '192.168.0.0/16' } ) )
7888 . with ( 'v6' , ( ) => ( { supportedVersions : 'IPv6' , exampleIPs : 'fd00::/64' } ) )
@@ -113,6 +123,22 @@ export function EditNetworkInterfaceForm({
113123 loading = { editNetworkInterface . isPending }
114124 submitError = { editNetworkInterface . error }
115125 >
126+ < FormMetadata resource = { editing } >
127+ { v4 && (
128+ < PropertiesTable . Row label = "Private IPv4" >
129+ < CopyableIp ip = { v4 . ip } isLinked = { false } />
130+ </ PropertiesTable . Row >
131+ ) }
132+ { v6 && (
133+ < PropertiesTable . Row label = "Private IPv6" >
134+ < CopyableIp ip = { v6 . ip } isLinked = { false } />
135+ </ PropertiesTable . Row >
136+ ) }
137+ < PropertiesTable . Row label = "MAC address" > { editing . mac } </ PropertiesTable . Row >
138+ < PropertiesTable . Row label = "Subnet" >
139+ < SubnetNameFromId subnetId = { editing . subnetId } />
140+ </ PropertiesTable . Row >
141+ </ FormMetadata >
116142 < NameField name = "name" control = { form . control } />
117143 < DescriptionField name = "description" control = { form . control } />
118144 < FormDivider />
0 commit comments