Skip to content

Commit f5a8d17

Browse files
feat: Add copy button to the SSH Page (#1962)
1 parent b85de3e commit f5a8d17

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

site/src/components/CodeExample/CodeExample.stories.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ export const Example = Template.bind({})
1717
Example.args = {
1818
code: sampleCode,
1919
}
20+
21+
export const LongCode = Template.bind({})
22+
LongCode.args = {
23+
code: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICnKzATuWwmmt5+CKTPuRGN0R1PBemA+6/SStpLiyX+L",
24+
}

site/src/components/CodeExample/CodeExample.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const useStyles = makeStyles((theme) => ({
2828
root: {
2929
display: "flex",
3030
flexDirection: "row",
31-
justifyContent: "space-between",
3231
alignItems: "center",
3332
background: theme.palette.background.default,
3433
color: theme.palette.primary.contrastText,
@@ -39,6 +38,13 @@ const useStyles = makeStyles((theme) => ({
3938
},
4039
code: {
4140
padding: `${theme.spacing(0.5)}px ${theme.spacing(0.75)}px ${theme.spacing(0.5)}px ${theme.spacing(2)}px`,
41+
whiteSpace: "nowrap",
42+
width: "100%",
43+
overflowX: "auto",
44+
// Have a better area to display the scrollbar
45+
height: 42,
46+
display: "flex",
47+
alignItems: "center",
4248
},
4349
button: {
4450
border: 0,

site/src/pages/UserSettingsPage/SSHKeysPage/SSHKeysPage.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Button from "@material-ui/core/Button"
33
import CircularProgress from "@material-ui/core/CircularProgress"
44
import { useActor } from "@xstate/react"
55
import React, { useContext, useEffect } from "react"
6-
import { CodeBlock } from "../../../components/CodeBlock/CodeBlock"
6+
import { CodeExample } from "../../../components/CodeExample/CodeExample"
77
import { ConfirmDialog } from "../../../components/ConfirmDialog/ConfirmDialog"
88
import { Section } from "../../../components/Section/Section"
99
import { Stack } from "../../../components/Stack/Stack"
@@ -41,10 +41,10 @@ export const SSHKeysPage: React.FC = () => {
4141

4242
{sshKey && (
4343
<Stack>
44-
<CodeBlock lines={[sshKey.public_key.trim()]} />
44+
<CodeExample code={sshKey.public_key.trim()} />
4545
<div>
4646
<Button
47-
color="primary"
47+
variant="outlined"
4848
onClick={() => {
4949
authSend({ type: "REGENERATE_SSH_KEY" })
5050
}}

0 commit comments

Comments
 (0)