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.

49 lines
1.5 KiB

  1. // Package imports.
  2. import { connect } from 'react-redux';
  3. import { defineMessages, injectIntl } from 'react-intl';
  4. // Our imports.
  5. import NotificationPurgeButtons from 'flavours/glitch/components/notification_purge_buttons';
  6. import {
  7. deleteMarkedNotifications,
  8. enterNotificationClearingMode,
  9. markAllNotifications,
  10. } from 'flavours/glitch/actions/notifications';
  11. import { openModal } from 'flavours/glitch/actions/modal';
  12. const messages = defineMessages({
  13. clearMessage: { id: 'notifications.marked_clear_confirmation', defaultMessage: 'Are you sure you want to permanently clear all selected notifications?' },
  14. clearConfirm: { id: 'notifications.marked_clear', defaultMessage: 'Clear selected notifications' },
  15. });
  16. const mapDispatchToProps = (dispatch, { intl }) => ({
  17. onEnterCleaningMode(yes) {
  18. dispatch(enterNotificationClearingMode(yes));
  19. },
  20. onDeleteMarked() {
  21. dispatch(openModal('CONFIRM', {
  22. message: intl.formatMessage(messages.clearMessage),
  23. confirm: intl.formatMessage(messages.clearConfirm),
  24. onConfirm: () => dispatch(deleteMarkedNotifications()),
  25. }));
  26. },
  27. onMarkAll() {
  28. dispatch(markAllNotifications(true));
  29. },
  30. onMarkNone() {
  31. dispatch(markAllNotifications(false));
  32. },
  33. onInvert() {
  34. dispatch(markAllNotifications(null));
  35. },
  36. });
  37. const mapStateToProps = state => ({
  38. markNewForDelete: state.getIn(['notifications', 'markNewForDelete']),
  39. });
  40. export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationPurgeButtons));