2017-01-02 14:09:57 +01:00
|
|
|
import { connect } from 'react-redux';
|
2017-06-12 12:26:23 +02:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-01-02 14:09:57 +01:00
|
|
|
import ColumnSettings from '../components/column_settings';
|
2017-12-24 04:47:35 +01:00
|
|
|
import { changeSetting } from '../../../actions/settings';
|
2017-06-12 12:26:23 +02:00
|
|
|
import { clearNotifications } from '../../../actions/notifications';
|
2017-12-24 04:47:35 +01:00
|
|
|
import { changeAlerts as changePushNotifications } from '../../../actions/push_notifications';
|
2017-06-12 12:26:23 +02:00
|
|
|
import { openModal } from '../../../actions/modal';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
clearMessage: { id: 'notifications.clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all your notifications?' },
|
|
|
|
clearConfirm: { id: 'notifications.clear', defaultMessage: 'Clear notifications' },
|
|
|
|
});
|
2017-01-02 14:09:57 +01:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2017-05-20 17:31:47 +02:00
|
|
|
settings: state.getIn(['settings', 'notifications']),
|
2017-07-13 22:15:32 +02:00
|
|
|
pushSettings: state.get('push_notifications'),
|
2017-01-02 14:09:57 +01:00
|
|
|
});
|
|
|
|
|
2017-06-12 12:26:23 +02:00
|
|
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
2017-01-02 14:09:57 +01:00
|
|
|
|
2018-01-02 13:50:54 +01:00
|
|
|
onChange (path, checked) {
|
|
|
|
if (path[0] === 'push') {
|
|
|
|
dispatch(changePushNotifications(path.slice(1), checked));
|
2017-07-13 22:15:32 +02:00
|
|
|
} else {
|
2018-01-02 13:50:54 +01:00
|
|
|
dispatch(changeSetting(['notifications', ...path], checked));
|
2017-07-13 22:15:32 +02:00
|
|
|
}
|
2017-01-10 17:25:10 +01:00
|
|
|
},
|
|
|
|
|
2017-06-12 12:26:23 +02:00
|
|
|
onClear () {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: intl.formatMessage(messages.clearMessage),
|
|
|
|
confirm: intl.formatMessage(messages.clearConfirm),
|
|
|
|
onConfirm: () => dispatch(clearNotifications()),
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2017-01-02 14:09:57 +01:00
|
|
|
});
|
|
|
|
|
2017-06-12 12:26:23 +02:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ColumnSettings));
|