mediawiki-skins-Vector/includes/FeatureManagement/TODO.md
Sam Smith 9177c22365 features: Add minimalist feature manager
With complex additions to Vector's codebase like the Desktop Improvement
Program upcoming, it's important that we have a shared, intuitive
language to talk about features and their requirements. Centralising
the registration of features and creating an API satisfies does exactly
this.

This change introduces a greatly-reduced version of Piotr Miazga's
(polishdeveloper, pmiazga) original proposed API and associated
scaffolding classes for feature management in Vector, which itself was
based upon his work in MobileFrontend/MinervaNeue. This is done to
establish a foundation upon which we can build the more sophisticated
parts of Piotr's proposal in a piecemeal basis, thereby minimising risk.

Distinct from Piotr's proposed API is the ability to register sets and
features that are always enabled or disabled.

Additionally:

- A Vector.FeatureManager service is registered but not used

- A list of proposed immediate next steps is included

Bug: T244481
Change-Id: Ie53c41d479eaf15559d5bb00f269774760360bde
2020-02-26 11:49:29 +00:00

1.2 KiB

TODO

Currently the FeatureManager class is a very shallow interpretation of Piotr Miazga's proposed API and associated scaffolding classes (see https://phabricator.wikimedia.org/T244481 and https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/Vector/+/572323/). This document aims to list the steps required to get from this system to something as powerful as Piotr's.

  1. Decide whether "set" is the correct name
  2. Add support for sets that utilise contextual information that isn't available at boot time, e.g.
use Vector\Constants;
use IContextSource;

$featureManager->registerSet( Constants::LOGGED_IN_SET, function( IContextSource $context ) {
	$user = $context->getUser();

	return $user
		&& $user->isSafeToLoad()
		&& $user->isLoggedIn();
} );

$featureManager->registerSet( Constants::MAINSPACE_SET, function ( IContextSource $context ) {
	$title = $context->getTitle();

	return $title && $title->inNamespace( NS_MAIN );
} );
  1. Consider supporing memoization of those sets (see https://gerrit.wikimedia.org/r/#/c/mediawiki/skins/Vector/+/573626/7/includes/FeatureManagement/FeatureManager.php@68)
  2. Add support for getting all sets
  3. Add support for getting all features enabled when a set is enabled/disabled