Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9776e66

Browse files
refactor: Make the applications more notable in the resources table (coder#2774)
1 parent e149534 commit 9776e66

File tree

4 files changed

+43
-59
lines changed

4 files changed

+43
-59
lines changed
+9-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import Button from "@material-ui/core/Button"
12
import Link from "@material-ui/core/Link"
23
import { makeStyles } from "@material-ui/core/styles"
34
import ComputerIcon from "@material-ui/icons/Computer"
45
import { FC } from "react"
56
import * as TypesGen from "../../api/typesGenerated"
6-
import { combineClasses } from "../../util/combineClasses"
77

88
export interface AppLinkProps {
99
userName: TypesGen.User["username"]
@@ -26,36 +26,18 @@ export const AppLink: FC<AppLinkProps> = ({ userName, workspaceName, appName, ap
2626
window.open(href, appName, "width=900,height=600")
2727
}}
2828
>
29-
{appIcon ? (
30-
<img
31-
className={combineClasses([styles.icon, appIcon === "" ? "empty" : ""])}
32-
alt={`${appName} Icon`}
33-
src={appIcon || ""}
34-
/>
35-
) : (
36-
<ComputerIcon className={styles.icon} />
37-
)}
38-
{appName}
29+
<Button
30+
size="small"
31+
startIcon={appIcon ? <img alt={`${appName} Icon`} src={appIcon} /> : <ComputerIcon />}
32+
>
33+
{appName}
34+
</Button>
3935
</Link>
4036
)
4137
}
4238

43-
const useStyles = makeStyles((theme) => ({
39+
const useStyles = makeStyles(() => ({
4440
link: {
45-
color: theme.palette.text.secondary,
46-
display: "flex",
47-
alignItems: "center",
48-
},
49-
50-
icon: {
51-
width: 16,
52-
height: 16,
53-
marginRight: theme.spacing(1.5),
54-
55-
// If no icon is provided we still want the padding on the left
56-
// to occur.
57-
"&.empty": {
58-
opacity: 0,
59-
},
41+
textDecoration: "none !important",
6042
},
6143
}))

site/src/components/Resources/Resources.tsx

+17-17
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ export const Resources: FC<ResourcesProps> = ({
102102

103103
<TableCell className={styles.agentColumn}>
104104
{agent.name}
105-
<span className={styles.operatingSystem}>{agent.operating_system}</span>
106-
<span style={{ color: agentStatus.color }}>{agentStatus.status}</span>
105+
<div className={styles.agentInfo}>
106+
<span className={styles.operatingSystem}>{agent.operating_system}</span>
107+
<span style={{ color: agentStatus.color }}>{agentStatus.status}</span>
108+
</div>
107109
</TableCell>
108110
{canUpdateWorkspace && (
109111
<TableCell>
110-
<Stack>
112+
<div className={styles.accessLinks}>
111113
{agent.status === "connected" && (
112114
<TerminalLink
113-
className={styles.accessLink}
114115
workspaceName={workspace.name}
115116
agentName={agent.name}
116117
userName={workspace.owner_name}
@@ -126,7 +127,7 @@ export const Resources: FC<ResourcesProps> = ({
126127
workspaceName={workspace.name}
127128
/>
128129
))}
129-
</Stack>
130+
</div>
130131
</TableCell>
131132
)}
132133
</TableRow>
@@ -165,23 +166,22 @@ const useStyles = makeStyles((theme) => ({
165166
paddingLeft: `${theme.spacing(2)}px !important`,
166167
},
167168

168-
accessLink: {
169-
color: theme.palette.text.secondary,
169+
agentInfo: {
170170
display: "flex",
171-
alignItems: "center",
172-
173-
"& svg": {
174-
width: 16,
175-
height: 16,
176-
marginRight: theme.spacing(1.5),
177-
},
178-
},
179-
180-
operatingSystem: {
171+
gap: theme.spacing(1.5),
181172
fontSize: 14,
182173
color: theme.palette.text.secondary,
183174
marginTop: theme.spacing(0.5),
175+
},
176+
177+
operatingSystem: {
184178
display: "block",
185179
textTransform: "capitalize",
186180
},
181+
182+
accessLinks: {
183+
display: "flex",
184+
gap: theme.spacing(0.5),
185+
flexWrap: "wrap",
186+
},
187187
}))

site/src/components/TerminalLink/TerminalLink.tsx

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Button from "@material-ui/core/Button"
12
import Link from "@material-ui/core/Link"
23
import { makeStyles } from "@material-ui/core/styles"
34
import ComputerIcon from "@material-ui/icons/Computer"
@@ -44,25 +45,15 @@ export const TerminalLink: FC<TerminalLinkProps> = ({
4445
window.open(href, Language.terminalTitle(generateRandomString(12)), "width=900,height=600")
4546
}}
4647
>
47-
<ComputerIcon className={styles.icon} />
48-
{Language.linkText}
48+
<Button startIcon={<ComputerIcon />} size="small">
49+
{Language.linkText}
50+
</Button>
4951
</Link>
5052
)
5153
}
5254

53-
// Replicating these from accessLink style from Resources component until we
54-
// define if we want these styles coming from the parent or having a
55-
// ResourceLink component for that
56-
const useStyles = makeStyles((theme) => ({
55+
const useStyles = makeStyles(() => ({
5756
link: {
58-
color: theme.palette.text.secondary,
59-
display: "flex",
60-
alignItems: "center",
61-
},
62-
63-
icon: {
64-
width: 16,
65-
height: 16,
66-
marginRight: theme.spacing(1.5),
57+
textDecoration: "none !important",
6758
},
6859
}))

site/src/theme/overrides.ts

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ export const getOverrides = (palette: PaletteOptions) => {
3232
backgroundColor: "#000000",
3333
},
3434
},
35+
sizeSmall: {
36+
padding: `0 12px`,
37+
fontSize: 14,
38+
minHeight: 36,
39+
},
40+
iconSizeSmall: {
41+
width: 16,
42+
height: 16,
43+
marginLeft: "0 !important",
44+
marginRight: 12,
45+
},
3546
},
3647
MuiTableHead: {
3748
root: {

0 commit comments

Comments
 (0)