Skip to content

Commit

Permalink
display external IPs on primary network interface
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Jul 25, 2022
1 parent d85df4e commit 2cb595b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion OMICRON_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
604a35be03783f1506519f7652557626347343be
b9f6c1d35e3901e7ecd2415f3c42ea1bc6ca246c
20 changes: 11 additions & 9 deletions app/pages/project/instances/instance/tabs/NetworkingTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ const SubnetNameFromId = ({ value }: { value: string }) => (
</span>
)

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

export function NetworkingTab() {
Expand Down Expand Up @@ -131,7 +128,12 @@ export function NetworkingTab() {
<Column accessor="ip" />
<Column header="vpc" accessor="vpcId" cell={VpcNameFromId} />
<Column header="subnet" accessor="subnetId" cell={SubnetNameFromId} />
<Column header="External IP" accessor="id" cell={ExternalIpsFromInstanceName} />
<Column
header="External IP"
// we use primary to decide whether to show the IP in that row
accessor="primary"
cell={ExternalIpsFromInstanceName}
/>
<Column
accessor="primary"
cell={({ value }) =>
Expand Down
16 changes: 16 additions & 0 deletions libs/api-mocks/msw/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,22 @@ export const handlers = [
}
),

rest.get<never, InstanceParams, Json<Api.ExternalIpResultsPage> | GetErr>(
'/api/organizations/:orgName/projects/:projectName/instances/:instanceName/external-ips',
(req, res) => {
const [, err] = lookupInstance(req.params)
if (err) return res(err)
// TODO: proper mock table
const items = [
{
ip: '123.4.56.7',
kind: 'ephemeral',
} as const,
]
return res(json({ items }))
}
),

rest.get<never, InstanceParams, Json<Api.NetworkInterfaceResultsPage> | GetErr>(
'/api/organizations/:orgName/projects/:projectName/instances/:instanceName/network-interfaces',
(req, res) => {
Expand Down
16 changes: 15 additions & 1 deletion libs/api/__generated__/Api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/api/__generated__/OMICRON_VERSION

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2cb595b

Please sign in to comment.