Skip to content

Commit 728ceeb

Browse files
committed
fix: clean up TS in ResourceAvatar
1 parent 0490f52 commit 728ceeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

site/src/components/Resources/ResourceAvatar.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Avatar from "@material-ui/core/Avatar"
22
import { makeStyles } from "@material-ui/core/styles"
33
import FolderIcon from "@material-ui/icons/FolderOutlined"
4-
import HelpIcon from "@material-ui/icons/HelpOutlined"
54
import WidgetsIcon from "@material-ui/icons/WidgetsOutlined"
65
import ImageIcon from "@material-ui/icons/ImageOutlined"
76
import MemoryIcon from "@material-ui/icons/MemoryOutlined"
@@ -13,7 +12,9 @@ const AdjustedMemoryIcon: typeof MemoryIcon = ({ style, ...props }) => {
1312
return <MemoryIcon style={{ ...style, fontSize: 24 }} {...props} />
1413
}
1514

16-
const iconByResource: Record<string, typeof MemoryIcon> = {
15+
type ValidIcons = 'docker_volume' | 'docker_container' | 'docker_image' | 'kubernetes_persistent_volume_claim' | 'kubernetes_pod' | 'google_compute_disk' | 'google_compute_instance' | 'aws_instance' | 'kubernetes_deployment' | 'null_resource'
16+
17+
const iconByResource: Record<ValidIcons, typeof MemoryIcon | undefined> = {
1718
docker_volume: FolderIcon,
1819
docker_container: AdjustedMemoryIcon,
1920
docker_image: ImageIcon,
@@ -26,12 +27,10 @@ const iconByResource: Record<string, typeof MemoryIcon> = {
2627
null_resource: WidgetsIcon,
2728
}
2829

29-
export type ResourceAvatarProps = { type: string }
30+
export type ResourceAvatarProps = { type: ValidIcons }
3031

3132
export const ResourceAvatar: React.FC<ResourceAvatarProps> = ({ type }) => {
32-
// this resource can return undefined
33-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
34-
const IconComponent = iconByResource[type] ?? HelpIcon
33+
const IconComponent = iconByResource[type] ?? WidgetsIcon
3534
const styles = useStyles()
3635

3736
return (

0 commit comments

Comments
 (0)