Skip to content

Commit 5492ab7

Browse files
feat: Add resource type and restyle terminal link (coder#1722)
1 parent c5f4d80 commit 5492ab7

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

site/src/components/Resources/Resources.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export const Resources: React.FC<ResourcesProps> = ({ resources, getResourcesErr
5858
if (!agent) {
5959
return (
6060
<TableRow>
61-
<TableCell className={styles.resourceNameCell}>{resource.name}</TableCell>
61+
<TableCell className={styles.resourceNameCell}>
62+
{resource.name}
63+
<span className={styles.resourceType}>{resource.type}</span>
64+
</TableCell>
6265
<TableCell colSpan={3}></TableCell>
6366
</TableRow>
6467
)
@@ -71,6 +74,7 @@ export const Resources: React.FC<ResourcesProps> = ({ resources, getResourcesErr
7174
{agentIndex === 0 && (
7275
<TableCell className={styles.resourceNameCell} rowSpan={agents.length}>
7376
{resource.name}
77+
<span className={styles.resourceType}>{resource.type}</span>
7478
</TableCell>
7579
)}
7680

@@ -85,6 +89,7 @@ export const Resources: React.FC<ResourcesProps> = ({ resources, getResourcesErr
8589
<TableCell>
8690
{agent.status === "connected" && (
8791
<TerminalLink
92+
className={styles.accessLink}
8893
workspaceName={workspace.name}
8994
agentName={agent.name}
9095
userName={workspace.owner_name}
@@ -115,8 +120,27 @@ const useStyles = makeStyles((theme) => ({
115120
borderRight: `1px solid ${theme.palette.divider}`,
116121
},
117122

123+
resourceType: {
124+
fontSize: 14,
125+
color: theme.palette.text.secondary,
126+
marginTop: theme.spacing(0.5),
127+
display: "block",
128+
},
129+
118130
// Adds some left spacing
119131
agentColumn: {
120132
paddingLeft: `${theme.spacing(2)}px !important`,
121133
},
134+
135+
accessLink: {
136+
color: theme.palette.text.secondary,
137+
display: "flex",
138+
alignItems: "center",
139+
140+
"& svg": {
141+
width: 16,
142+
height: 16,
143+
marginRight: theme.spacing(1.5),
144+
},
145+
},
122146
}))
Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import Link from "@material-ui/core/Link"
2+
import { makeStyles } from "@material-ui/core/styles"
3+
import ComputerIcon from "@material-ui/icons/Computer"
24
import React from "react"
35
import * as TypesGen from "../../api/typesGenerated"
6+
import { combineClasses } from "../../util/combineClasses"
47

58
export const Language = {
6-
linkText: "Open in terminal",
9+
linkText: "Open terminal",
710
}
811

912
export interface TerminalLinkProps {
1013
agentName?: TypesGen.WorkspaceAgent["name"]
1114
userName?: TypesGen.User["username"]
1215
workspaceName: TypesGen.Workspace["name"]
16+
className?: string
1317
}
1418

1519
/**
@@ -19,10 +23,34 @@ export interface TerminalLinkProps {
1923
* If no user name is provided "me" is used however it makes the link not
2024
* shareable.
2125
*/
22-
export const TerminalLink: React.FC<TerminalLinkProps> = ({ agentName, userName = "me", workspaceName }) => {
26+
export const TerminalLink: React.FC<TerminalLinkProps> = ({ agentName, userName = "me", workspaceName, className }) => {
27+
const styles = useStyles()
28+
2329
return (
24-
<Link href={`/${userName}/${workspaceName}${agentName ? `.${agentName}` : ""}/terminal`} target="_blank">
30+
<Link
31+
href={`/${userName}/${workspaceName}${agentName ? `.${agentName}` : ""}/terminal`}
32+
className={combineClasses([styles.link, className])}
33+
target="_blank"
34+
>
35+
<ComputerIcon className={styles.icon} />
2536
{Language.linkText}
2637
</Link>
2738
)
2839
}
40+
41+
// Replicating these from accessLink style from Resources component until we
42+
// define if we want these styles coming from the parent or having a
43+
// ResourceLink component for that
44+
const useStyles = makeStyles((theme) => ({
45+
link: {
46+
color: theme.palette.text.secondary,
47+
display: "flex",
48+
alignItems: "center",
49+
},
50+
51+
icon: {
52+
width: 16,
53+
height: 16,
54+
marginRight: theme.spacing(1.5),
55+
},
56+
}))

0 commit comments

Comments
 (0)