fix: render disconnect tree label via className, not embedded HTML#10169
fix: render disconnect tree label via className, not embedded HTML#10169kundansable wants to merge 1 commit into
Conversation
Server/database disconnect handlers built the tree node label as an HTML string (<span class='text-muted'>[Disconnecting...]</span> ...), but FileTreeX's setLabel() writes the label via label.textContent, which escapes markup — so the literal tag text was shown instead of a styled "[Disconnecting...]" label. Pass plain text plus a className instead, and have setLabel apply that className to the label span (resetting to the default file-name class otherwise), so styling comes from CSS rather than injected HTML. Fixes pgadmin-org#10106
WalkthroughDisconnecting server and database nodes now pass plain text with a muted class to the tree label API. The renderer applies the text through ChangesDisconnect label rendering
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx (1)
447-466: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winBroaden
setLabel’s type
FileTreeX.setLabelalready accepts object labels at runtime, but the parameter is still typed asstring, andIFileTreeXHandledoesn’t exposesetLabeleither. Update both tostring | { label: string; className?: string }so the TS API matches the actual contract.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx` around lines 447 - 466, Broaden the setLabel parameter type from string to string | { label: string; className?: string } in FileTreeX and update the corresponding IFileTreeXHandle declaration to expose setLabel with the same signature. Preserve the existing runtime handling for string and object labels.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx`:
- Around line 447-466: Broaden the setLabel parameter type from string to string
| { label: string; className?: string } in FileTreeX and update the
corresponding IFileTreeXHandle declaration to expose setLabel with the same
signature. Preserve the existing runtime handling for string and object labels.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f1da0f85-6d4a-46c6-8e4c-967c8d63e87e
📒 Files selected for processing (3)
web/pgadmin/browser/server_groups/servers/databases/static/js/database.jsweb/pgadmin/browser/server_groups/servers/static/js/server.jsweb/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx
Summary
Fixes #10106 — when disconnecting a server (or database), the Object Explorer tree node briefly shows the literal text
<span class='text-muted'>[Disconnecting...]</span>instead of a greyed-out "[Disconnecting...]" label.Root Cause
The disconnect handlers in
server.js/database.jsbuilt the transitional tree-node label as an HTML string and passed it straight to the tree'ssetLabel().FileTreeX'ssetLabel()writes the label vialabel.textContent, which — correctly — escapes any markup rather than rendering it, so the raw tag text is displayed verbatim instead of being interpreted as HTML.Fix
Have the disconnect handlers pass plain text (
[Disconnecting...] ${label}) plus aclassName: 'text-muted'instead of an HTML string.setLabel()now applies that className to the label<span>(and resets it to the defaultfile-nameclass otherwise), so the muted styling comes from CSS rather than injected markup.Test Steps
[Disconnecting...] <server name>— not the literal<span class='text-muted'>...</span>markup text.Summary by CodeRabbit