feat(dockstat): Add custom toast notifications and global error alerts#49
Merged
feat(dockstat): Add custom toast notifications and global error alerts#49
Conversation
Contributor
Reviewer's GuideImplements a custom toast notification system in the Dockstat app using Sonner and UI Card variants, wiring it to server log errors for global alerts, and extending UI Card styling to support error/success states. Sequence diagram for server log error triggering a toast notificationsequenceDiagram
participant Server
participant ClientApp
participant Layout
participant ToastModule
participant Sonner
Server->>ClientApp: Send logMessage(level="error", name, message)
ClientApp->>Layout: Update logMessage state
Layout->>Layout: useEffect on logMessage
Layout->>ToastModule: toast({variant="error", title, description})
ToastModule->>Sonner: sonnerToast.custom(render Toast(id, props))
Sonner-->>ClientApp: Render Toast component in Toaster
ClientApp->>ToastModule: User clicks button in Toast
ToastModule->>Sonner: sonnerToast.dismiss(id)
Updated class diagram for toast components and Card variantsclassDiagram
class ToastProps {
+string id
+string title
+string description
+string variant
+string buttonLabel
+function buttonOnClick()
}
class ToastModule {
+function toast(title, description, variant, buttonLabel, buttonOnClick)
}
class ToastComponent {
+boolean isHovered
+function render(id, title, description, variant, buttonLabel, buttonOnClick)
}
class Card {
+CardVariant variant
+CardSize size
+function render(children, onClick)
}
class Button {
+string variant
+function render(label, onClick)
}
class CardVariant {
<<enumeration>>
default
outlined
elevated
flat
dark
error
success
}
class CardSize {
<<enumeration>>
xs
sm
md
lg
}
ToastModule --> ToastProps
ToastModule ..> ToastComponent
ToastComponent --> Card
ToastComponent --> Button
Card --> CardVariant
Card --> CardSize
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In the global error toast title, there’s a typo in the message text ('occured' → 'occurred'); since this is user-facing, it’s worth correcting.
- The
ToastProps.descriptionis restricted tostringwhiletitleallowsReactNode; if you anticipate richer content (links, formatted text) in descriptions, consider typingdescriptionasReact.ReactNodefor consistency and flexibility.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the global error toast title, there’s a typo in the message text ('occured' → 'occurred'); since this is user-facing, it’s worth correcting.
- The `ToastProps.description` is restricted to `string` while `title` allows `ReactNode`; if you anticipate richer content (links, formatted text) in descriptions, consider typing `description` as `React.ReactNode` for consistency and flexibility.
## Individual Comments
### Comment 1
<location> `apps/dockstat/src/components/toast.tsx:22` </location>
<code_context>
+
+interface ToastProps {
+ id: string | number
+ title: string | React.ReactNode
+ description: string
+ variant?: "error" | "success"
</code_context>
<issue_to_address>
**issue:** React namespace types are used without importing the `React` type.
`ToastProps` uses `React.ReactNode` but `React` isn’t imported as a type, which can break type-checking under some TS/JSX configs. Please either import `type React from "react"` or use the named `ReactNode` type instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- Enhance `ToastProps.description` to accept `string | ReactNode`, providing more flexible content options for toast messages. - Conditionally apply the `title` attribute to the toast description paragraph, ensuring it is only rendered when the description is a string to prevent invalid HTML with React elements. - Fix a typo in the server error toast message, changing "occured" to "occurred". - Adjust import orders in `toast.tsx` and `layout.tsx` for consistency.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary by Sourcery
Introduce a custom toast notification system for Dockstat and hook it into global server error logging.
New Features:
Enhancements:
Build:
Chores: