diff --git a/site/src/components/Resources/Resources.tsx b/site/src/components/Resources/Resources.tsx index ca5dbfb149574..e3214993b4ce0 100644 --- a/site/src/components/Resources/Resources.tsx +++ b/site/src/components/Resources/Resources.tsx @@ -9,6 +9,7 @@ import { FC } from "react" import { Workspace, WorkspaceResource } from "../../api/typesGenerated" import { getDisplayAgentStatus } from "../../util/workspace" import { AppLink } from "../AppLink/AppLink" +import { SSHButton } from "../SSHButton/SSHButton" import { Stack } from "../Stack/Stack" import { TableHeaderRow } from "../TableHeaders/TableHeaders" import { TerminalLink } from "../TerminalLink/TerminalLink" @@ -107,18 +108,17 @@ export const Resources: FC = ({ {agentStatus.status} - {canUpdateWorkspace && ( - -
- {agent.status === "connected" && ( + + <> + {canUpdateWorkspace && agent.status === "connected" && ( +
+ - )} - {agent.status === "connected" && - agent.apps.map((app) => ( + {agent.apps.map((app) => ( = ({ workspaceName={workspace.name} /> ))} -
-
- )} +
+ )} + +
) }) diff --git a/site/src/components/SSHButton/SSHButton.stories.tsx b/site/src/components/SSHButton/SSHButton.stories.tsx new file mode 100644 index 0000000000000..4664b9554b148 --- /dev/null +++ b/site/src/components/SSHButton/SSHButton.stories.tsx @@ -0,0 +1,23 @@ +import { Story } from "@storybook/react" +import { MockWorkspace, MockWorkspaceAgent } from "../../testHelpers/renderHelpers" +import { SSHButton, SSHButtonProps } from "./SSHButton" + +export default { + title: "components/SSHButton", + component: SSHButton, +} + +const Template: Story = (args) => + +export const Closed = Template.bind({}) +Closed.args = { + workspaceName: MockWorkspace.name, + agentName: MockWorkspaceAgent.name, +} + +export const Opened = Template.bind({}) +Opened.args = { + workspaceName: MockWorkspace.name, + agentName: MockWorkspaceAgent.name, + defaultIsOpen: true, +} diff --git a/site/src/components/SSHButton/SSHButton.tsx b/site/src/components/SSHButton/SSHButton.tsx new file mode 100644 index 0000000000000..8a767cc93abbd --- /dev/null +++ b/site/src/components/SSHButton/SSHButton.tsx @@ -0,0 +1,109 @@ +import Button from "@material-ui/core/Button" +import Popover from "@material-ui/core/Popover" +import { makeStyles } from "@material-ui/core/styles" +import CloudIcon from "@material-ui/icons/CloudOutlined" +import { useRef, useState } from "react" +import { CodeExample } from "../CodeExample/CodeExample" +import { Stack } from "../Stack/Stack" +import { HelpTooltipLink, HelpTooltipLinksGroup, HelpTooltipText } from "../Tooltips/HelpTooltip" + +export interface SSHButtonProps { + workspaceName: string + agentName: string + defaultIsOpen?: boolean +} + +export const SSHButton: React.FC = ({ + workspaceName, + agentName, + defaultIsOpen = false, +}) => { + const anchorRef = useRef(null) + const [isOpen, setIsOpen] = useState(defaultIsOpen) + const id = isOpen ? "schedule-popover" : undefined + const styles = useStyles() + + const onClose = () => { + setIsOpen(false) + } + + return ( + <> + + + Run the following commands to connect with SSH: + + +
+ + + Configure ssh{" "} + + - only needs to be run once, or after managing workspaces + + + + +
+ +
+ + Connect to the agent + + +
+
+ + + Install Coder CLI + Configuring VS Code + SSH configuration + +
+ + ) +} + +const useStyles = makeStyles((theme) => ({ + popoverPaper: { + padding: `${theme.spacing(2)}px ${theme.spacing(3)}px ${theme.spacing(3)}px`, + width: theme.spacing(38), + color: theme.palette.text.secondary, + marginTop: theme.spacing(0.25), + }, + + codeExamples: { + marginTop: theme.spacing(1.5), + }, + + codeExampleLabel: { + fontSize: 12, + }, + + textHelper: { + fontWeight: 400, + }, +}))