2019-08-26 16:24:10 +00:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-05-28 14:38:10 +00:00
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import { openModal } from 'flavours/glitch/actions/modal';
|
2022-10-11 08:41:15 +00:00
|
|
|
import { logOut } from 'flavours/glitch/utils/log_out';
|
2019-08-26 16:24:10 +00:00
|
|
|
|
2023-05-28 14:38:10 +00:00
|
|
|
import Header from '../components/header';
|
|
|
|
|
2019-08-26 16:24:10 +00:00
|
|
|
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 18:52:07 +00: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 16:19:35 +00:00
|
|
|
onSettingsClick (e) {
|
2019-04-20 18:52:07 +00:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2023-05-25 13:42:37 +00:00
|
|
|
dispatch(openModal({ modalType: 'SETTINGS', modalProps: {} }));
|
2019-04-20 18:52:07 +00:00
|
|
|
},
|
2019-08-26 16:24:10 +00:00
|
|
|
onLogout () {
|
2023-05-25 13:42:37 +00:00
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
closeWhenConfirm: false,
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
},
|
2019-08-26 16:24:10 +00:00
|
|
|
}));
|
|
|
|
},
|
2019-04-20 18:52:07 +00:00
|
|
|
});
|
|
|
|
|
2019-08-26 16:24:10 +00:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Header));
|