diff --git a/app/components/EquivalentCliCommand.tsx b/app/components/EquivalentCliCommand.tsx index 9c0f8697b4..2c16564f0e 100644 --- a/app/components/EquivalentCliCommand.tsx +++ b/app/components/EquivalentCliCommand.tsx @@ -13,7 +13,7 @@ import { Button } from '~/ui/lib/Button' import { Modal } from '~/ui/lib/Modal' import useTimeout from '~/ui/lib/use-timeout' -export default function EquivalentCliCommand({ command }: { command: string }) { +export function EquivalentCliCommand({ command }: { command: string }) { const [isOpen, setIsOpen] = useState(false) const [hasCopied, setHasCopied] = useState(false) diff --git a/app/pages/project/instances/instance/SerialConsolePage.tsx b/app/pages/project/instances/instance/SerialConsolePage.tsx index 6f6262ad18..9d80e0b4d6 100644 --- a/app/pages/project/instances/instance/SerialConsolePage.tsx +++ b/app/pages/project/instances/instance/SerialConsolePage.tsx @@ -11,10 +11,11 @@ import { Link } from 'react-router-dom' import { api } from '@oxide/api' import { PrevArrow12Icon } from '@oxide/design-system/icons/react' -import EquivalentCliCommand from '~/components/EquivalentCliCommand' +import { EquivalentCliCommand } from '~/components/EquivalentCliCommand' import { useInstanceSelector } from '~/hooks' import { Badge, type BadgeColor } from '~/ui/lib/Badge' import { Spinner } from '~/ui/lib/Spinner' +import { cliCmd } from '~/util/cli-cmd' import { pb } from '~/util/path-builder' const Terminal = lazy(() => import('~/components/Terminal')) @@ -95,10 +96,6 @@ export function SerialConsolePage() { } }, []) - const command = `oxide instance serial console - --project ${project} - --instance ${instance}` - return (
- +
diff --git a/app/pages/project/instances/instance/tabs/ConnectTab.tsx b/app/pages/project/instances/instance/tabs/ConnectTab.tsx index 71e5611398..89141139d0 100644 --- a/app/pages/project/instances/instance/tabs/ConnectTab.tsx +++ b/app/pages/project/instances/instance/tabs/ConnectTab.tsx @@ -6,20 +6,33 @@ * Copyright Oxide Computer Company */ +import { Link } from 'react-router-dom' + +import { EquivalentCliCommand } from '~/components/EquivalentCliCommand' import { useInstanceSelector } from '~/hooks' +import { buttonStyle } from '~/ui/lib/Button' import { SettingsGroup } from '~/ui/lib/SettingsGroup' +import { cliCmd } from '~/util/cli-cmd' import { pb } from '~/util/path-builder' export function ConnectTab() { const { project, instance } = useInstanceSelector() return ( - - Connect to your instance’s serial console - + + + Serial console + Connect to your instance’s serial console + + + + + Connect + + + ) } diff --git a/app/ui/lib/SettingsGroup.stories.tsx b/app/ui/lib/SettingsGroup.stories.tsx index 65bb11c009..1ac409a2df 100644 --- a/app/ui/lib/SettingsGroup.stories.tsx +++ b/app/ui/lib/SettingsGroup.stories.tsx @@ -5,27 +5,40 @@ * * Copyright Oxide Computer Company */ +import { Link } from 'react-router-dom' + +import { Button, buttonStyle } from './Button' import { SettingsGroup } from './SettingsGroup' export const Default = () => ( - - Connect to your instance’s serial console - + + + Serial console + Connect to your instance’s serial console + + + + Connect + + + ) export const WithoutDocs = () => ( - - Connect to your instance’s serial console - -) - -export const FunctionAction = () => ( - alert('hi')} ctaText="Connect"> - Connect to your instance’s serial console - + + + Serial console + Connect to your instance’s serial console + + + + Connect + + + + ) diff --git a/app/ui/lib/SettingsGroup.tsx b/app/ui/lib/SettingsGroup.tsx index 9915718c02..62e8d943ae 100644 --- a/app/ui/lib/SettingsGroup.tsx +++ b/app/ui/lib/SettingsGroup.tsx @@ -5,55 +5,37 @@ * * Copyright Oxide Computer Company */ -import { Link } from 'react-router-dom' import { OpenLink12Icon } from '@oxide/design-system/icons/react' -import { Button, buttonStyle } from '~/ui/lib/Button' +import { classed } from '~/util/classed' -type Props = { - title: string - docs?: { - text: string - link: string - } +const LearnMore = ({ href, text }: { href: string; text: React.ReactNode }) => ( + <> + Learn more about{' '} + + {text} + + + +) + +type FooterProps = { + /** Link text */ children: React.ReactNode - /** String action is a link */ - cta: string | (() => void) - ctaText: string + docsLink?: { text: string; href: string } } -export const SettingsGroup = ({ title, docs, children, cta, ctaText }: Props) => { - return ( -
-
-
{title}
- {children} -
-
- {/* div always present to keep the button right-aligned */} -
- {docs && ( - <> - Learn more about{' '} - - {docs.text} - - - - )} -
- - {typeof cta === 'string' ? ( - - {ctaText} - - ) : ( - - )} -
+/** Use size=sm on buttons and links! */ +export const SettingsGroup = { + Container: classed.div`w-full max-w-[660px] rounded-lg border text-sans-md text-secondary border-default`, + Body: classed.div`p-6`, + Title: classed.div`mb-1 text-sans-lg text-default`, + Footer: ({ children, docsLink }: FooterProps) => ( +
+ {/* div always present to keep the buttons right-aligned */} +
{docsLink && }
+
{children}
- ) + ), } diff --git a/app/util/cli-cmd.ts b/app/util/cli-cmd.ts new file mode 100644 index 0000000000..d4154c394e --- /dev/null +++ b/app/util/cli-cmd.ts @@ -0,0 +1,12 @@ +/* + * 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 + */ + +export const cliCmd = { + serialConsole: ({ project, instance }: { project: string; instance: string }) => + `oxide instance serial console\n--project ${project}\n--instance ${instance}`, +}