Skip to content

Commit ffff5a4

Browse files
committed
display external IPs on primary network interface
1 parent d85df4e commit ffff5a4

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

OMICRON_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
604a35be03783f1506519f7652557626347343be
1+
b9f6c1d35e3901e7ecd2415f3c42ea1bc6ca246c

app/pages/__tests__/instance/networking.e2e.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ test('Instance networking tab', async ({ page }) => {
1313
'my-nic',
1414
'a network interface',
1515
'172.30.0.10',
16+
'123.4.56.7',
1617
'mock-vpc',
1718
'mock-subnet',
1819
'primary',
@@ -58,11 +59,12 @@ test('Instance networking tab', async ({ page }) => {
5859
'my-nic',
5960
'a network interface',
6061
'172.30.0.10',
62+
'—',
6163
'mock-vpc',
6264
'mock-subnet',
6365
'',
6466
])
65-
await expectRowVisible(page, 'nic-2', ['nic-2', null, null, null, null, 'primary'])
67+
await expectRowVisible(page, 'nic-2', ['nic-2', null, null, null, null, null, 'primary'])
6668

6769
// Make an edit to the network interface
6870
await page

app/pages/project/instances/instance/tabs/NetworkingTab.tsx

+11-9
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ const SubnetNameFromId = ({ value }: { value: string }) => (
3939
</span>
4040
)
4141

42-
function ExternalIpsFromInstanceName({ value: instanceName }: { value: string }) {
43-
const { orgName, projectName } = useParams('orgName', 'projectName')
44-
const { data } = useApiQuery('instanceExternalIpList', {
45-
orgName,
46-
projectName,
47-
instanceName,
48-
})
49-
return <span className="text-default">{data?.items.map((eip) => eip.ip).join(', ')}</span>
42+
function ExternalIpsFromInstanceName({ value: primary }: { value: boolean }) {
43+
const instanceParams = useParams('orgName', 'projectName', 'instanceName')
44+
const { data } = useApiQuery('instanceExternalIpList', instanceParams)
45+
const ips = data?.items.map((eip) => eip.ip).join(', ')
46+
return <span className="text-default">{primary ? ips : <>&mdash;</>}</span>
5047
}
5148

5249
export function NetworkingTab() {
@@ -129,9 +126,14 @@ export function NetworkingTab() {
129126
<Column accessor="description" />
130127
{/* TODO: mark v4 or v6 explicitly? */}
131128
<Column accessor="ip" />
129+
<Column
130+
header="External IP"
131+
// we use primary to decide whether to show the IP in that row
132+
accessor="primary"
133+
cell={ExternalIpsFromInstanceName}
134+
/>
132135
<Column header="vpc" accessor="vpcId" cell={VpcNameFromId} />
133136
<Column header="subnet" accessor="subnetId" cell={SubnetNameFromId} />
134-
<Column header="External IP" accessor="id" cell={ExternalIpsFromInstanceName} />
135137
<Column
136138
accessor="primary"
137139
cell={({ value }) =>

libs/api-mocks/msw/handlers.ts

+16
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@ export const handlers = [
462462
}
463463
),
464464

465+
rest.get<never, InstanceParams, Json<Api.ExternalIpResultsPage> | GetErr>(
466+
'/api/organizations/:orgName/projects/:projectName/instances/:instanceName/external-ips',
467+
(req, res) => {
468+
const [, err] = lookupInstance(req.params)
469+
if (err) return res(err)
470+
// TODO: proper mock table
471+
const items = [
472+
{
473+
ip: '123.4.56.7',
474+
kind: 'ephemeral',
475+
} as const,
476+
]
477+
return res(json({ items }))
478+
}
479+
),
480+
465481
rest.get<never, InstanceParams, Json<Api.NetworkInterfaceResultsPage> | GetErr>(
466482
'/api/organizations/:orgName/projects/:projectName/instances/:instanceName/network-interfaces',
467483
(req, res) => {

libs/api/__generated__/Api.ts

+15-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/api/__generated__/OMICRON_VERSION

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)