Skip to content

fix: render disconnect tree label via className, not embedded HTML#10169

Open
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10106-tree-html-label
Open

fix: render disconnect tree label via className, not embedded HTML#10169
kundansable wants to merge 1 commit into
pgadmin-org:masterfrom
kundansable:fix-10106-tree-html-label

Conversation

@kundansable

@kundansable kundansable commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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.js built the transitional tree-node label as an HTML string and passed it straight to the tree's setLabel(). FileTreeX's setLabel() writes the label via label.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 a className: 'text-muted' instead of an HTML string. setLabel() now applies that className to the label <span> (and resets it to the default file-name class otherwise), so the muted styling comes from CSS rather than injected markup.

Test Steps

  1. In the Object Explorer, expand Servers and connect to any server.
  2. Right-click the connected server → Disconnect Server (or use the toolbar disconnect action).
  3. Watch the tree node label during the transition.
  4. Expected: label reads a greyed-out [Disconnecting...] <server name> — not the literal <span class='text-muted'>...</span> markup text.
  5. Repeat for a connected database node's disconnect path if applicable.
  6. Confirm the label correctly returns to normal (non-muted) styling once disconnected / on reconnect.

Summary by CodeRabbit

  • Bug Fixes
    • Improved server and database disconnection status labels with consistent muted styling.
    • Prevented label content from being interpreted as HTML, improving display safety.
    • Ensured tree labels update correctly when custom styling is provided.

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
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Disconnecting server and database nodes now pass plain text with a muted class to the tree label API. The renderer applies the text through textContent and assigns the provided class separately, preventing raw HTML from appearing in node labels.

Changes

Disconnect label rendering

Layer / File(s) Summary
Tree label API and disconnect callers
web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx, web/pgadmin/browser/server_groups/servers/static/js/server.js, web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
setLabel now separates label text from its optional CSS class and applies text through textContent; server and database disconnect flows provide [Disconnecting...] labels with the text-muted class.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: rendering the disconnect label via className instead of embedded HTML.
Linked Issues check ✅ Passed The PR fixes #10106 by switching disconnect labels to plain text with muted styling, matching the reported bug.
Out of Scope Changes check ✅ Passed The FileTreeX label update supports the same disconnect-label fix and doesn't introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Broaden setLabel’s type
FileTreeX.setLabel already accepts object labels at runtime, but the parameter is still typed as string, and IFileTreeXHandle doesn’t expose setLabel either. Update both to string | { 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

📥 Commits

Reviewing files that changed from the base of the PR and between b15c745 and a842931.

📒 Files selected for processing (3)
  • web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
  • web/pgadmin/browser/server_groups/servers/static/js/server.js
  • web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object Explorer renders raw HTML as literal text when disconnecting a server

1 participant