sforkowany z mirror/soapbox
Merge branch 'adminfe-link' into 'master'
Add link to AdminFE for staff members Closes #54 See merge request soapbox-pub/soapbox-fe!15stable/1.0.x
commit
ea6f5b6370
|
@ -12,6 +12,7 @@ import Icon from './icon';
|
||||||
import DisplayName from './display_name';
|
import DisplayName from './display_name';
|
||||||
import { closeSidebar } from '../actions/sidebar';
|
import { closeSidebar } from '../actions/sidebar';
|
||||||
import { shortNumberFormat } from '../utils/numbers';
|
import { shortNumberFormat } from '../utils/numbers';
|
||||||
|
import { isStaff } from '../utils/accounts';
|
||||||
import { makeGetAccount } from '../selectors';
|
import { makeGetAccount } from '../selectors';
|
||||||
import { logOut } from 'gabsocial/actions/auth';
|
import { logOut } from 'gabsocial/actions/auth';
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ const messages = defineMessages({
|
||||||
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
|
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
|
||||||
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
||||||
filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' },
|
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' },
|
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
||||||
lists: { id: 'column.lists', defaultMessage: 'Lists' },
|
lists: { id: 'column.lists', defaultMessage: 'Lists' },
|
||||||
apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' },
|
apps: { id: 'tabs_bar.apps', defaultMessage: 'Apps' },
|
||||||
|
@ -41,6 +43,7 @@ const mapStateToProps = state => {
|
||||||
account: getAccount(state, me),
|
account: getAccount(state, me),
|
||||||
sidebarOpen: state.get('sidebar').sidebarOpen,
|
sidebarOpen: state.get('sidebar').sidebarOpen,
|
||||||
hasPatron: state.getIn(['soapbox', 'extensions', 'patron']),
|
hasPatron: state.getIn(['soapbox', 'extensions', 'patron']),
|
||||||
|
isStaff: isStaff(state.getIn(['accounts', me])),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,10 +66,15 @@ class SidebarMenu extends ImmutablePureComponent {
|
||||||
account: ImmutablePropTypes.map,
|
account: ImmutablePropTypes.map,
|
||||||
sidebarOpen: PropTypes.bool,
|
sidebarOpen: PropTypes.bool,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
|
isStaff: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
isStaff: false,
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { sidebarOpen, onClose, intl, account, onClickLogOut, hasPatron } = this.props;
|
const { sidebarOpen, onClose, intl, account, onClickLogOut, hasPatron, isStaff } = this.props;
|
||||||
if (!account) return null;
|
if (!account) return null;
|
||||||
const acct = account.get('acct');
|
const acct = account.get('acct');
|
||||||
|
|
||||||
|
@ -151,6 +159,10 @@ class SidebarMenu extends ImmutablePureComponent {
|
||||||
<Icon id='filter' />
|
<Icon id='filter' />
|
||||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.filters)}</span>
|
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.filters)}</span>
|
||||||
</NavLink> */}
|
</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}>
|
<NavLink className='sidebar-menu-item' to='/settings/preferences' onClick={onClose}>
|
||||||
<Icon id='cog' />
|
<Icon id='cog' />
|
||||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.preferences)}</span>
|
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.preferences)}</span>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { connect } from 'react-redux';
|
||||||
import { openModal } from '../../../actions/modal';
|
import { openModal } from '../../../actions/modal';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
||||||
|
import { isStaff } from 'gabsocial/utils/accounts';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
import { logOut } from 'gabsocial/actions/auth';
|
import { logOut } from 'gabsocial/actions/auth';
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ const messages = defineMessages({
|
||||||
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
|
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Hidden domains' },
|
||||||
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
||||||
filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' },
|
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' },
|
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
||||||
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
|
keyboard_shortcuts: { id: 'navigation_bar.keyboard_shortcuts', defaultMessage: 'Hotkeys' },
|
||||||
});
|
});
|
||||||
|
@ -24,6 +26,7 @@ const mapStateToProps = state => {
|
||||||
const me = state.get('me');
|
const me = state.get('me');
|
||||||
return {
|
return {
|
||||||
meUsername: state.getIn(['accounts', me, 'username']),
|
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,
|
onOpenHotkeys: PropTypes.func.isRequired,
|
||||||
onClickLogOut: PropTypes.func.isRequired,
|
onClickLogOut: PropTypes.func.isRequired,
|
||||||
meUsername: PropTypes.string,
|
meUsername: PropTypes.string,
|
||||||
|
isStaff: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
isStaff: false,
|
||||||
|
}
|
||||||
|
|
||||||
handleHotkeyClick = () => {
|
handleHotkeyClick = () => {
|
||||||
this.props.onOpenHotkeys();
|
this.props.onOpenHotkeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { intl, onClickLogOut, meUsername } = this.props;
|
const { intl, onClickLogOut, meUsername, isStaff } = this.props;
|
||||||
const size = this.props.size || 16;
|
const size = this.props.size || 16;
|
||||||
|
|
||||||
let menu = [];
|
let menu = [];
|
||||||
|
@ -68,6 +76,9 @@ class ActionBar extends React.PureComponent {
|
||||||
// menu.push({ text: intl.formatMessage(messages.filters), to: '/filters' });
|
// menu.push({ text: intl.formatMessage(messages.filters), to: '/filters' });
|
||||||
menu.push(null);
|
menu.push(null);
|
||||||
menu.push({ text: intl.formatMessage(messages.keyboard_shortcuts), action: this.handleHotkeyClick });
|
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.preferences), to: '/settings/preferences' });
|
||||||
menu.push({ text: intl.formatMessage(messages.logout), to: '/auth/sign_out', action: onClickLogOut });
|
menu.push({ text: intl.formatMessage(messages.logout), to: '/auth/sign_out', action: onClickLogOut });
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue