You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

  1. import { connect } from 'react-redux';
  2. import { defineMessages, injectIntl } from 'react-intl';
  3. import ColumnSettings from '../components/column_settings';
  4. import { changeSetting, saveSettings } from '../../../actions/settings';
  5. import { clearNotifications } from '../../../actions/notifications';
  6. import { openModal } from '../../../actions/modal';
  7. const messages = defineMessages({
  8. clearMessage: { id: 'notifications.clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all your notifications?' },
  9. clearConfirm: { id: 'notifications.clear', defaultMessage: 'Clear notifications' },
  10. });
  11. const mapStateToProps = state => ({
  12. settings: state.getIn(['settings', 'notifications']),
  13. });
  14. const mapDispatchToProps = (dispatch, { intl }) => ({
  15. onChange (key, checked) {
  16. dispatch(changeSetting(['notifications', ...key], checked));
  17. },
  18. onSave () {
  19. dispatch(saveSettings());
  20. },
  21. onClear () {
  22. dispatch(openModal('CONFIRM', {
  23. message: intl.formatMessage(messages.clearMessage),
  24. confirm: intl.formatMessage(messages.clearConfirm),
  25. onConfirm: () => dispatch(clearNotifications()),
  26. }));
  27. },
  28. });
  29. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ColumnSettings));