ProtectionForm: Move JS config var to RL packageFiles
authorFomafix <fomafix@googlemail.com>
Mon, 17 Sep 2018 20:14:53 +0000 (22:14 +0200)
committerFomafix <fomafix@googlemail.com>
Mon, 11 Feb 2019 11:20:01 +0000 (12:20 +0100)
The check for type Array of the JavaScript config variable is obsolete.

Change-Id: I4a38cfc211360c831958ce8ca88584cdf56a727c

includes/ProtectionForm.php
resources/Resources.php
resources/src/mediawiki.legacy/protect.js

index c677a09..6ce7ef4 100644 (file)
@@ -353,12 +353,9 @@ class ProtectionForm {
                $user = $context->getUser();
                $output = $context->getOutput();
                $lang = $context->getLanguage();
-               $conf = $context->getConfig();
-               $cascadingRestrictionLevels = $conf->get( 'CascadingRestrictionLevels' );
                $out = '';
                if ( !$this->disabled ) {
                        $output->addModules( 'mediawiki.legacy.protect' );
-                       $output->addJsConfigVars( 'wgCascadeableLevels', $cascadingRestrictionLevels );
                        $out .= Xml::openElement( 'form', [ 'method' => 'post',
                                'action' => $this->mTitle->getLocalURL( 'action=protect' ),
                                'id' => 'mw-Protect-Form' ] );
index d62f3e3..f226427 100644 (file)
@@ -2386,7 +2386,12 @@ return [
                ],
        ],
        'mediawiki.legacy.protect' => [
-               'scripts' => 'resources/src/mediawiki.legacy/protect.js',
+               'localBasePath' => "$IP/resources/src/mediawiki.legacy",
+               'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.legacy",
+               'packageFiles' => [
+                       'protect.js',
+                       'config.json' => [ 'config' => [ 'CascadingRestrictionLevels' ] ],
+               ],
                'dependencies' => 'jquery.lengthLimit',
                'messages' => [ 'protect-unchain-permissions' ]
        ],
index 73978d9..b3707a5 100644 (file)
@@ -1,5 +1,6 @@
 ( function () {
        var ProtectionForm,
+               config = require( './config.json' ),
                reasonCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
                reasonByteLimit = mw.config.get( 'wgCommentByteLimit' );
 
@@ -18,9 +19,7 @@
                                return false;
                        }
 
-                       if ( mw.config.get( 'wgCascadeableLevels' ) !== undefined ) {
-                               $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
-                       }
+                       $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) );
                        this.getExpirySelectors().each( function () {
                                $( this ).on( 'change', ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) );
                        } );
                 * @return {boolean}
                 */
                isCascadeableLevel: function ( level ) {
-                       var cascadeableLevels = mw.config.get( 'wgCascadeableLevels' );
-
-                       if ( !Array.isArray( cascadeableLevels ) ) {
-                               return false;
-                       }
-
-                       return cascadeableLevels.indexOf( level ) !== -1;
+                       return config.CascadingRestrictionLevels.indexOf( level ) !== -1;
                },
 
                /**