Skip to content

Commit

Permalink
make all external IPs in header copyable (#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliepark authored Apr 22, 2024
1 parent 0f4bed0 commit e649e7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
41 changes: 18 additions & 23 deletions app/components/ExternalIps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,25 @@ export function ExternalIps({ project, instance }: InstanceSelector) {
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

if (!ips || ips.length === 0) return <EmptyCell />
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 className="flex items-center gap-1">
{intersperse(
ips.map((eip) => (
<span className="flex items-center gap-1" key={eip.ip}>
<a
className="link-with-underline text-sans-semi-md"
href={`https://${eip.ip}`}
target="_blank"
rel="noreferrer"
>
{eip.ip}
</a>
<CopyToClipboard text={eip.ip} />
</span>
)),
<span className="text-quinary"> / </span>
)}
</div>
)
}

function IpLink({ ip }: { ip: string }) {
return (
<a
className="link-with-underline text-sans-semi-md"
href={`https://${ip}`}
target="_blank"
rel="noreferrer"
>
{ip}
</a>
)
}
2 changes: 1 addition & 1 deletion app/pages/project/instances/instance/InstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function InstancePage() {
{instance.id}
</span>
</PropertiesTable.Row>
<PropertiesTable.Row label="external IP">
<PropertiesTable.Row label="external IPs">
{<ExternalIps {...instanceSelector} />}
</PropertiesTable.Row>
</PropertiesTable>
Expand Down

0 comments on commit e649e7b

Please sign in to comment.