1
1
import Avatar from "@material-ui/core/Avatar"
2
2
import { makeStyles } from "@material-ui/core/styles"
3
3
import FolderIcon from "@material-ui/icons/FolderOutlined"
4
- import HelpIcon from "@material-ui/icons/HelpOutlined"
5
4
import WidgetsIcon from "@material-ui/icons/WidgetsOutlined"
6
5
import ImageIcon from "@material-ui/icons/ImageOutlined"
7
6
import MemoryIcon from "@material-ui/icons/MemoryOutlined"
@@ -13,7 +12,9 @@ const AdjustedMemoryIcon: typeof MemoryIcon = ({ style, ...props }) => {
13
12
return < MemoryIcon style = { { ...style , fontSize : 24 } } { ...props } />
14
13
}
15
14
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 > = {
17
18
docker_volume : FolderIcon ,
18
19
docker_container : AdjustedMemoryIcon ,
19
20
docker_image : ImageIcon ,
@@ -26,12 +27,10 @@ const iconByResource: Record<string, typeof MemoryIcon> = {
26
27
null_resource : WidgetsIcon ,
27
28
}
28
29
29
- export type ResourceAvatarProps = { type : string }
30
+ export type ResourceAvatarProps = { type : ValidIcons }
30
31
31
32
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
35
34
const styles = useStyles ( )
36
35
37
36
return (
0 commit comments