sforkowany z mirror/soapbox
Refactor isStaff, fixing profile page issues
rodzic
e761942ced
commit
2de1b5466e
|
@ -66,9 +66,13 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
withGroupAdmin: PropTypes.bool,
|
||||
intl: PropTypes.object.isRequired,
|
||||
me: PropTypes.string,
|
||||
account: ImmutablePropTypes.map,
|
||||
isStaff: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isStaff: false,
|
||||
}
|
||||
|
||||
// Avoid checking props that are functions (and whose equality will always
|
||||
// evaluate to false. See react-immutable-pure-component for usage.
|
||||
updateOnProps = [
|
||||
|
@ -188,7 +192,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
}
|
||||
|
||||
_makeMenu = (publicStatus) => {
|
||||
const { status, intl, withDismiss, withGroupAdmin, me, account } = this.props;
|
||||
const { status, intl, withDismiss, withGroupAdmin, me, isStaff } = this.props;
|
||||
const mutingConversation = status.get('muted');
|
||||
|
||||
let menu = [];
|
||||
|
@ -230,7 +234,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(account)) {
|
||||
if (isStaff) {
|
||||
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')}` });
|
||||
|
@ -307,7 +311,7 @@ const mapStateToProps = state => {
|
|||
const me = state.get('me');
|
||||
return {
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
isStaff: isStaff(state.getIn(['accounts', me])),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ const mapStateToProps = state => {
|
|||
const me = state.get('me');
|
||||
return {
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
isStaff: isStaff(state.getIn(['accounts', me])),
|
||||
autoPlayGif: state.getIn(['settings', 'autoPlayGif']),
|
||||
};
|
||||
};
|
||||
|
@ -69,8 +69,13 @@ class Header extends ImmutablePureComponent {
|
|||
domain: PropTypes.string.isRequired,
|
||||
username: PropTypes.string,
|
||||
autoPlayGif: PropTypes.bool,
|
||||
isStaff: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isStaff: false,
|
||||
}
|
||||
|
||||
state = {
|
||||
isSmallScreen: (window.innerWidth <= 895),
|
||||
}
|
||||
|
@ -102,7 +107,7 @@ class Header extends ImmutablePureComponent {
|
|||
});
|
||||
|
||||
makeMenu() {
|
||||
const { account, intl, me } = this.props;
|
||||
const { account, intl, me, isStaff } = this.props;
|
||||
|
||||
let menu = [];
|
||||
|
||||
|
@ -165,7 +170,7 @@ class Header extends ImmutablePureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
if (account.get('id') !== me && isStaff(account)) {
|
||||
if (account.get('id') !== me && isStaff) {
|
||||
menu.push(null);
|
||||
menu.push({ text: intl.formatMessage(messages.admin_account, { name: account.get('username') }), href: `/admin/accounts/${account.get('id')}` });
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ const mapStateToProps = state => {
|
|||
const me = state.get('me');
|
||||
return {
|
||||
me,
|
||||
account: state.getIn(['accounts', me]),
|
||||
isStaff: isStaff(state.getIn(['accounts', me])),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -70,9 +70,13 @@ class ActionBar extends React.PureComponent {
|
|||
intl: PropTypes.object.isRequired,
|
||||
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
||||
me: PropTypes.string,
|
||||
account: ImmutablePropTypes.map,
|
||||
isStaff: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
isStaff: false,
|
||||
}
|
||||
|
||||
handleReplyClick = () => {
|
||||
const { me } = this.props;
|
||||
if (me) {
|
||||
|
@ -167,7 +171,7 @@ class ActionBar extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { status, intl, me, account } = this.props;
|
||||
const { status, intl, me, isStaff } = this.props;
|
||||
|
||||
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'));
|
||||
const mutingConversation = status.get('muted');
|
||||
|
@ -201,7 +205,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(account)) {
|
||||
if (isStaff) {
|
||||
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')}` });
|
||||
|
|
Ładowanie…
Reference in New Issue