mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-24 02:48:18 +00:00
Config: Explicitly check feature availability in the client
Don't assume a feature is available because the code has loaded and the user option is set. Export the logic from Hooks.php to the client. Change-Id: Ica0e58de7ed0d59e3b09645193eb2b691ae41c39
This commit is contained in:
parent
99acd2a925
commit
c42e86f0f6
|
@ -267,6 +267,14 @@ class Hooks {
|
|||
'ext.discussionTools.init'
|
||||
] );
|
||||
|
||||
$output->addJsConfigVars(
|
||||
'wgDiscussionToolsFeaturesEnabled',
|
||||
[
|
||||
'replytool' => static::isFeatureEnabledForOutput( $output, 'replytool' ),
|
||||
'newtopictool' => static::isFeatureEnabledForOutput( $output, 'newtopictool' ),
|
||||
]
|
||||
);
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$optionsLookup = $services->getUserOptionsLookup();
|
||||
$req = $output->getRequest();
|
||||
|
|
|
@ -4,6 +4,7 @@ var
|
|||
$pageContainer,
|
||||
newTopicController,
|
||||
$overlay,
|
||||
featuresEnabled = mw.config.get( 'wgDiscussionToolsFeaturesEnabled' ),
|
||||
Parser = require( './Parser.js' ),
|
||||
ThreadItem = require( './ThreadItem.js' ),
|
||||
logger = require( './logger.js' ),
|
||||
|
@ -276,7 +277,7 @@ function init( $container, state ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( mw.user.options.get( 'discussiontools-newtopictool' ) ) {
|
||||
if ( featuresEnabled.newtopictool && mw.user.options.get( 'discussiontools-newtopictool' ) ) {
|
||||
if ( newTopicController ) {
|
||||
// Stop the torn down controller from re-appearing
|
||||
newTopicController.$replyLink.off( 'click keypress', newTopicController.onReplyLinkClickHandler );
|
||||
|
|
Loading…
Reference in a new issue