-
Notifications
You must be signed in to change notification settings - Fork 19
Add VPC and instance external IP to instance page #1882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ee0bf86
Add VPC and instance external IP to instance page
benjaminleonard 31c0d28
Use slash as divider
benjaminleonard 4f8fc3f
Adds copy button on instance external IP (#1885)
benjaminleonard 0e16ec2
basic externalIps table. every instance still has the same IP though
david-crespo b20ce6c
make external IPs legit
david-crespo 9779f97
add file license
david-crespo acceef9
fix fallback logic around no IPs
david-crespo 4fa26fd
skeleton cell component
david-crespo 9a74c92
Give properties row a fixed height
benjaminleonard c8e2cc8
`EmptyCellContent` component instead of `—` directly
benjaminleonard bd14bdc
extract ExternalIps component that doesn't know about primary
david-crespo 2088e91
put https on IP link
david-crespo 8d582c9
remove external IP column from nics table, add asserts to e2e test
david-crespo 79c9839
put prefetches in Promise.all
david-crespo 3d5d4b8
sneaky prefetch on VPC name
david-crespo c31c850
share primary VPC ID logic
david-crespo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
|
|
||
| import { useApiQuery } from '@oxide/api' | ||
| import { EmptyCell, SkeletonCell } from '@oxide/table' | ||
| import { CopyToClipboard } from '@oxide/ui' | ||
| import { intersperse } from '@oxide/util' | ||
|
|
||
| type InstanceSelector = { project: string; instance: string } | ||
|
|
||
| export function ExternalIps({ project, instance }: InstanceSelector) { | ||
| const { data, isPending } = useApiQuery('instanceExternalIpList', { | ||
| path: { instance }, | ||
| query: { project }, | ||
| }) | ||
| if (isPending) return <SkeletonCell /> | ||
|
|
||
| const ips = data?.items | ||
| ? intersperse( | ||
| data.items.map((eip) => <IpLink ip={eip.ip} key={eip.ip} />), | ||
| <span className="text-quinary"> / </span> | ||
| ) | ||
| : undefined | ||
|
|
||
| return ( | ||
| <div className="flex items-center gap-1 text-secondary"> | ||
| {ips && ips.length > 0 ? ips : <EmptyCell />} | ||
| {/* If there's exactly one IP here, render a copy to clipboard button */} | ||
| {data?.items.length === 1 && <CopyToClipboard text={data.items[0].ip} />} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| function IpLink({ ip }: { ip: string }) { | ||
| return ( | ||
| <a | ||
| className="underline text-sans-semi-md text-secondary hover:text-default" | ||
| href={`https://${ip}`} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| {ip} | ||
| </a> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import type { ExternalIp } from '@oxide/api' | ||
|
|
||
| import { instances } from './instance' | ||
| import type { Json } from './json-type' | ||
|
|
||
| type DbExternalIp = { | ||
| instance_id: string | ||
| external_ip: Json<ExternalIp> | ||
| } | ||
|
|
||
| // TODO: this type represents the API response, but we need to mock more | ||
| // structure in order to be able to look up IPs for a particular instance | ||
| export const externalIps: DbExternalIp[] = [ | ||
| { | ||
| instance_id: instances[0].id, | ||
| external_ip: { | ||
| ip: `123.4.56.0`, | ||
| kind: 'ephemeral', | ||
| }, | ||
| }, | ||
| // middle one has no IPs | ||
| { | ||
| instance_id: instances[2].id, | ||
| external_ip: { | ||
| ip: `123.4.56.1`, | ||
| kind: 'ephemeral', | ||
| }, | ||
| }, | ||
| { | ||
| instance_id: instances[2].id, | ||
| external_ip: { | ||
| ip: `123.4.56.2`, | ||
| kind: 'ephemeral', | ||
| }, | ||
| }, | ||
| { | ||
| instance_id: instances[2].id, | ||
| external_ip: { | ||
| ip: `123.4.56.3`, | ||
| kind: 'ephemeral', | ||
| }, | ||
| }, | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
|
|
||
| import { classed } from '@oxide/util' | ||
|
|
||
| export const EmptyCell = () => <span className="text-sans-md text-quinary">—</span> | ||
|
|
||
| export const SkeletonCell = classed.div`h-4 w-12 rounded bg-tertiary motion-safe:animate-pulse` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.