chinwagsocial/app/javascript/mastodon/features/ui/containers/modal_container.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { openModal, closeModal } from '../../../actions/modal';
2017-04-02 06:11:28 +10:00
import ModalRoot from '../components/modal_root';
2016-10-25 03:07:40 +11:00
const defaultProps = {};
2016-10-25 03:07:40 +11:00
const mapStateToProps = state => ({
ignoreFocus: state.getIn(['modal', 'ignoreFocus']),
type: state.getIn(['modal', 'stack', 0, 'modalType'], null),
props: state.getIn(['modal', 'stack', 0, 'modalProps'], defaultProps),
2016-10-25 03:07:40 +11:00
});
const mapDispatchToProps = dispatch => ({
onClose (confirmationMessage, ignoreFocus = false) {
if (confirmationMessage) {
dispatch(
openModal({
modalType: 'CONFIRM',
modalProps: {
message: confirmationMessage.message,
confirm: confirmationMessage.confirm,
onConfirm: () => dispatch(closeModal({
modalType: undefined,
ignoreFocus: { ignoreFocus },
})),
} }),
);
} else {
dispatch(closeModal({
modalType: undefined,
ignoreFocus: { ignoreFocus },
}));
}
2016-10-25 03:07:40 +11:00
},
});
2017-04-02 06:11:28 +10:00
export default connect(mapStateToProps, mapDispatchToProps)(ModalRoot);