2019-04-20 20:52:07 +02:00
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
|
|
|
import { connect } from 'react-redux';
|
2019-08-26 18:24:10 +02:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2019-04-20 20:52:07 +02:00
|
|
|
import Header from '../components/header';
|
2019-08-26 18:24:10 +02:00
|
|
|
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' },
|
|
|
|
});
|
2019-04-20 20:52:07 +02:00
|
|
|
|
|
|
|
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 }) => ({
|
2019-04-23 18:19:35 +02:00
|
|
|
onSettingsClick (e) {
|
2019-04-20 20:52:07 +02:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
dispatch(openModal('SETTINGS', {}));
|
|
|
|
},
|
2019-08-26 18:24:10 +02:00
|
|
|
onLogout () {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
}));
|
|
|
|
},
|
2019-04-20 20:52:07 +02:00
|
|
|
});
|
|
|
|
|
2019-08-26 18:24:10 +02:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Header));
|