diff --git a/includes/Constants.php b/includes/Constants.php index 889b77d4f..7a04186c6 100644 --- a/includes/Constants.php +++ b/includes/Constants.php @@ -283,7 +283,17 @@ final class Constants { /** * @var string */ - public const REQUIREMENT_TYPOGRAPHY_SURVEY = 'TypographySurvey'; + public const REQUIREMENT_TYPOGRAPHY_SURVEY_PREFERENCE = 'TypographySurvey'; + + /** + * @var string + */ + public const REQUIREMENT_TYPOGRAPHY_SURVEY_CONFIG = 'TypographySurveyConfigRequirement'; + + /** + * @var string + */ + public const TYPOGRAPHY_SURVEY_CONFIG_KEY = 'VectorTypographySurvey'; /** * @var string diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index b25ac94e2..ba6ad6dc3 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -331,17 +331,26 @@ return [ $context->getUser(), $services->getUserOptionsLookup(), Constants::PREF_KEY_TYPOGRAPHY_SURVEY, - Constants::REQUIREMENT_TYPOGRAPHY_SURVEY, + Constants::REQUIREMENT_TYPOGRAPHY_SURVEY_PREFERENCE, $request, $context->getTitle() ) ); + $featureManager->registerRequirement( + new DynamicConfigRequirement( + $services->getMainConfig(), + Constants::TYPOGRAPHY_SURVEY_CONFIG_KEY, + Constants::REQUIREMENT_TYPOGRAPHY_SURVEY_CONFIG + ) + ); + $featureManager->registerFeature( Constants::FEATURE_TYPOGRAPHY_SURVEY, [ Constants::REQUIREMENT_FULLY_INITIALISED, - Constants::REQUIREMENT_TYPOGRAPHY_SURVEY + Constants::REQUIREMENT_TYPOGRAPHY_SURVEY_PREFERENCE, + Constants::REQUIREMENT_TYPOGRAPHY_SURVEY_CONFIG ] ); diff --git a/resources/skins.vector.typographySurvey/TypographySurvey.vue b/resources/skins.vector.typographySurvey/TypographySurvey.vue index c00e248ed..3b222bf32 100644 --- a/resources/skins.vector.typographySurvey/TypographySurvey.vue +++ b/resources/skins.vector.typographySurvey/TypographySurvey.vue @@ -5,15 +5,15 @@
diff --git a/resources/skins.vector.typographySurvey/index.js b/resources/skins.vector.typographySurvey/index.js index d621e07f9..e3be8df1f 100644 --- a/resources/skins.vector.typographySurvey/index.js +++ b/resources/skins.vector.typographySurvey/index.js @@ -1,12 +1,16 @@ -if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) { - mw.loader.using( [ 'vue' ] ).then( function () { - const Vue = require( 'vue' ), - App = require( './TypographySurvey.vue' ), - mountEl = document.createElement( 'div' ); +( function () { + const isMainNamespace = mw.config.get( 'wgNamespaceNumber' ) === 0; - mountEl.id = 'vector-typography-survey'; - document.body.appendChild( mountEl ); - // @ts-ignore - Vue.createMwApp( App ).mount( mountEl ); - } ); -} + if ( isMainNamespace ) { + mw.loader.using( [ 'vue' ] ).then( function () { + const Vue = require( 'vue' ), + App = require( './TypographySurvey.vue' ), + mountEl = document.createElement( 'div' ); + + mountEl.id = 'vector-typography-survey'; + document.body.appendChild( mountEl ); + // @ts-ignore + Vue.createMwApp( App ).mount( mountEl ); + } ); + } +}() ); diff --git a/skin.json b/skin.json index a5ee8f3d7..fde45c2c0 100644 --- a/skin.json +++ b/skin.json @@ -659,6 +659,13 @@ "logged_out": false }, "description": "@var boolean Temporary feature flag that enables the zebra design for the Vector skin." + }, + "VectorTypographySurvey": { + "value": { + "logged_in": false, + "logged_out": false + }, + "description": "@var boolean Temporary feature flag to enable a survey tool to gather feedback for typography changes in Vector. Note the user preference `vector-typography-survey` must also be set for the tool to be displayed." } }, "ServiceWiringFiles": [