Skip to content

fix(site): Fix secondary buttons with popovers #7296

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 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions site/src/components/Resources/AgentButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { makeStyles } from "@material-ui/core/styles"
import Button, { ButtonProps } from "@material-ui/core/Button"
import { FC } from "react"
import { FC, forwardRef } from "react"
import { combineClasses } from "utils/combineClasses"

export const PrimaryAgentButton: FC<ButtonProps> = ({
Expand All @@ -17,20 +17,21 @@ export const PrimaryAgentButton: FC<ButtonProps> = ({
)
}

export const SecondaryAgentButton: FC<ButtonProps> = ({
className,
...props
}) => {
const styles = useStyles()
// eslint-disable-next-line react/display-name -- Name is inferred from variable name
export const SecondaryAgentButton = forwardRef<HTMLButtonElement, ButtonProps>(
({ className, ...props }, ref) => {
const styles = useStyles()

return (
<Button
variant="outlined"
className={combineClasses([styles.secondaryButton, className])}
{...props}
/>
)
}
return (
<Button
ref={ref}
variant="outlined"
className={combineClasses([styles.secondaryButton, className])}
{...props}
/>
)
},
)

const useStyles = makeStyles((theme) => ({
primaryButton: {
Expand Down
108 changes: 55 additions & 53 deletions site/src/components/SSHButton/SSHButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,64 @@ export const SSHButton: React.FC<React.PropsWithChildren<SSHButtonProps>> = ({
>
Connect SSH
</SecondaryAgentButton>
<Popover
classes={{ paper: styles.popoverPaper }}
id={id}
open={isOpen}
anchorEl={anchorRef.current}
onClose={onClose}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
transformOrigin={{
vertical: "top",
horizontal: "left",
}}
>
<HelpTooltipText>
Run the following commands to connect with SSH:
</HelpTooltipText>
<div>
<Popover
classes={{ paper: styles.popoverPaper }}
id={id}
open={isOpen}
anchorEl={anchorRef.current}
onClose={onClose}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
transformOrigin={{
vertical: "top",
horizontal: "left",
}}
>
<HelpTooltipText>
Run the following commands to connect with SSH:
</HelpTooltipText>

<Stack spacing={0.5} className={styles.codeExamples}>
<div>
<HelpTooltipText>
<strong className={styles.codeExampleLabel}>
Configure SSH hosts on machine:
</strong>
</HelpTooltipText>
<CodeExample code="coder config-ssh" />
</div>
<Stack spacing={0.5} className={styles.codeExamples}>
<div>
<HelpTooltipText>
<strong className={styles.codeExampleLabel}>
Configure SSH hosts on machine:
</strong>
</HelpTooltipText>
<CodeExample code="coder config-ssh" />
</div>

<div>
<HelpTooltipText>
<strong className={styles.codeExampleLabel}>
Connect to the agent:
</strong>
</HelpTooltipText>
<CodeExample
code={`ssh ${sshPrefix}${workspaceName}.${agentName}`}
/>
</div>
</Stack>
<div>
<HelpTooltipText>
<strong className={styles.codeExampleLabel}>
Connect to the agent:
</strong>
</HelpTooltipText>
<CodeExample
code={`ssh ${sshPrefix}${workspaceName}.${agentName}`}
/>
</div>
</Stack>

<HelpTooltipLinksGroup>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/install">
Install Coder CLI
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#vs-code-remote">
Connect via VS Code Remote SSH
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#jetbrains-gateway">
Connect via JetBrains Gateway
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#ssh-configuration">
SSH configuration
</HelpTooltipLink>
</HelpTooltipLinksGroup>
</Popover>
<HelpTooltipLinksGroup>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/install">
Install Coder CLI
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#vs-code-remote">
Connect via VS Code Remote SSH
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#jetbrains-gateway">
Connect via JetBrains Gateway
</HelpTooltipLink>
<HelpTooltipLink href="https://coder.com/docs/coder-oss/latest/ides#ssh-configuration">
SSH configuration
</HelpTooltipLink>
</HelpTooltipLinksGroup>
</Popover>
</div>
</>
)
}
Expand Down