about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/containers/header_container.js
blob: b4dcb4d569d22ccfa35c23230e7aa3731e880e3a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { openModal } from 'flavours/glitch/actions/modal';
import { connect }   from 'react-redux';
import { defineMessages, injectIntl } from 'react-intl';
import Header from '../components/header';
import { logOut } from 'flavours/glitch/util/log_out';

const messages = defineMessages({
  logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' },
  logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' },
});

const mapStateToProps = state => {
  return {
    columns: state.getIn(['settings', 'columns']),
    unreadNotifications: state.getIn(['notifications', 'unread']),
    showNotificationsBadge: state.getIn(['local_settings', 'notifications', 'tab_badge']),
  };
};

const mapDispatchToProps = (dispatch, { intl }) => ({
  onSettingsClick (e) {
    e.preventDefault();
    e.stopPropagation();
    dispatch(openModal('SETTINGS', {}));
  },
  onLogout () {
    dispatch(openModal('CONFIRM', {
      message: intl.formatMessage(messages.logoutMessage),
      confirm: intl.formatMessage(messages.logoutConfirm),
      onConfirm: () => logOut(),
    }));
  },
});

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Header));