[MediaWiki-commits] [Gerrit] mediawiki...Popups[mpga]: Create the settings reducer
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: { -
[MediaWiki-commits] [Gerrit] mediawiki...Popups[mpga]: Create the settings reducer
Jhernandez has uploaded a new change for review. ( 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(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/15/326515/1 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 }, -