import { Fragment } from 'react' import { NavLink } from 'react-router-dom' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import { openPopover } from '../actions/popover' import { openModal } from '../actions/modal' import RelativeTimestamp from './relative_timestamp' import DisplayName from './display_name' import Text from './text' import DotTextSeperator from './dot_text_seperator' import Icon from './icon' import Button from './button' import Avatar from './avatar' const mapDispatchToProps = (dispatch) => ({ onOpenStatusRevisionsPopover(status) { dispatch(openModal('STATUS_REVISIONS', { status, })) }, onOpenStatusOptionsPopover(targetRef, status) { dispatch(openPopover('STATUS_OPTIONS', { targetRef, status, position: 'top', })) }, }) export default @connect(null, mapDispatchToProps) class StatusHeader extends ImmutablePureComponent { static propTypes = { status: ImmutablePropTypes.map, onOpenStatusRevisionsPopover: PropTypes.func.isRequired, onOpenStatusOptionsPopover: PropTypes.func.isRequired, } handleOpenStatusOptionsPopover = () => { this.props.onOpenStatusOptionsPopover(this.statusOptionsButton, this.props.status) } handleOpenStatusEdits = () => { this.props.onOpenStatusRevisionsPopover(this.props.status) } handleDeleteClick = () => { this.props.onDelete(this.props.status, this.context.router.history); } handleEditClick = () => { this.props.onEdit(this.props.status); } handlePinClick = () => { this.props.onPin(this.props.status); } handleMentionClick = () => { this.props.onMention(this.props.status.get('account'), this.context.router.history); } handleMuteClick = () => { this.props.onMute(this.props.status.get('account')); } handleBlockClick = () => { this.props.onBlock(this.props.status); } handleOpen = () => { this.context.router.history.push(`/${this.props.status.getIn(['account', 'acct'])}/posts/${this.props.status.get('id')}`); } handleEmbed = () => { this.props.onEmbed(this.props.status); } handleReport = () => { this.props.onReport(this.props.status); } handleConversationMuteClick = () => { this.props.onMuteConversation(this.props.status); } handleCopy = () => { const url = this.props.status.get('url'); const textarea = document.createElement('textarea'); textarea.textContent = url; textarea.style.position = 'fixed'; document.body.appendChild(textarea); try { textarea.select(); document.execCommand('copy'); } catch (e) { // } finally { document.body.removeChild(textarea); } } handleGroupRemoveAccount = () => { const { status } = this.props; this.props.onGroupRemoveAccount(status.getIn(['group', 'id']), status.getIn(['account', 'id'])); } handleGroupRemovePost = () => { const { status } = this.props; this.props.onGroupRemoveStatus(status.getIn(['group', 'id']), status.get('id')); } setStatusOptionsButton = n => { this.statusOptionsButton = n } render() { const { status } = this.props const statusUrl = `/${status.getIn(['account', 'acct'])}/posts/${status.get('id')}`; return (
{ !!status.get('group') && } { status.get('revised_at') !== null && }
) } }