2020-03-26 03:11:32 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
2020-03-25 03:08:43 +00:00
|
|
|
import PopoverLayout from './popover_layout'
|
|
|
|
import List from '../list'
|
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
const messages = defineMessages({
|
|
|
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
|
|
|
edit: { id: 'status.edit', defaultMessage: 'Edit' },
|
|
|
|
mention: { id: 'status.mention', defaultMessage: 'Mention @{name}' },
|
|
|
|
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
|
|
|
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
|
|
|
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
|
|
|
comment: { id: 'status.comment', defaultMessage: 'Comment' },
|
|
|
|
more: { id: 'status.more', defaultMessage: 'More' },
|
|
|
|
share: { id: 'status.share', defaultMessage: 'Share' },
|
|
|
|
replyAll: { id: 'status.replyAll', defaultMessage: 'Reply to thread' },
|
|
|
|
repost: { id: 'repost', defaultMessage: 'Repost' },
|
|
|
|
quote: { id: 'status.quote', defaultMessage: 'Quote' },
|
|
|
|
repost_private: { id: 'status.repost_private', defaultMessage: 'Repost to original audience' },
|
|
|
|
cancel_repost_private: { id: 'status.cancel_repost_private', defaultMessage: 'Un-repost' },
|
|
|
|
cannot_repost: { id: 'status.cannot_repost', defaultMessage: 'This post cannot be reposted' },
|
|
|
|
cannot_quote: { id: 'status.cannot_quote', defaultMessage: 'This post cannot be quoted' },
|
|
|
|
like: { id: 'status.like', defaultMessage: 'Like' },
|
|
|
|
open: { id: 'status.open', defaultMessage: 'Expand this status' },
|
|
|
|
report: { id: 'status.report', defaultMessage: 'Report @{name}' },
|
|
|
|
muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' },
|
|
|
|
unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' },
|
|
|
|
pin: { id: 'status.pin', defaultMessage: 'Pin on profile' },
|
|
|
|
unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' },
|
|
|
|
embed: { id: 'status.embed', defaultMessage: 'Embed' },
|
|
|
|
admin_account: { id: 'status.admin_account', defaultMessage: 'Open moderation interface for @{name}' },
|
|
|
|
admin_status: { id: 'status.admin_status', defaultMessage: 'Open this status in the moderation interface' },
|
|
|
|
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
|
|
|
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove status from group' },
|
|
|
|
})
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
export default
|
|
|
|
@injectIntl
|
|
|
|
class StatusOptionsPopover extends ImmutablePureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
onOpenUnauthorizedModal: PropTypes.func.isRequired,
|
|
|
|
onOpenStatusSharePopover: PropTypes.func.isRequired,
|
|
|
|
onReply: PropTypes.func,
|
|
|
|
onQuote: PropTypes.func,
|
|
|
|
onFavorite: PropTypes.func,
|
|
|
|
onRepost: PropTypes.func,
|
|
|
|
onDelete: PropTypes.func,
|
|
|
|
onMention: PropTypes.func,
|
|
|
|
onMute: PropTypes.func,
|
|
|
|
onBlock: PropTypes.func,
|
|
|
|
onReport: PropTypes.func,
|
|
|
|
onEmbed: PropTypes.func,
|
|
|
|
onMuteConversation: PropTypes.func,
|
|
|
|
onPin: PropTypes.func,
|
|
|
|
withDismiss: PropTypes.bool,
|
|
|
|
withGroupAdmin: PropTypes.bool,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
getItems = () => {
|
|
|
|
const { status, intl, withDismiss, withGroupAdmin } = this.props
|
|
|
|
const mutingConversation = status.get('muted')
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
let menu = [];
|
2020-03-04 03:45:16 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
menu.push({
|
|
|
|
icon: 'circle',
|
|
|
|
hideArrow: true,
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(messages.open),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handleOpen
|
|
|
|
});
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (publicStatus) {
|
|
|
|
menu.push({
|
|
|
|
icon: 'circle',
|
|
|
|
hideArrow: true,
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(messages.copy),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handleCopy,
|
|
|
|
})
|
|
|
|
menu.push({
|
|
|
|
icon: 'circle',
|
|
|
|
hideArrow: true,
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(messages.embed),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handleEmbed,
|
|
|
|
})
|
|
|
|
}
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (!me) return menu
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (status.getIn(['account', 'id']) === me || withDismiss) {
|
|
|
|
menu.push({
|
|
|
|
icon: 'circle',
|
|
|
|
hideArrow: true,
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(mutingConversation ? messages.unmuteConversation : messages.muteConversation),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handleConversationMuteClick,
|
|
|
|
})
|
|
|
|
}
|
2020-03-04 03:45:16 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (status.getIn(['account', 'id']) === me) {
|
|
|
|
if (publicStatus) {
|
|
|
|
menu.push({
|
|
|
|
icon: 'circle',
|
|
|
|
hideArrow: true,
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handlePinClick,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
if (status.get('visibility') === 'private') {
|
|
|
|
menu.push({
|
2020-03-31 17:04:50 +01:00
|
|
|
title: intl.formatMessage(status.get('reblogged') ? messages.cancel_repost_private : messages.repost_private),
|
2020-03-26 03:11:32 +00:00
|
|
|
onClick: this.handleRepostClick
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-03-31 17:04:50 +01:00
|
|
|
menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.edit), action: this.handleEditClick });
|
2020-03-26 03:11:32 +00:00
|
|
|
} else {
|
2020-03-31 17:04:50 +01:00
|
|
|
menu.push({ text: intl.formatMessage(messages.mention, { name: status.getIn(['account', 'username']) }), action: this.handleMentionClick });
|
|
|
|
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 });
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (isStaff) {
|
2020-03-31 17:04:50 +01:00
|
|
|
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')}` });
|
2020-03-26 03:11:32 +00:00
|
|
|
}
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
if (withGroupAdmin) {
|
2020-03-31 17:04:50 +01:00
|
|
|
menu.push({ text: intl.formatMessage(messages.group_remove_account), action: this.handleGroupRemoveAccount });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.group_remove_post), action: this.handleGroupRemovePost });
|
2020-03-26 03:11:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-04 03:45:16 +00:00
|
|
|
|
2020-03-25 03:08:43 +00:00
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-03-26 03:11:32 +00:00
|
|
|
const items = this.getItems()
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
return (
|
2020-03-25 03:08:43 +00:00
|
|
|
<PopoverLayout className={_s.width240PX}>
|
|
|
|
<List
|
2020-04-07 02:53:23 +01:00
|
|
|
size='large'
|
2020-03-25 03:08:43 +00:00
|
|
|
scrollKey='profile_options'
|
2020-03-26 03:11:32 +00:00
|
|
|
items={items}
|
2020-03-25 03:08:43 +00:00
|
|
|
/>
|
|
|
|
</PopoverLayout>
|
2020-02-24 21:56:07 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|