jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/326515 )

Change subject: Create the settings reducer
......................................................................


Create the settings reducer

Right now only with visibility state on it.

Change-Id: Idbe99aca652eb04357ba85f22ba413dcd38cd54b
---
M resources/ext.popups/reducers.js
M tests/qunit/ext.popups/reducers.test.js
2 files changed, 31 insertions(+), 54 deletions(-)

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



diff --git a/resources/ext.popups/reducers.js b/resources/ext.popups/reducers.js
index 080cd24..f450963 100644
--- a/resources/ext.popups/reducers.js
+++ b/resources/ext.popups/reducers.js
@@ -1,4 +1,4 @@
-( function ( mw, $ ) {
+( function ( mw ) {
 
        // Sugar for the mw.popups.reducers.eventLogging reducer.
        var counts = mw.popups.counts;
@@ -214,61 +214,30 @@
        };
 
        /**
-        * Reducer for actions that modify the state of the view
+        * Reducer for actions that modify the state of the settings
         *
-        * @param {Object} state before action
-        * @param {Object} action Redux action that modified state.
-        *  Must have `type` property.
+        * @param {Object} state
+        * @param {Object} action
         * @return {Object} state after action
         */
-       mw.popups.reducers.renderer = function ( state, action ) {
+       mw.popups.reducers.settings = function ( state, action ) {
                if ( state === undefined ) {
                        state = {
-                               isAnimating: false,
-                               isInteractive: false,
-                               showSettings: false
+                               shouldShow: false
                        };
                }
 
                switch ( action.type ) {
-                       case mw.popups.actionTypes.PREVIEW_ANIMATING:
-                               return $.extend( {}, state, {
-                                       isAnimating: true,
-                                       isInteractive: false,
-                                       showSettings: false
+                       case mw.popups.actionTypes.SETTINGS_SHOW:
+                               return nextState( state, {
+                                       shouldShow: true
                                } );
-                       case mw.popups.actionTypes.PREVIEW_INTERACTIVE:
-                               return $.extend( OO.copy( state ), {
-                                       isAnimating: false,
-                                       isInteractive: true,
-                                       showSettings: false
-                               } );
-                       case mw.popups.actionTypes.PREVIEW_CLICK:
-                               return $.extend( OO.copy( state ), {
-                                       isAnimating: false,
-                                       isInteractive: false,
-                                       showSettings: false
-                               } );
-                       case mw.popups.actionTypes.COG_CLICK:
-                               return $.extend( OO.copy( state ), {
-                                       isAnimating: true,
-                                       isInteractive: false,
-                                       showSettings: true
-                               } );
-                       case mw.popups.actionTypes.SETTINGS_DIALOG_INTERACTIVE:
-                               return $.extend( OO.copy( state ), {
-                                       isAnimating: false,
-                                       isInteractive: true,
-                                       showSettings: true
-                               } );
-                       case mw.popups.actionTypes.SETTINGS_DIALOG_CLOSED:
-                               return $.extend( OO.copy( state ), {
-                                       isAnimating: false,
-                                       isInteractive: false,
-                                       showSettings: false
+                       case mw.popups.actionTypes.SETTINGS_HIDE:
+                               return nextState( state, {
+                                       shouldShow: false
                                } );
                        default:
                                return state;
                }
        };
-}( mediaWiki, jQuery ) );
+}( mediaWiki ) );
diff --git a/tests/qunit/ext.popups/reducers.test.js 
b/tests/qunit/ext.popups/reducers.test.js
index 507df6a..98b1e23 100644
--- a/tests/qunit/ext.popups/reducers.test.js
+++ b/tests/qunit/ext.popups/reducers.test.js
@@ -27,10 +27,8 @@
                                        event: undefined,
                                        interaction: undefined
                                },
-                               renderer: {
-                                       isAnimating: false,
-                                       isInteractive: false,
-                                       showSettings: false
+                               settings: {
+                                       shouldShow: false
                                }
                        },
                        'It should initialize the state by default'
@@ -179,17 +177,27 @@
                );
        } );
 
-       QUnit.test( '#renderer', function ( assert ) {
+       QUnit.test( '#settings: SETTINGS_SHOW', function ( assert ) {
                assert.expect( 1 );
 
                assert.deepEqual(
-                       mw.popups.reducers.renderer( {}, { type: 
'PREVIEW_ANIMATING' } ),
+                       mw.popups.reducers.settings( {}, { type: 
'SETTINGS_SHOW' } ),
                        {
-                               isAnimating: true,
-                               isInteractive: false,
-                               showSettings: false
+                               shouldShow: true
                        },
-                       'It should set isAnimating to true on the 
PREVIEW_ANIMATING action'
+                       'It should mark the settings dialog as ready to be 
shown'
+               );
+       } );
+
+       QUnit.test( '#settings: SETTINGS_HIDE', function ( assert ) {
+               assert.expect( 1 );
+
+               assert.deepEqual(
+                       mw.popups.reducers.settings( {}, { type: 
'SETTINGS_HIDE' } ),
+                       {
+                               shouldShow: false
+                       },
+                       'It should mark the settings dialog as ready to be 
closed'
                );
        } );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idbe99aca652eb04357ba85f22ba413dcd38cd54b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Phuedx <samsm...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to