Skip to content

Commit fdfc130

Browse files
committed
Add icons and avatar to the resource
1 parent 3e5affd commit fdfc130

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

site/src/components/AvatarData/AvatarData.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,25 @@ export interface AvatarDataProps {
1515
subtitle: string
1616
highlightTitle?: boolean
1717
link?: string
18+
avatar?: React.ReactNode
1819
}
1920

20-
export const AvatarData: FC<AvatarDataProps> = ({ title, subtitle, link, highlightTitle }) => {
21+
export const AvatarData: FC<AvatarDataProps> = ({
22+
title,
23+
subtitle,
24+
link,
25+
highlightTitle,
26+
avatar,
27+
}) => {
2128
const styles = useStyles()
2229

30+
if (!avatar) {
31+
avatar = firstLetter(title)
32+
}
33+
2334
return (
2435
<div className={styles.root}>
25-
<Avatar className={styles.avatar}>{firstLetter(title)}</Avatar>
36+
<Avatar className={styles.avatar}>{avatar}</Avatar>
2637

2738
{link ? (
2839
<Link to={link} underline="none" component={RouterLink}>

site/src/components/Resources/Resources.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import TableBody from "@material-ui/core/TableBody"
44
import TableCell from "@material-ui/core/TableCell"
55
import TableHead from "@material-ui/core/TableHead"
66
import TableRow from "@material-ui/core/TableRow"
7+
import MemoryIcon from "@material-ui/icons/MemoryOutlined"
78
import useTheme from "@material-ui/styles/useTheme"
9+
import { AvatarData } from "components/AvatarData/AvatarData"
810
import { FC } from "react"
911
import { Workspace, WorkspaceResource } from "../../api/typesGenerated"
1012
import { getDisplayAgentStatus } from "../../util/workspace"
@@ -68,17 +70,23 @@ export const Resources: FC<ResourcesProps> = ({
6870
/* We need to initialize the agents to display the resource */
6971
}
7072
const agents = resource.agents ?? [null]
73+
const resourceName = (
74+
<AvatarData
75+
avatar={<MemoryIcon />}
76+
title={resource.name}
77+
subtitle={resource.type}
78+
highlightTitle
79+
/>
80+
)
81+
7182
return agents.map((agent, agentIndex) => {
7283
{
7384
/* If there is no agent, just display the resource name */
7485
}
7586
if (!agent) {
7687
return (
7788
<TableRow key={`${resource.id}-${agentIndex}`}>
78-
<TableCell>
79-
{resource.name}
80-
<span className={styles.resourceType}>{resource.type}</span>
81-
</TableCell>
89+
<TableCell>{resourceName}</TableCell>
8290
<TableCell colSpan={3}></TableCell>
8391
</TableRow>
8492
)
@@ -91,8 +99,7 @@ export const Resources: FC<ResourcesProps> = ({
9199
{/* The rowspan should be the same than the number of agents */}
92100
{agentIndex === 0 && (
93101
<TableCell className={styles.resourceNameCell} rowSpan={agents.length}>
94-
{resource.name}
95-
<span className={styles.resourceType}>{resource.type}</span>
102+
{resourceName}
96103
</TableCell>
97104
)}
98105

0 commit comments

Comments
 (0)