Readers/Web/Dev notes/Menu architecture (Vector)

The Page Tools project will involve substantial changes to the menus in Vector 2022. Vector already modifies it's menus quite heavily, and if we don't organize the code now, adding more logic will lead to more confusion, tech debt and potential bugs. We have to find a sane way to modify the menu-related code in Vector and make future modifications manageable.

Current challenges

 * Menu modifications takes place in different parts of the code: hooks, in SkinVector.php and SkinVector2022.php
 * The Menu.mustache template has large amount of conditionals
 * The addition of icons to menu items takes place in different places in the code
 * No clear separation of responsibilities between SkinVector.php and SkinVector2022.php

Areas of exploration

 * Template refactoring
 * Division of logic between PHP and Mustache templates
 * Architecture of skin data modifications (i.e. can we structure these modifications in some sort of pattern).
 * Normalizing skin data for templates

October 3, 2022
Patch: POC: Refactor user menu dropdown to use multiple menu groups

Participants: Bernard, Moh

Summary: "I talked to @Moh about this, we decided that we could use SkinComponents to create SkinComponentDropdown and use SkinComponentMenu in order to better organize this data. Moh will be writing a task to clean this stuff up and implement those classes." - comment

October 4, 2022
Task: Split up Menu.template into separate templates, remove SkinVector::decoratePortletsData from modern Vector

Task goals: Split the Menu.mustache into multiple templates.

October 5, 2022
Patch: [Technical] Split up Menu.template, restrict decoratePortletData to legacy Vector

Summary: Merged Nov. 2.

New template structure & code is moved from SkinVector.php to SkinVectorLegacy.php so that responsibilities are more clear.

New templates:


 * Menu.mustache
 * Portal.mustache
 * Dropdown.mustache
 * Tabs.mustache

October 18, 2022
Meeting: Template Changes for Article Tools

Participants: Bernard, Jan, Mohd

Summary: Notes. Agree that we need a core Menu.mustache template that's shared across multiple menus. Question: How much data manipulation do we do in the templates vs in PHP?

October 20, 2022
Meeting: Jan, Berard

Summary: Notes exploring potential menu structures. How do we handle the "pinnable" template inside a potential Dropdown template?

October 31, 2022
Meeting: Super happy dev time - Path forward for menus

Summary:

1. Split templates

- from Menu.mustach into Dropdown.mustache & Portals.mustache

- Accept array as menu data for Article Tools menu

- Dropdown will be duplicated for pinnable feature

2. SkinComponents

- Modifications of data for menus. We're already heavily modifying menu data.

- create core menu/menuData component

- Proof of concept: https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/850293

3. Composition

- How do we stuff data into child templates in Mustache without composability?

- We need to do more analysis on the solution to composition

November 7, 2022
Patch: [Technical] Separate Dropdown template into 3 templates

Summary: New structure for templates that allows for "faking" composability. Removes the need to use getTemplateParser in skinVector.php.

New templates:


 * Dropdown.mustache
 * Dropdown/start.mustache
 * Dropdown/end.mustache

The template can now be used similar to how you'd use a tag in Vue.

November 8, 2022
Meeting: Bernard, Nick, Jan

Summary: Compared approaches to handling Dropdown data. Discussing Replace 'more' menu with page tools pinnable dropdown vs. Create new Page Tools menu (feature flagged). Agreed that iterating over an array of menu content is preferable to hard-coding menu content in Mustache. Why? We have to iterate over the sidebar menu content anyway, and handling the menu data in PHP makes it modifiable by extensions.

November 11, 2022
Patch: Replace 'more' menu with page tools pinnable dropdown,

Summary: As of now, the data and templates for the Page Tools menu (a.k.a a pinnable dropdown) follow the diagram below.