Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277901

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, 11 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/01/277901/1

diff --git a/resources/ui/steps/uw.ui.Thanks.js 
b/resources/ui/steps/uw.ui.Thanks.js
index 70ad513..d4d21ba 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 );
                } );
@@ -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..89a6b9d 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' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib38374ae8f444c05b46362d14f5be1620f8aee14
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to