jiti-meet/react/features/base/dialog/actions.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-09-18 15:58:03 +00:00
import { HIDE_DIALOG, OPEN_DIALOG } from './actionTypes';
2017-03-07 03:34:51 +00:00
/**
* Signals Dialog to close its dialog.
*
* @returns {{
* type: HIDE_DIALOG
* }}
*/
export function hideDialog() {
return {
type: HIDE_DIALOG
};
}
/**
* Signals Dialog to open dialog.
*
* @param {Object} component - The component to display as dialog.
2017-09-18 15:58:03 +00:00
* @param {Object} [componentProps] - The React <tt>Component</tt> props of the
* specified <tt>component</tt>.
2017-03-07 03:34:51 +00:00
* @returns {Object}
*/
export function openDialog(component, componentProps) {
return {
type: OPEN_DIALOG,
component,
componentProps
};
}
/**
* Signals Dialog to open a dialog with the specified component if the component
2017-09-18 15:58:03 +00:00
* is not already open. If it is open, then Dialog is signaled to close its
* dialog.
*
* @param {Object} component - The component to display as dialog.
2017-09-18 15:58:03 +00:00
* @param {Object} [componentProps] - The React <tt>Component</tt> props of the
* specified <tt>component</tt>.
* @returns {Object}
*/
export function toggleDialog(component, componentProps) {
return (dispatch, getState) => {
2017-09-18 15:58:03 +00:00
if (getState()['features/base/dialog'].component === component) {
dispatch(hideDialog());
} else {
dispatch(openDialog(component, componentProps));
}
};
}