Skip to content

Commit 3947c8c

Browse files
authored
Bump Omicron version and add IP Pool type field to IP Pool create form (#2951)
* Bump Omicron version and add IP Pool type field to IP Pool create form * Move description to top of form; make radios vertical * update e2e test to use multicast pool type
1 parent 092937a commit 3947c8c

File tree

11 files changed

+77
-50
lines changed

11 files changed

+77
-50
lines changed

OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b751cada653d817ba8274135d10e481369d6911c
1+
9617f40aa6f35b58ffd6b4e92c02ba8e7dd95033

app/api/__generated__/Api.ts

Lines changed: 23 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/OMICRON_VERSION

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/msw-handlers.ts

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/api/__generated__/validate.ts

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/forms/ip-pool-create.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
*/
88
import { useForm } from 'react-hook-form'
99
import { useNavigate } from 'react-router'
10+
import type { SetRequired } from 'type-fest'
1011

1112
import { useApiMutation, useApiQueryClient, type IpPoolCreate } from '@oxide/api'
1213

1314
import { DescriptionField } from '~/components/form/fields/DescriptionField'
1415
import { NameField } from '~/components/form/fields/NameField'
16+
import { RadioField } from '~/components/form/fields/RadioField'
1517
import { SideModalForm } from '~/components/form/SideModalForm'
1618
import { HL } from '~/components/HL'
1719
import { titleCrumb } from '~/hooks/use-crumbs'
@@ -23,10 +25,13 @@ import { pb } from '~/util/path-builder'
2325
// create a v6 pool, you can't actually add any ranges to it until
2426
// https://github.com/oxidecomputer/omicron/issues/8966
2527

26-
const defaultValues: IpPoolCreate = {
28+
type IpPoolCreateForm = SetRequired<IpPoolCreate, 'poolType'>
29+
30+
const defaultValues: IpPoolCreateForm = {
2731
name: '',
2832
description: '',
2933
ipVersion: 'v4',
34+
poolType: 'unicast',
3035
}
3136

3237
export const handle = titleCrumb('New IP pool')
@@ -45,23 +50,33 @@ export default function CreateIpPoolSideModalForm() {
4550
},
4651
})
4752

48-
const form = useForm({ defaultValues })
53+
const form = useForm<IpPoolCreateForm>({ defaultValues })
4954

5055
return (
5156
<SideModalForm
5257
form={form}
5358
formType="create"
5459
resourceName="IP pool"
5560
onDismiss={onDismiss}
56-
onSubmit={({ name, description }) => {
57-
createPool.mutate({ body: { name, description } })
61+
onSubmit={({ name, description, poolType }) => {
62+
createPool.mutate({ body: { name, description, poolType } })
5863
}}
5964
loading={createPool.isPending}
6065
submitError={createPool.error}
6166
>
67+
<IpPoolVisibilityMessage />
6268
<NameField name="name" control={form.control} />
6369
<DescriptionField name="description" control={form.control} />
64-
<IpPoolVisibilityMessage />
70+
<RadioField
71+
name="poolType"
72+
label="Pool type"
73+
column
74+
control={form.control}
75+
items={[
76+
{ value: 'unicast', label: 'Unicast' },
77+
{ value: 'multicast', label: 'Multicast' },
78+
]}
79+
/>
6580
</SideModalForm>
6681
)
6782
}

app/forms/ip-pool-edit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export default function EditIpPoolSideModalForm() {
7272
loading={editPool.isPending}
7373
submitError={editPool.error}
7474
>
75+
<IpPoolVisibilityMessage />
7576
<NameField name="name" control={form.control} />
7677
<DescriptionField name="description" control={form.control} />
77-
<IpPoolVisibilityMessage />
7878
</SideModalForm>
7979
)
8080
}

app/pages/system/networking/IpPoolsPage.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
type IpPool,
2020
} from '@oxide/api'
2121
import { IpGlobal16Icon, IpGlobal24Icon } from '@oxide/design-system/icons/react'
22+
import { Badge } from '@oxide/design-system/ui'
2223

2324
import { DocsPopover } from '~/components/DocsPopover'
2425
import { HL } from '~/components/HL'
@@ -64,6 +65,10 @@ const colHelper = createColumnHelper<IpPool>()
6465
const staticColumns = [
6566
colHelper.accessor('name', { cell: makeLinkCell((pool) => pb.ipPool({ pool })) }),
6667
colHelper.accessor('description', Columns.description),
68+
colHelper.accessor('poolType', {
69+
header: 'Pool type',
70+
cell: (info) => <Badge color="neutral">{info.getValue()}</Badge>,
71+
}),
6772
// TODO: add version column when API supports v6 pools
6873
colHelper.display({
6974
header: 'IPs Remaining',

mock-api/ip-pool.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const ipPool1: Json<IpPool> = {
1818
time_created: new Date().toISOString(),
1919
time_modified: new Date().toISOString(),
2020
ip_version: 'v4',
21+
pool_type: 'unicast',
2122
}
2223

2324
export const ipPool2: Json<IpPool> = {
@@ -27,6 +28,7 @@ export const ipPool2: Json<IpPool> = {
2728
time_created: new Date().toISOString(),
2829
time_modified: new Date().toISOString(),
2930
ip_version: 'v6',
31+
pool_type: 'unicast',
3032
}
3133

3234
export const ipPool3: Json<IpPool> = {
@@ -36,6 +38,7 @@ export const ipPool3: Json<IpPool> = {
3638
time_created: new Date().toISOString(),
3739
time_modified: new Date().toISOString(),
3840
ip_version: 'v4',
41+
pool_type: 'unicast',
3942
}
4043

4144
export const ipPool4: Json<IpPool> = {
@@ -45,6 +48,7 @@ export const ipPool4: Json<IpPool> = {
4548
time_created: new Date().toISOString(),
4649
time_modified: new Date().toISOString(),
4750
ip_version: 'v6',
51+
pool_type: 'unicast',
4852
}
4953

5054
export const ipPools: Json<IpPool>[] = [ipPool1, ipPool2, ipPool3, ipPool4]

mock-api/msw/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ export const handlers = makeHandlers({
10301030
// undefined.
10311031
// See https://zod.dev/v4/changelog?id=defaults-applied-within-optional-fields#defaults-applied-within-optional-fields
10321032
ip_version: body.ip_version || 'v4',
1033+
pool_type: body.pool_type || 'unicast',
10331034
...getTimestamps(),
10341035
}
10351036
db.ipPools.push(newPool)
@@ -1998,7 +1999,6 @@ export const handlers = makeHandlers({
19981999
systemUpdateTrustRootView: NotImplemented,
19992000
scimTokenList: NotImplemented,
20002001
scimTokenCreate: NotImplemented,
2001-
scimTokenDeleteAll: NotImplemented,
20022002
scimTokenView: NotImplemented,
20032003
scimTokenDelete: NotImplemented,
20042004
userBuiltinList: NotImplemented,

0 commit comments

Comments
 (0)