feat: Add colorization based on health level for panels and toolbar
- #1395
Description
This PR introduces a unified health/alert state for Django Debug Toolbar panels and updates the UI to reflect panel.
The name health is debatable, but the alert was already taken by the panel.
Key Changes
-
Adds a
ToolbarHealthLevelenum (NONE,WARNING,CRITICAL) for numeric health states. -
Adds a
health_levelproperty to the basePanelclass, allowing panels to report their health status. -
Implements
health_levelinAlertsPanelandSQLPanelfor alert and slow query detection. -
The toolbar now computes the maximum health level across all panels and uses it to color the hidden toolbar handle.
-
UI Updates:
- Panel buttons and the hidden toolbar handle use new CSS classes and colors based on health level.
- Adds CSS variables and styles for warning and critical states.
| Warning | Warning on Hover | Critical | Critical on Hover |
|---|---|---|---|
| Critical on Panel | Warning on Panel |
|---|---|
Motivation
- Improves user experience by visually highlighting issues in the toolbar.
Checklist:
- [ ] I have added the relevant tests for this change.
- [ ] I have added an item to the Pending section of
docs/changes.rst. - [ ] Add to Documentation
@matthiask @tim-schilling
I'll be writing the testcases for this. It would be great if you could take a look at it before testcases.
Thanks!
Edit: You can also suggest how to compute health(debatable name) across other panel profiling, time etc...
@hunzlahmalik this is really neat! How does it work with the history panel? Does the color only show for the request that renders the button? If you switch to a request that has problems, does the color update? Last question, I promise, did you consider adding the health level to the history panel so a person can view the high level issues of all the requests in a summary-esque view? I personally think that would be a fantastic way to leverage this feature.
For the panels that do define the health_level logic, after switching the request they should update the color too. Right now there are only two panels with health_level login, sqlpanel and alerts.
See this:
Regarding summary-esque view, what do you have in mind. We can colorize the rows in the history panel based on health, or do you want a separate some kind of filter/tab for it. I think coloring the rows looks good to me. Like if there is a request with health_level CRITICAL, then that row will be red, with warning, that row will be yellowish.