2017-04-22 22:57:08 +00:00
|
|
|
import { assign, ReducerRegistry } from '../redux';
|
2017-03-07 03:34:51 +00:00
|
|
|
|
2017-04-22 22:57:08 +00:00
|
|
|
import { HIDE_DIALOG, OPEN_DIALOG } from './actionTypes';
|
2017-03-07 03:34:51 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-22 22:57:08 +00:00
|
|
|
* Reduces redux actions which show or hide dialogs.
|
2017-03-07 03:34:51 +00:00
|
|
|
*
|
2017-04-22 22:57:08 +00:00
|
|
|
* @param {State} state - The current redux state.
|
|
|
|
* @param {Action} action - The redux action to reduce.
|
|
|
|
* @param {string} action.type - The type of the redux action to reduce..
|
|
|
|
* @returns {State} The next redux state that is the result of reducing the
|
|
|
|
* specified action.
|
2017-03-07 03:34:51 +00:00
|
|
|
*/
|
|
|
|
ReducerRegistry.register('features/base/dialog', (state = {}, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case HIDE_DIALOG:
|
2017-04-22 22:57:08 +00:00
|
|
|
return assign(state, {
|
2017-03-07 03:34:51 +00:00
|
|
|
component: undefined,
|
|
|
|
componentProps: undefined
|
|
|
|
});
|
2017-04-22 22:57:08 +00:00
|
|
|
|
2017-03-07 03:34:51 +00:00
|
|
|
case OPEN_DIALOG:
|
2017-04-22 22:57:08 +00:00
|
|
|
return assign(state, {
|
2017-03-07 03:34:51 +00:00
|
|
|
component: action.component,
|
|
|
|
componentProps: action.componentProps
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
});
|