jenkins-bot has submitted this change and it was merged.

Change subject: Use local this.config rather than mw.UploadWizard.config where 
we need to
......................................................................


Use local this.config rather than mw.UploadWizard.config where we need to

None of these classes have a dependency on 'ext.uploadWizard' (it
would result in circular dependencies), and so they are not allowed to
access mw.UploadWizard. We already pass the config to them when construcing.
This was causing unit tests to fail when not ran in specific order.

Also remove checks for `mw.UploadWizard.config` itself, which were
presumably added when tests started failing...

Change-Id: Ib38374ae8f444c05b46362d14f5be1620f8aee14
---
M resources/ui/steps/uw.ui.Thanks.js
M resources/ui/steps/uw.ui.Upload.js
M tests/qunit/controller/uw.controller.Thanks.test.js
3 files changed, 14 insertions(+), 18 deletions(-)

Approvals:
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/ui/steps/uw.ui.Thanks.js 
b/resources/ui/steps/uw.ui.Thanks.js
index 70ad513..c64d75f 100644
--- a/resources/ui/steps/uw.ui.Thanks.js
+++ b/resources/ui/steps/uw.ui.Thanks.js
@@ -52,10 +52,10 @@
                        .addClass( 'mwe-upwiz-thanks-header' )
                        .prependTo( this.$div );
 
-               if ( !mw.UploadWizard.config || !mw.UploadWizard.config.display 
|| !mw.UploadWizard.config.display.thanksLabel ) {
+               if ( !this.config.display || !this.config.display.thanksLabel ) 
{
                        $header.text( mw.message( 'mwe-upwiz-thanks-intro' 
).text() );
                } else {
-                       $header.html( 
mw.UploadWizard.config.display.thanksLabel );
+                       $header.html( this.config.display.thanksLabel );
                }
 
                this.homeButton = new OO.ui.ButtonWidget( {
@@ -141,8 +141,8 @@
                        );
 
                upload.getThumbnail(
-                       mw.UploadWizard.config.thumbnailWidth,
-                       mw.UploadWizard.config.thumbnailMaxHeight
+                       this.config.thumbnailWidth,
+                       this.config.thumbnailMaxHeight
                ).done( function ( thumb ) {
                        mw.UploadWizard.placeThumbnail( $thumbnailDiv, thumb );
                } );
@@ -188,7 +188,7 @@
         * @return {Object|undefined}
         */
        uw.ui.Thanks.prototype.getButtonConfig = function ( buttonName, 
configField ) {
-               if ( !this.config || !this.config.display || 
!this.config.display[ buttonName ] ) {
+               if ( !this.config.display || !this.config.display[ buttonName ] 
) {
                        return;
                }
 
@@ -217,14 +217,14 @@
                        .addClass( 'mwe-upwiz-thanks-update-delay' )
                        .msg( 'mwe-upwiz-objref-notice-update-delay' );
 
-               if ( mw.UploadWizard.config && mw.UploadWizard.config.display 
&& mw.UploadWizard.config.display.noticeUpdateDelay ) {
-                       $delayNotice.html( 
mw.UploadWizard.config.display.noticeUpdateDelay );
+               if ( this.config.display && 
this.config.display.noticeUpdateDelay ) {
+                       $delayNotice.html( 
this.config.display.noticeUpdateDelay );
                }
                return $delayNotice;
        };
 
        uw.ui.Thanks.prototype.isObjectReferenceGiven = function () {
-               return mw.UploadWizard.config.defaults && 
mw.UploadWizard.config.defaults.objref !== '';
+               return this.config.defaults && this.config.defaults.objref !== 
'';
        };
 
 }( mediaWiki, jQuery, mediaWiki.uploadWizard, OO ) );
diff --git a/resources/ui/steps/uw.ui.Upload.js 
b/resources/ui/steps/uw.ui.Upload.js
index 8fa2e05..d3d4cdf 100644
--- a/resources/ui/steps/uw.ui.Upload.js
+++ b/resources/ui/steps/uw.ui.Upload.js
@@ -214,7 +214,7 @@
                        this.$addFileContainer.add( this.$buttons ).show();
                        this.$uploadCenterDivide.hide();
 
-                       if ( mw.UploadWizard.config.enableMultipleFiles !== 
true ) {
+                       if ( this.config.enableMultipleFiles !== true ) {
                                $needToHide = $( '.mwe-upwiz-file-input' )
                                        .add( this.$addFileContainer );
 
@@ -360,7 +360,7 @@
         * @return {boolean}
         */
        uw.ui.Upload.prototype.isFlickrImportEnabled = function () {
-               return mw.UploadWizard.config.UploadFromUrl && 
mw.UploadWizard.config.flickrApiKey !== '';
+               return this.config.UploadFromUrl && this.config.flickrApiKey 
!== '';
        };
 
 }( mediaWiki, jQuery, mediaWiki.uploadWizard, OO ) );
diff --git a/tests/qunit/controller/uw.controller.Thanks.test.js 
b/tests/qunit/controller/uw.controller.Thanks.test.js
index 721d6f1..7a5e449 100644
--- a/tests/qunit/controller/uw.controller.Thanks.test.js
+++ b/tests/qunit/controller/uw.controller.Thanks.test.js
@@ -19,18 +19,14 @@
        QUnit.module( 'mw.uw.controller.Thanks', QUnit.newMwEnvironment() );
 
        QUnit.test( 'Constructor sanity test', 3, function ( assert ) {
-               var step;
-
-               mw.UploadWizard.config = { display: { thanksLabel: 'Thanks!' } 
};
-
-               step = new uw.controller.Thanks();
+               var step = new uw.controller.Thanks( { display: { thanksLabel: 
'Thanks!' } } );
                assert.ok( step );
                assert.ok( step instanceof uw.controller.Step );
                assert.ok( step.ui );
        } );
 
        QUnit.test( 'moveTo', 1, function ( assert ) {
-               var step = new uw.controller.Thanks(),
+               var step = new uw.controller.Thanks( {} ),
                        auStub = this.sandbox.stub( step.ui, 'addUpload' );
 
                this.sandbox.stub( step.ui, 'moveTo' );
@@ -81,7 +77,7 @@
        } );
 
        QUnit.test( 'Method drops the given parameter', 1, function ( assert ) {
-               var uiThanks = new uw.ui.Thanks(),
+               var uiThanks = new uw.ui.Thanks( {} ),
                        locationHref = 
'https://commons.wikimedia.org/wiki/Special:UploadWizard?campaign=somecampaign&objref=testRef|MyPage|342&updateList=1&somevar=someval';
 
                assert.equal(
@@ -89,6 +85,6 @@
                        
'https://commons.wikimedia.org/wiki/Special:UploadWizard?campaign=somecampaign&objref=testRef%7CMyPage%7C342&somevar=someval',
                        'The href of the begin button does not contain the 
updateList parameter.'
                );
-
        } );
+
 }( mediaWiki, mediaWiki.uploadWizard ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/277901
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib38374ae8f444c05b46362d14f5be1620f8aee14
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: Kai Nissen (WMDE) <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Rillke <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to