diff --git a/app/pages/project/instances/instance/tabs/ConnectTab.tsx b/app/pages/project/instances/instance/tabs/ConnectTab.tsx index 0e6bdec8f..12a2d523e 100644 --- a/app/pages/project/instances/instance/tabs/ConnectTab.tsx +++ b/app/pages/project/instances/instance/tabs/ConnectTab.tsx @@ -9,11 +9,11 @@ import type { ReactNode } from 'react' import { Link, type LoaderFunctionArgs } from 'react-router-dom' -import { apiQueryClient, useApiQuery } from '~/api' +import { apiQueryClient, usePrefetchedApiQuery } from '~/api' import { EquivalentCliCommand } from '~/components/EquivalentCliCommand' -import { getInstanceSelector, useInstanceSelector, useProjectSelector } from '~/hooks' +import { getInstanceSelector, useInstanceSelector } from '~/hooks' import { buttonStyle } from '~/ui/lib/Button' -import { SettingsGroup } from '~/ui/lib/SettingsGroup' +import { LearnMore, SettingsGroup } from '~/ui/lib/SettingsGroup' import { cliCmd } from '~/util/cli-cmd' import { links } from '~/util/links' import { pb } from '~/util/path-builder' @@ -35,29 +35,14 @@ const InlineCode = ({ children }: { children: ReactNode }) => ( export function ConnectTab() { const { project, instance } = useInstanceSelector() - const { data: externalIps } = useApiQuery('instanceExternalIpList', { + const { data: externalIps } = usePrefetchedApiQuery('instanceExternalIpList', { path: { instance }, query: { project }, }) - const newFloatingIpLink = pb.floatingIpsNew(useProjectSelector()) - const floatingIps = externalIps?.items?.filter((ip) => ip.kind === 'floating') - // default to a floating IP; fall back to ephemeral IP, if it exists - const externalIp = (floatingIps?.[0] || externalIps?.items?.[0])?.ip - const sshCopy = externalIp ? ( -
- If you specified SSH keys when you created this instance, you can connect to it
- through an external IP:
- If you specified SSH keys when you created this instance, you can create an external - IP via the{' '} - - Floating IPs page - {' '} - to connect to your instance via SSH. -
- ) + const floatingIp = externalIps.items.find((ip) => ip.kind === 'floating') + const ephemeralIp = externalIps.items.find((ip) => ip.kind === 'ephemeral') + // prefer floating, fall back to ephemeral + const externalIp = floatingIp?.ip || ephemeralIp?.ip return (- Read our{' '} +
+ If you specified SSH keys when you created this instance, you can connect to it
+ through an external IP:{' '}
+
+ This instance has no external IP address. You can add one on the{' '} - SSH guide + networking {' '} - to learn more. + tab.
-