2020-03-27 13:59:38 -07:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { openModal } from '../../../actions/modal';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2020-04-11 12:41:13 -07:00
|
|
|
import { logOut } from 'gabsocial/actions/auth';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
profile: { id: 'account.profile', defaultMessage: 'Profile' },
|
|
|
|
messages: { id: 'navigation_bar.messages', defaultMessage: 'Messages' },
|
|
|
|
preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
|
|
|
|
follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
|
|
|
|
blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
|
|
|
|
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
|
|
|
|
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
|
|
|
filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' },
|
|
|
|
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
|
|
|
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
|
|
|
|
});
|
|
|
|
|
2020-04-17 15:14:04 -07:00
|
|
|
const mapStateToProps = state => {
|
|
|
|
const me = state.get('me');
|
|
|
|
return {
|
|
|
|
meUsername: state.getIn(['accounts', me, 'username']),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onOpenHotkeys() {
|
|
|
|
dispatch(openModal('HOTKEYS'));
|
|
|
|
},
|
2020-04-11 12:41:13 -07:00
|
|
|
onClickLogOut(e) {
|
|
|
|
dispatch(logOut());
|
|
|
|
e.preventDefault();
|
|
|
|
},
|
2020-03-27 13:59:38 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
class ActionBar extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
size: PropTypes.number,
|
2020-04-14 14:37:17 -07:00
|
|
|
onOpenHotkeys: PropTypes.func.isRequired,
|
|
|
|
onClickLogOut: PropTypes.func.isRequired,
|
2020-04-17 15:14:04 -07:00
|
|
|
meUsername: PropTypes.string,
|
2020-03-27 13:59:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
handleHotkeyClick = () => {
|
|
|
|
this.props.onOpenHotkeys();
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
render() {
|
2020-04-17 15:14:04 -07:00
|
|
|
const { intl, onClickLogOut, meUsername } = this.props;
|
2020-03-27 13:59:38 -07:00
|
|
|
const size = this.props.size || 16;
|
|
|
|
|
|
|
|
let menu = [];
|
|
|
|
|
|
|
|
menu.push({ text: intl.formatMessage(messages.profile), to: `/@${meUsername}` });
|
2020-04-14 11:44:40 -07:00
|
|
|
menu.push({ text: intl.formatMessage(messages.messages), to: '/messages' });
|
2020-03-27 13:59:38 -07:00
|
|
|
menu.push(null);
|
|
|
|
menu.push({ text: intl.formatMessage(messages.follow_requests), to: '/follow_requests' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.mutes), to: '/mutes' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.blocks), to: '/blocks' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.domain_blocks), to: '/domain_blocks' });
|
2020-04-11 12:41:13 -07:00
|
|
|
menu.push({ text: intl.formatMessage(messages.filters), to: '/filters' });
|
2020-03-27 13:59:38 -07:00
|
|
|
menu.push(null);
|
|
|
|
menu.push({ text: intl.formatMessage(messages.keyboard_shortcuts), action: this.handleHotkeyClick });
|
2020-04-11 12:41:13 -07:00
|
|
|
menu.push({ text: intl.formatMessage(messages.preferences), to: '/settings/preferences' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.logout), to: '/auth/sign_out', action: onClickLogOut });
|
2020-03-27 13:59:38 -07:00
|
|
|
|
|
|
|
return (
|
2020-04-14 11:44:40 -07:00
|
|
|
<div className='compose__action-bar' style={{ 'marginTop':'-6px' }}>
|
2020-03-27 13:59:38 -07:00
|
|
|
<div className='compose__action-bar-dropdown'>
|
|
|
|
<DropdownMenuContainer items={menu} icon='chevron-down' size={size} direction='right' />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-04-14 11:44:40 -07:00
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
2020-04-17 15:14:04 -07:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ActionBar));
|