Skip to content

Commit 2cb595b

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

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

OMICRON_VERSION

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

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() {
@@ -131,7 +128,12 @@ export function NetworkingTab() {
131128
<Column accessor="ip" />
132129
<Column header="vpc" accessor="vpcId" cell={VpcNameFromId} />
133130
<Column header="subnet" accessor="subnetId" cell={SubnetNameFromId} />
134-
<Column header="External IP" accessor="id" cell={ExternalIpsFromInstanceName} />
131+
<Column
132+
header="External IP"
133+
// we use primary to decide whether to show the IP in that row
134+
accessor="primary"
135+
cell={ExternalIpsFromInstanceName}
136+
/>
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)