Use dynamic isStaff function
This commit is contained in:
parent
c6b9968855
commit
7712eb6621
3 changed files with 19 additions and 11 deletions
|
@ -7,7 +7,7 @@ import IconButton from './icon_button';
|
|||
import DropdownMenuContainer from '../containers/dropdown_menu_container';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { isStaff } from '../initial_state';
|
||||
import { isStaff } from 'gabsocial/utils/accounts';
|
||||
import { openModal } from '../actions/modal';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
|
@ -65,6 +65,8 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
withDismiss: PropTypes.bool,
|
||||
withGroupAdmin: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
me: PropTypes.string,
|
||||
account: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
// Avoid checking props that are functions (and whose equality will always
|
||||
|
@ -186,7 +188,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
_makeMenu = (publicStatus) => {
|
||||
const { status, intl, withDismiss, withGroupAdmin, me } = this.props;
|
||||
const { status, intl, withDismiss, withGroupAdmin, me, account } = this.props;
|
||||
const mutingConversation = status.get('muted');
|
||||
|
||||
let menu = [];
|
||||
|
@ -228,7 +230,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||
|
||||
if (isStaff) {
|
||||
if (isStaff(account)) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
|
@ -302,8 +304,10 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const me = state.get('me');
|
||||
return {
|
||||
me: state.get('me'),
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
|
|||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||
import Button from 'gabsocial/components/button';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
import { isStaff } from 'gabsocial/initial_state';
|
||||
import { isStaff } from 'gabsocial/utils/accounts';
|
||||
import classNames from 'classnames';
|
||||
import Avatar from 'gabsocial/components/avatar';
|
||||
import { shortNumberFormat } from 'gabsocial/utils/numbers';
|
||||
|
@ -48,8 +48,10 @@ const messages = defineMessages({
|
|||
});
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const me = state.get('me');
|
||||
return {
|
||||
me: state.get('me'),
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
autoPlayGif: state.getIn(['settings', 'autoPlayGif']),
|
||||
};
|
||||
};
|
||||
|
@ -163,7 +165,7 @@ class Header extends ImmutablePureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
if (account.get('id') !== me && isStaff) {
|
||||
if (account.get('id') !== me && isStaff(account)) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: account.get('username') }), href: `/admin/accounts/${account.get('id')}` });
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import IconButton from '../../../components/icon_button';
|
|||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import { isStaff } from '../../../initial_state';
|
||||
import { isStaff } from 'gabsocial/utils/accounts';
|
||||
|
||||
const messages = defineMessages({
|
||||
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
||||
|
@ -34,8 +34,10 @@ const messages = defineMessages({
|
|||
});
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const me = state.get('me');
|
||||
return {
|
||||
me: state.get('me'),
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -164,7 +166,7 @@ class ActionBar extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { status, intl, me } = this.props;
|
||||
const { status, intl, me, account } = this.props;
|
||||
|
||||
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
|
||||
const mutingConversation = status.get('muted');
|
||||
|
@ -198,7 +200,7 @@ class ActionBar extends React.PureComponent {
|
|||
menu.push({ text: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }), action: this.handleMuteClick });
|
||||
menu.push({ text: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }), action: this.handleBlockClick });
|
||||
menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport });
|
||||
if (isStaff) {
|
||||
if (isStaff(account)) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/admin/accounts/${status.getIn(['account', 'id'])}` });
|
||||
menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses/${status.get('id')}` });
|
||||
|
|
Loading…
Reference in a new issue