Add link to AdminFE for staff members

merge-requests/15/head
Bárbara de Castro Fernandes 2020-05-18 20:48:33 -03:00
rodzic 88fb2b9911
commit 2e7a2e0e42
2 zmienionych plików z 25 dodań i 2 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ import Icon from './icon';
import DisplayName from './display_name';
import { closeSidebar } from '../actions/sidebar';
import { shortNumberFormat } from '../utils/numbers';
import { isStaff } from '../utils/accounts';
import { makeGetAccount } from '../selectors';
import { logOut } from 'gabsocial/actions/auth';
@ -26,6 +27,7 @@ const messages = defineMessages({
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' },
admin_settings: { id: 'navigation_bar.admin_settings', defaultMessage: 'Admin settings' },
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
lists: { id: 'column.lists', defaultMessage: 'Lists' },
apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' },
@ -41,6 +43,7 @@ const mapStateToProps = state => {
account: getAccount(state, me),
sidebarOpen: state.get('sidebar').sidebarOpen,
hasPatron: state.getIn(['soapbox', 'extensions', 'patron']),
isStaff: isStaff(state.getIn(['accounts', me])),
};
};
@ -63,10 +66,15 @@ class SidebarMenu extends ImmutablePureComponent {
account: ImmutablePropTypes.map,
sidebarOpen: PropTypes.bool,
onClose: PropTypes.func.isRequired,
isStaff: PropTypes.bool.isRequired,
};
static defaultProps = {
isStaff: false,
}
render() {
const { sidebarOpen, onClose, intl, account, onClickLogOut, hasPatron } = this.props;
const { sidebarOpen, onClose, intl, account, onClickLogOut, hasPatron, isStaff } = this.props;
if (!account) return null;
const acct = account.get('acct');
@ -151,6 +159,10 @@ class SidebarMenu extends ImmutablePureComponent {
<Icon id='filter' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.filters)}</span>
</NavLink> */}
{ isStaff && <a className='sidebar-menu-item' href={'/pleroma/admin/'} onClick={onClose}>
<Icon id='shield' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.admin_settings)}</span>
</a> }
<NavLink className='sidebar-menu-item' to='/settings/preferences' onClick={onClose}>
<Icon id='cog' />
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.preferences)}</span>

Wyświetl plik

@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import { openModal } from '../../../actions/modal';
import PropTypes from 'prop-types';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { isStaff } from 'gabsocial/utils/accounts';
import { defineMessages, injectIntl } from 'react-intl';
import { logOut } from 'gabsocial/actions/auth';
@ -16,6 +17,7 @@ const messages = defineMessages({
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' },
admin_settings: { id: 'navigation_bar.admin_settings', defaultMessage: 'Admin settings' },
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
});
@ -24,6 +26,7 @@ const mapStateToProps = state => {
const me = state.get('me');
return {
meUsername: state.getIn(['accounts', me, 'username']),
isStaff: isStaff(state.getIn(['accounts', me])),
};
};
@ -45,14 +48,19 @@ class ActionBar extends React.PureComponent {
onOpenHotkeys: PropTypes.func.isRequired,
onClickLogOut: PropTypes.func.isRequired,
meUsername: PropTypes.string,
isStaff: PropTypes.bool.isRequired,
};
static defaultProps = {
isStaff: false,
}
handleHotkeyClick = () => {
this.props.onOpenHotkeys();
}
render() {
const { intl, onClickLogOut, meUsername } = this.props;
const { intl, onClickLogOut, meUsername, isStaff } = this.props;
const size = this.props.size || 16;
let menu = [];
@ -68,6 +76,9 @@ class ActionBar extends React.PureComponent {
// menu.push({ text: intl.formatMessage(messages.filters), to: '/filters' });
menu.push(null);
menu.push({ text: intl.formatMessage(messages.keyboard_shortcuts), action: this.handleHotkeyClick });
if (isStaff) {
menu.push({ text: intl.formatMessage(messages.admin_settings), href: '/pleroma/admin/' });
}
menu.push({ text: intl.formatMessage(messages.preferences), to: '/settings/preferences' });
menu.push({ text: intl.formatMessage(messages.logout), to: '/auth/sign_out', action: onClickLogOut });