mediawiki-extensions-Popups/resources/ext.popups/reducers/settings.js
Sam Smith fcfe079d79 Hygiene: Organize reducers
Reducer changes:
* Break the mw.popups.reducers.rootReducer test into @@INIT tests
  for each reducer as there's shouldn't be any need to test that a
  framework works as documented.

Changes:
* Move the mw.popups.reducers#preview, #eventLogging, and #settings
  reducers into their own files in resources/ext.popups/reducers/.
* Make the associated tests mirror the new layout.
* Move the initialization of the mw.popups.reducers namespace into its
  own file.
* Remove the mw.popups.rootReducer property in favour of a simple
  private factory function per the reducer change above.

Change-Id: I94229d9ef1985f3806eec44c2e8234a5bbddc94f
2016-12-13 18:45:10 +00:00

32 lines
667 B
JavaScript

( function ( popups, nextState ) {
/**
* Reducer for actions that modify the state of the settings
*
* @param {Object} state
* @param {Object} action
* @return {Object} state after action
*/
popups.reducers.settings = function ( state, action ) {
if ( state === undefined ) {
state = {
shouldShow: false
};
}
switch ( action.type ) {
case popups.actionTypes.SETTINGS_SHOW:
return nextState( state, {
shouldShow: true
} );
case popups.actionTypes.SETTINGS_HIDE:
return nextState( state, {
shouldShow: false
} );
default:
return state;
}
};
}( mediaWiki.popups, mediaWiki.popups.nextState ) );