Skip to content

Add the possibility to define navigation item children#862

Merged
giuscris merged 3 commits into2.xfrom
feature/menu-items-children
Feb 28, 2026
Merged

Add the possibility to define navigation item children#862
giuscris merged 3 commits into2.xfrom
feature/menu-items-children

Conversation

@giuscris
Copy link
Member

This pull request refactors how navigation tabs are handled in the panel, making the navigation structure more flexible and maintainable. Instead of hardcoding tab arrays and rendering logic in controllers and views, tabs are now defined as navigation children in the configuration and rendered using reusable partials. This change also introduces improved handling for navigation items and collections, including support for nested items.

Navigation Structure Refactoring

  • Navigation tabs for options and tools are now defined as children in the navigation config (panel/config/navigation.php), replacing hardcoded arrays in controllers. This enables dynamic tab generation and easier future extension. [1] [2] [3] [4]
  • Controllers (OptionsController, ToolsController) no longer maintain their own tab arrays or pass tab views; views now use navigation children for tab rendering. [1] [2] [3] [4] [5]

Navigation Item & Collection Improvements

  • NavigationItem and NavigationItemCollection classes now implement ArraySerializable and support nested children, with new methods for serialization and construction from arrays. [1] [2] [3]
  • The panel's navigation loading logic now uses NavigationItemCollection::fromArray for building navigation items, supporting nested structures.

View and Partial Updates

  • Old tab rendering views (options/tabs.php, tools/tabs.php) are removed and replaced with a new partial (partials/navigation/tabs.php) that renders navigation tabs based on navigation children. [1] [2] [3]
  • Options and tools views (options/site.php, options/system.php, tools/backups.php, tools/info.php, tools/updates.php) now use the new tab partial, passing appropriate navigation children. [1] [2] [3] [4] [5]
  • Sidebar navigation is also refactored to use a new partial for consistent rendering. [1] [2]

Styling

  • Minor CSS update for tab icons to improve spacing.

@giuscris giuscris requested a review from Copilot February 28, 2026 11:30
@giuscris giuscris self-assigned this Feb 28, 2026
@giuscris giuscris added the enhancement New feature or request label Feb 28, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the panel navigation to support defining “tab” navigation as child navigation items in configuration, and renders both tabs and sidebar navigation via reusable partials instead of controller-provided tab arrays.

Changes:

  • Define options/tools tabs as children in panel/config/navigation.php and render them via a new partials/navigation/tabs.php partial.
  • Refactor sidebar rendering to use a new partials/navigation/sidebar.php partial.
  • Extend panel navigation model/collection to support nested children and array (de)serialization.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
panel/views/tools/updates.php Switches from controller-provided $tabs HTML to the new navigation tabs partial.
panel/views/tools/tabs.php Removes legacy tools tabs view.
panel/views/tools/info.php Switches to the new navigation tabs partial.
panel/views/tools/backups.php Switches to the new navigation tabs partial.
panel/views/partials/sidebar.php Replaces inline sidebar rendering loop with an inserted partial.
panel/views/partials/navigation/tabs.php Adds reusable tabs renderer driven by navigation children.
panel/views/partials/navigation/sidebar.php Adds reusable sidebar renderer driven by navigation items.
panel/views/options/tabs.php Removes legacy options tabs view.
panel/views/options/system.php Switches to the new navigation tabs partial.
panel/views/options/site.php Switches to the new navigation tabs partial.
panel/src/scss/components/_tabs.scss Adds spacing styling for tab icons.
panel/config/navigation.php Introduces children for options/tools and removes redundant badge => null entries.
formwork/src/Panel/Panel.php Updates navigation loading to build via NavigationItemCollection::fromArray().
formwork/src/Panel/Navigation/NavigationItemCollection.php Adds ArraySerializable support and fromArray()/toArray() helpers.
formwork/src/Panel/Navigation/NavigationItem.php Adds children() support plus fromArray()/toArray() handling for nested items.
formwork/src/Panel/Controllers/ToolsController.php Removes hardcoded tabs array and stops passing rendered tabs to views.
formwork/src/Panel/Controllers/OptionsController.php Removes hardcoded tabs array and stops passing rendered tabs to views.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris merged commit 60fa191 into 2.x Feb 28, 2026
2 checks passed
@giuscris giuscris deleted the feature/menu-items-children branch February 28, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants