Skip to content

refactor: use WidgetsIcon for null resources #3754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor: replace HelpIcon w/WidgetsIcon
Based on user feedback, we believe the `WidgetsIcon` will cause less
confusion.
  • Loading branch information
jsjoeio committed Aug 30, 2022
commit 91827b1000bd595a3aeb24180b8eaf5ead0e4632
8 changes: 3 additions & 5 deletions site/src/components/Resources/ResourceAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Avatar from "@material-ui/core/Avatar"
import { makeStyles } from "@material-ui/core/styles"
import FolderIcon from "@material-ui/icons/FolderOutlined"
import HelpIcon from "@material-ui/icons/HelpOutlined"
import WidgetsIcon from "@material-ui/icons/WidgetsOutlined"
import ImageIcon from "@material-ui/icons/ImageOutlined"
import MemoryIcon from "@material-ui/icons/MemoryOutlined"
import React from "react"
Expand All @@ -22,15 +22,13 @@ const iconByResource: Record<string, typeof MemoryIcon> = {
google_compute_instance: AdjustedMemoryIcon,
aws_instance: AdjustedMemoryIcon,
kubernetes_deployment: AdjustedMemoryIcon,
null_resource: HelpIcon,
null_resource: WidgetsIcon,
}

export type ResourceAvatarProps = { type: string }

export const ResourceAvatar: React.FC<ResourceAvatarProps> = ({ type }) => {
// this resource can return undefined
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const IconComponent = iconByResource[type] ?? HelpIcon
const IconComponent = iconByResource[type] ?? WidgetsIcon
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the resource can be undefined, I modified the return type of iconByResource to match that, which lets us remove this eslint line.

const styles = useStyles()

return (
Expand Down