- Notifications
You must be signed in to change notification settings - Fork906
feat: set icons for each type of notification#17115
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
5bb9eca
feat: set icons for each type of notification
BrunoQuaresma8ea7089
Merge branch 'main' of https://github.com/coder/coder into bq/notific…
BrunoQuaresma6182d98
Refactor types
BrunoQuaresma22dd6e6
FMT
BrunoQuaresmafa1d788
Fix missing type issues
BrunoQuaresmac6fcdc7
Rollback enums
BrunoQuaresmacd09c3e
Merge branch 'main' of https://github.com/coder/coder into bq/notific…
BrunoQuaresmafb9acf7
Fix avatar for empty icons
BrunoQuaresma16dd8be
Merge branch 'main' into bq/notification-icons
BrunoQuaresmaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
42 changes: 21 additions & 21 deletionscoderd/inboxnotifications.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletionscoderd/inboxnotifications_internal_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletionscoderd/inboxnotifications_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletionscodersdk/inboxnotification.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletionssite/src/api/typesGenerated.ts
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
2 changes: 1 addition & 1 deletionsite/src/components/Avatar/Avatar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -28,7 +28,7 @@ const avatarVariants = cva( | ||
}, | ||
variant: { | ||
default: null, | ||
icon:"[&_svg]:size-full", | ||
}, | ||
}, | ||
defaultVariants: { | ||
46 changes: 46 additions & 0 deletionssite/src/modules/notifications/NotificationsInbox/InboxAvatar.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { InboxAvatar } from "./InboxAvatar"; | ||
const meta: Meta<typeof InboxAvatar> = { | ||
title: "modules/notifications/NotificationsInbox/InboxAvatar", | ||
component: InboxAvatar, | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof InboxAvatar>; | ||
export const Custom: Story = { | ||
args: { | ||
icon: "/icon/git.svg", | ||
}, | ||
}; | ||
export const EmptyIcon: Story = { | ||
args: { | ||
icon: "", | ||
}, | ||
}; | ||
export const FallbackWorkspace: Story = { | ||
args: { | ||
icon: "DEFAULT_ICON_WORKSPACE", | ||
}, | ||
}; | ||
export const FallbackAccount: Story = { | ||
args: { | ||
icon: "DEFAULT_ICON_ACCOUNT", | ||
}, | ||
}; | ||
export const FallbackTemplate: Story = { | ||
args: { | ||
icon: "DEFAULT_ICON_TEMPLATE", | ||
}, | ||
}; | ||
export const FallbackOther: Story = { | ||
args: { | ||
icon: "DEFAULT_ICON_OTHER", | ||
}, | ||
}; |
54 changes: 54 additions & 0 deletionssite/src/modules/notifications/NotificationsInbox/InboxAvatar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
InboxNotificationFallbackIconAccount, | ||
InboxNotificationFallbackIconOther, | ||
InboxNotificationFallbackIconTemplate, | ||
InboxNotificationFallbackIconWorkspace, | ||
} from "api/typesGenerated"; | ||
import { Avatar } from "components/Avatar/Avatar"; | ||
import { | ||
InfoIcon, | ||
LaptopIcon, | ||
LayoutTemplateIcon, | ||
UserIcon, | ||
} from "lucide-react"; | ||
import type { FC } from "react"; | ||
import type React from "react"; | ||
const InboxNotificationFallbackIcons = [ | ||
InboxNotificationFallbackIconAccount, | ||
InboxNotificationFallbackIconWorkspace, | ||
InboxNotificationFallbackIconTemplate, | ||
InboxNotificationFallbackIconOther, | ||
] as const; | ||
type InboxNotificationFallbackIcon = | ||
(typeof InboxNotificationFallbackIcons)[number]; | ||
const fallbackIcons: Record<InboxNotificationFallbackIcon, React.ReactNode> = { | ||
DEFAULT_ICON_WORKSPACE: <LaptopIcon />, | ||
DEFAULT_ICON_ACCOUNT: <UserIcon />, | ||
DEFAULT_ICON_TEMPLATE: <LayoutTemplateIcon />, | ||
DEFAULT_ICON_OTHER: <InfoIcon />, | ||
}; | ||
type InboxAvatarProps = { | ||
icon: string; | ||
}; | ||
export const InboxAvatar: FC<InboxAvatarProps> = ({ icon }) => { | ||
if (icon === "") { | ||
return <Avatar variant="icon">{fallbackIcons.DEFAULT_ICON_OTHER}</Avatar>; | ||
} | ||
if (isInboxNotificationFallbackIcon(icon)) { | ||
return <Avatar variant="icon">{fallbackIcons[icon]}</Avatar>; | ||
} | ||
return <Avatar variant="icon" src={icon} />; | ||
}; | ||
function isInboxNotificationFallbackIcon( | ||
icon: string, | ||
): icon is InboxNotificationFallbackIcon { | ||
return (InboxNotificationFallbackIcons as readonly string[]).includes(icon); | ||
} |
1 change: 1 addition & 0 deletionssite/src/modules/notifications/NotificationsInbox/InboxItem.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletionssite/src/modules/notifications/NotificationsInbox/InboxItem.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsite/src/testHelpers/entities.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.