From ffbdfb57129b0bcd3943d53edb459e16a9d2ff88 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 15 Jul 2021 11:20:15 -0500 Subject: [PATCH] Statuses: refactor visibility of moderator actions --- app/soapbox/components/status_action_bar.js | 34 +++++++++++-------- .../features/status/components/action_bar.js | 23 ++++++++----- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/soapbox/components/status_action_bar.js b/app/soapbox/components/status_action_bar.js index 47fe89956..aa49725cf 100644 --- a/app/soapbox/components/status_action_bar.js +++ b/app/soapbox/components/status_action_bar.js @@ -277,6 +277,7 @@ class StatusActionBar extends ImmutablePureComponent { _makeMenu = (publicStatus) => { const { status, intl, withDismiss, withGroupAdmin, me, isStaff, isAdmin } = this.props; const mutingConversation = status.get('muted'); + const self = status.getIn(['account', 'id']) === me; let menu = []; @@ -295,12 +296,12 @@ class StatusActionBar extends ImmutablePureComponent { menu.push(null); - if (status.getIn(['account', 'id']) === me || withDismiss) { + if (self || withDismiss) { menu.push({ text: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMuteClick }); menu.push(null); } - if (status.getIn(['account', 'id']) === me) { + if (self) { if (publicStatus) { menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); } else { @@ -318,24 +319,29 @@ class StatusActionBar extends ImmutablePureComponent { 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) { - menu.push(null); - if (isAdmin) { - menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/pleroma/admin/#/users/${status.getIn(['account', 'id'])}/` }); - menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/` }); - } + if (isStaff) { + menu.push(null); + + if (isAdmin) { + menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/pleroma/admin/#/users/${status.getIn(['account', 'id'])}/` }); + menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/` }); + } + + menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity }); + + if (!self) { menu.push({ text: intl.formatMessage(messages.deactivateUser, { name: status.getIn(['account', 'username']) }), action: this.handleDeactivateUser }); menu.push({ text: intl.formatMessage(messages.deleteUser, { name: status.getIn(['account', 'username']) }), action: this.handleDeleteUser }); - menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity }); menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus }); } + } - if (withGroupAdmin) { - menu.push(null); - menu.push({ text: intl.formatMessage(messages.group_remove_account), action: this.handleGroupRemoveAccount }); - menu.push({ text: intl.formatMessage(messages.group_remove_post), action: this.handleGroupRemovePost }); - } + if (!self && withGroupAdmin) { + menu.push(null); + menu.push({ text: intl.formatMessage(messages.group_remove_account), action: this.handleGroupRemoveAccount }); + menu.push({ text: intl.formatMessage(messages.group_remove_post), action: this.handleGroupRemovePost }); } return menu; diff --git a/app/soapbox/features/status/components/action_bar.js b/app/soapbox/features/status/components/action_bar.js index bac2b19c4..f22f96e1b 100644 --- a/app/soapbox/features/status/components/action_bar.js +++ b/app/soapbox/features/status/components/action_bar.js @@ -269,6 +269,7 @@ class ActionBar extends React.PureComponent { render() { const { status, intl, me, isStaff, isAdmin, allowedEmoji } = this.props; const { emojiSelectorVisible } = this.state; + const self = status.getIn(['account', 'id']) === me; const publicStatus = ['public', 'unlisted'].includes(status.get('visibility')); const mutingConversation = status.get('muted'); @@ -293,7 +294,7 @@ class ActionBar extends React.PureComponent { menu.push(null); - if (me === status.getIn(['account', 'id'])) { + if (self) { if (publicStatus) { menu.push({ text: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin), action: this.handlePinClick }); } else { @@ -314,15 +315,21 @@ 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) { - menu.push(null); - if (isAdmin) { - menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/pleroma/admin/#/users/${status.getIn(['account', 'id'])}/` }); - menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/` }); - } + } + + if (isStaff) { + menu.push(null); + + if (isAdmin) { + menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: `/pleroma/admin/#/users/${status.getIn(['account', 'id'])}/` }); + menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/` }); + } + + menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity }); + + if (!self) { menu.push({ text: intl.formatMessage(messages.deactivateUser, { name: status.getIn(['account', 'username']) }), action: this.handleDeactivateUser }); menu.push({ text: intl.formatMessage(messages.deleteUser, { name: status.getIn(['account', 'username']) }), action: this.handleDeleteUser }); - menu.push({ text: intl.formatMessage(status.get('sensitive') === false ? messages.markStatusSensitive : messages.markStatusNotSensitive), action: this.handleToggleStatusSensitivity }); menu.push({ text: intl.formatMessage(messages.deleteStatus), action: this.handleDeleteStatus }); } }