-
Notifications
You must be signed in to change notification settings - Fork 121
frontend: add timeout for snackbars #3776
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
frontend: add timeout for snackbars #3776
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideImplements level-based auto-dismiss timeouts for Alerter snackbars instead of keeping them open indefinitely. Class diagram for updated Alerter snackbar timeout logicclassDiagram
class Alerter {
+boolean show
+string message
+MessageLevel level
+string type
+number timeout
}
class MessageLevel {
<<enumeration>>
Success
Info
Warning
Error
}
Alerter --> MessageLevel : uses
class AlerterTypeComputed {
+string type()
}
class AlerterTimeoutComputed {
+number timeout()
}
AlerterTypeComputed <|-- Alerter : implements
AlerterTimeoutComputed <|-- Alerter : implements
class TimeoutBehavior {
+number forSuccess
+number forInfo
+number forWarning
+number forError
}
TimeoutBehavior : forSuccess = 5000
TimeoutBehavior : forInfo = 5000
TimeoutBehavior : forWarning = 7000
TimeoutBehavior : forError = -1
Alerter --> TimeoutBehavior : applies_by_level
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- Consider extracting the timeout values (5000, 7000, -1) into named constants or a small mapping object so the timing semantics are clearer and easier to adjust in one place.
- It might be helpful to add a brief inline comment or enum-like mapping indicating that
-1is used for an indefinite snackbar to make the special behavior explicit for future readers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the timeout values (5000, 7000, -1) into named constants or a small mapping object so the timing semantics are clearer and easier to adjust in one place.
- It might be helpful to add a brief inline comment or enum-like mapping indicating that `-1` is used for an indefinite snackbar to make the special behavior explicit for future readers.
## Individual Comments
### Comment 1
<location> `core/frontend/src/components/app/Alerter.vue:52-60` </location>
<code_context>
return 'info'
}
},
+ timeout(): number {
+ switch (this.level) {
+ case MessageLevel.Success:
+ case MessageLevel.Info:
+ return 5000
+ case MessageLevel.Warning:
+ return 7000
+ default:
+ return -1
+ }
+ },
</code_context>
<issue_to_address>
**suggestion:** Avoid magic numbers for timeouts by extracting named constants or documenting their intent.
Using raw `5000` and `7000` obscures their meaning (e.g., default vs. warning timeout). Please extract them into named constants (e.g., `SUCCESS_INFO_TIMEOUT_MS`, `WARNING_TIMEOUT_MS`) or a small `MessageLevel`-keyed map so the intent is clear and easier to adjust later.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| timeout(): number { | ||
| switch (this.level) { | ||
| case MessageLevel.Success: | ||
| case MessageLevel.Info: | ||
| return 5000 | ||
| case MessageLevel.Warning: | ||
| return 7000 | ||
| default: | ||
| return -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Avoid magic numbers for timeouts by extracting named constants or documenting their intent.
Using raw 5000 and 7000 obscures their meaning (e.g., default vs. warning timeout). Please extract them into named constants (e.g., SUCCESS_INFO_TIMEOUT_MS, WARNING_TIMEOUT_MS) or a small MessageLevel-keyed map so the intent is clear and easier to adjust later.
fix #1884
Summary by Sourcery
New Features: