feat(router): SidebarPanel now has routerles version
SidebarPanel now can be used without React Router. All tests converted to RTL. New logic covered by Unit Tests.
Summary by CodeRabbit
-
New Features
- Added a router-disabled sidebar mode that drives panel selection from internal navigation state.
-
Bug Fixes
- Improved sidebar navigation flexibility by making some sidebar properties optional, allowing multiple template IDs, and adding a silent flag for internal navigation.
- Moved version-related feed handling to the feed entry type to better align navigation behavior.
-
Tests
- Refactored tests to React Testing Library and added coverage for router-disabled mode.
-
Chores
- Enhanced mock sidebars to expose more data attributes for testing.
Walkthrough
Adds a router-disabled sidebar mode driven by internal navigation state, updates sidebar-related types (moving VERSIONS enum, changing filteredTemplateIds and optional sidebar), extends InternalSidebarNavigation, adds router-disabled SidebarPanels variant, and updates tests and mocks to support these changes.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Sidebar Navigation Typessrc/elements/common/types/SidebarNavigation.js.flow, src/elements/common/types/SidebarNavigation.ts |
Moved VERSIONS from ViewType to FeedEntryType; changed filteredTemplateIds from string to string[]; made sidebar optional; added optional silent to InternalSidebarNavigation; adjusted version-related view types. |
SidebarPanels Component & Router-Disabled Modesrc/elements/content-sidebar/SidebarPanels.js |
Renamed SidebarPanels → SidebarPanelsRouter; added SidebarPanelsRouterDisabled that renders sidebars from internalSidebarNavigation/handler (no React Router); added wrapper SidebarPanels to pick mode via routerDisabled prop; updated exports and URL→feed-type mapping. |
Tests (RTL) and New Router-Disabled Testssrc/elements/content-sidebar/__tests__/SidebarPanels.test.js |
Replaced Enzyme with React Testing Library; added tests for router-disabled mode using internalSidebarNavigation; updated helpers, assertions, refresh tests, and component update scenarios. |
Mock Sidebar Render Attributessrc/elements/content-sidebar/__mocks__/SidebarUtils.js |
Mock sidebar components updated to expose relevant props via data-* attributes (filteredTemplateIds, active feed entry type/id, versionId, initialization flag) for testing queries. |
Sequence Diagram(s)
sequenceDiagram
participant App
participant SidebarPanelsWrapper as SidebarPanels
participant RouterMode as SidebarPanelsRouter
participant DisabledMode as SidebarPanelsRouterDisabled
participant Sidebar as SidebarComponent
App->>SidebarPanelsWrapper: render(props: routerDisabled?, internalSidebarNavigation?, ...)
alt routerDisabled = false
SidebarPanelsWrapper->>RouterMode: render (uses React Router path)
RouterMode->>Sidebar: choose & render based on URL path
else routerDisabled = true
SidebarPanelsWrapper->>DisabledMode: render (uses internalSidebarNavigation)
DisabledMode->>Sidebar: choose & render based on internalSidebarNavigation state
end
Note over DisabledMode,Sidebar: internal handler updates drive navigation when router is disabled
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~40 minutes
Possibly related PRs
- box/box-ui-elements#4160 — Implements/aligns router-disabled internal navigation props and behavior for sidebar components.
- box/box-ui-elements#4156 — Adds router-disabled mode and internal navigation handling for content sidebar components.
- box/box-ui-elements#4177 — Introduces router-disabled internal navigation flow and adjustments to sidebar rendering without React Router.
Suggested labels
ready-to-merge
Suggested reviewers
- jankowiakdawid
- kajarosz
- tjiang-box
Poem
"I nibble at routes and hop through state,
Sidebars follow where I navigate.
Enums shuffled, mocks gleam bright,
Tests now bound and dancing light.
A rabbit's tweak — both swift and sly! 🐇"
[!TIP]
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.