Background
As one of the initial steps in T311647, we want to develop menu building capability in core to provide menu data that can be registered, used, and modified by skins, extensions, etc.
Description
Build an MVP of a core menu API.
Leveraging the refactoring of menus undertaken in MobileFrontend/Minerva, we can base the initial design of the core menu API MVP using the builder/director design pattern to deliver basic, structured menu data to templates.
Acceptance criteria
- Menu data generation is config-driven (JSON files)
- Menu data generation has a clear order of operations (we know which config takes precedence) << TBD
- Menus can be readily "grouped" i.e. menu entries can be bundled together in defined groups
- Icons, classes, attributes can be readily added/modified << descoped to Skins
- Template data generation is backwards compatible
Developer notes
Technical requirements:
- Settle on new data structure for menus - proposed data structure might be something like https://phabricator.wikimedia.org/F35474715
- Director classes can be accessed via services and used to build the data in getTemplateData() methods
- Generate new JSON conditionally.
- Since we need to keep the current template data as is for backwards compatibility, only include the restructured core menu data if a skin's skin.json provides the necessary config.
- Skins can add a menus key with a list of menu ids that they want rendered (see https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/816209/9/skin.json)
- Methods to generate data in Skin classes are removed/replaced by menu builder classes. << last step
- Tests are added << ***
To Do:
- If the approach proposed in POC patches (823673 + 808913 << footer menu is the 1st test case using Footer, MenuBuilder classes) is good enough to proceed, other menu classes have been stubbed out to implement MenuBuilderInterface:
- Actions
- AssociatedPages
- Footer
- Languages
- Notifications
- UserInterfacePreferences
- UserMenu
- UserPage
- Variants
- Views
- Flesh out approach to read a skin's JSON file into the menu builder to conditionally show/hide menus - MenuConfig is stubbed out as the class that will read a given skin.json << needs re-working per T318757
End Q1 status
- Follow up tasks have been outlined in T318757
- POC can be thrown away or used as basis for encapsulating menu API code leveraged by Skin Components (example of usage - menu + footer component patch introduces menu components in conjunction with POC MVP patch which creates a default menu component to generate the data using menu api.
- Descoping original goal in T311647 to what was able to be demo'd in POC patch.