Make SectionContainer resizable prop optional to fix Permissions and …#9693
Make SectionContainer resizable prop optional to fix Permissions and …#9693RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
Conversation
WalkthroughAdds optional resizable behavior to dashboard sections: Changes
Sequence Diagram(s)sequenceDiagram
participant Dashboard as Dashboard.jsx
participant Section as SectionContainer.jsx
participant Resizable as Resizable Wrapper
participant Content as Section Content (header/body)
Dashboard->>Section: render SectionContainer(resizable=true, defaultHeight=200)
alt resizable == true
Section->>Resizable: wrap content with defaultSize.height=defaultHeight
Resizable->>Content: render header and body inside resizable container
else resizable == false
Section->>Content: render header and body directly
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
…other page layouts.
1540ecb to
4b2bd91
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/pgadmin/dashboard/static/js/components/SectionContainer.jsx (1)
60-63: GuarddefaultHeightbefore using it for initial size.At Line 62, a non-positive or invalid
defaultHeightfrom callers can produce a poor initial render. Consider clamping/fallback before passing todefaultSize.♻️ Suggested hardening
export default function SectionContainer({title, titleExtras, children, style, resizable = false, defaultHeight = 200}) { + const resolvedDefaultHeight = + Number.isFinite(defaultHeight) && defaultHeight >= 25 ? defaultHeight : 200; + const content = ( @@ <Resizable enable={{ bottom: true }} - defaultSize={{ height: defaultHeight, width: '100%' }} + defaultSize={{ height: resolvedDefaultHeight, width: '100%' }} minHeight={25}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@web/pgadmin/dashboard/static/js/components/SectionContainer.jsx` around lines 60 - 63, Guard the defaultHeight value before passing it to the Resizable component's defaultSize: validate that defaultHeight is a finite positive number and clamp or fall back to a safe value (for example at least the existing minHeight or a sensible default like 100). Update the code that computes/uses defaultHeight in SectionContainer.jsx so you use a sanitized variable (e.g., safeDefaultHeight = Number.isFinite(defaultHeight) && defaultHeight > 0 ? Math.max(defaultHeight, minHeight) : minHeightOrFallback) and pass safeDefaultHeight into Resizable's defaultSize, keeping the minHeight prop unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@web/pgadmin/dashboard/static/js/components/SectionContainer.jsx`:
- Around line 60-63: Guard the defaultHeight value before passing it to the
Resizable component's defaultSize: validate that defaultHeight is a finite
positive number and clamp or fall back to a safe value (for example at least the
existing minHeight or a sensible default like 100). Update the code that
computes/uses defaultHeight in SectionContainer.jsx so you use a sanitized
variable (e.g., safeDefaultHeight = Number.isFinite(defaultHeight) &&
defaultHeight > 0 ? Math.max(defaultHeight, minHeight) : minHeightOrFallback)
and pass safeDefaultHeight into Resizable's defaultSize, keeping the minHeight
prop unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cf32f897-7da2-43fc-83fd-ce6cdfdf3eb4
📒 Files selected for processing (2)
web/pgadmin/dashboard/static/js/Dashboard.jsxweb/pgadmin/dashboard/static/js/components/SectionContainer.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
- web/pgadmin/dashboard/static/js/Dashboard.jsx
…other page layouts.
Summary by CodeRabbit