-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Add colorization based on health level for panels and toolbar #2178
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
base: main
Are you sure you want to change the base?
Conversation
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... |
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.
I like the idea! I added some nitpicks and comments/general questions.
|
||
--djdt-health-bg-1: #4b3f1b; | ||
--djdt-health-color-1: #ffe761; | ||
--djdt-health-bc-1: #ffcc00; |
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.
What is bc
? Background color? I think we prefer using variable names without abbreviations.
|
||
#djDebug .djdt-toolbarhandle-health-2 { | ||
border-color: var(--djdt-health-bc-2) !important; | ||
} |
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.
Can you add a comment why all these !important
are necessary? And/or remove them when they are not?
@@ -31,7 +31,7 @@ | |||
</ul> | |||
</div> | |||
<div class="djdt-hidden" id="djDebugToolbarHandle"> | |||
<div title="{% translate 'Show toolbar' %}" id="djShowToolBarButton"> | |||
<div title="{% translate 'Show toolbar' %}" id="djShowToolBarButton" class="{% if toolbar.health_level %} djdt-toolbarhandle-health-{{ toolbar.health_level }}{% endif %}"> |
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.
I generally do not like uppercase letters much in ID and class attributes, but I wonder if we should keep capitalization for internal consistency here? Any thoughts?
Return the maximum health level across all panels. | ||
This is used to color the toolbar hidden button. | ||
""" | ||
return max(panel.health_level for panel in self.panels) |
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.
What happens when self.panels
is empty? Is it possible? I think you might want to provide a default value as a fallback (max((...), NONE)
)
@@ -401,3 +402,9 @@ def is_processable_html_response(response): | |||
and content_encoding == "" | |||
and content_type in _HTML_TYPES | |||
) | |||
|
|||
|
|||
class ToolbarHealthLevel(IntEnum): |
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.
I think this could be called HealthLevel
only since it actually doesn't only apply to the toolbar itself but also to individual panels.
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 thealert
was already taken by the panel.Key Changes
Adds a
ToolbarHealthLevel
enum (NONE
,WARNING
,CRITICAL
) for numeric health states.Adds a
health_level
property to the basePanel
class, allowing panels to report their health status.Implements
health_level
inAlertsPanel
andSQLPanel
for 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:
Motivation
Checklist:
docs/changes.rst
.