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