import { Fragment } from 'react' import { injectIntl, defineMessages } from 'react-intl' import { NavLink } from 'react-router-dom' import ImmutablePropTypes from 'react-immutable-proptypes' import ImmutablePureComponent from 'react-immutable-pure-component' import classNames from 'classnames/bind' import { openPopover } from '../actions/popover' import { openModal } from '../actions/modal' import { me } from '../initial_state' 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 messages = defineMessages({ edited: { id: 'status.edited', defaultMessage: 'Edited' }, public_short: { id: 'privacy.public.short', defaultMessage: 'Public' }, public_long: { id: 'privacy.public.long', defaultMessage: 'Visible for anyone on or off Gab' }, unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' }, unlisted_long: { id: 'privacy.unlisted.long', defaultMessage: 'Do not show in public timelines' }, private_long: { id: 'privacy.private.long', defaultMessage: 'Visible for your followers only' }, }) const cx = classNames.bind(_s) const mapDispatchToProps = (dispatch) => ({ onOpenStatusRevisionsPopover(status) { dispatch(openModal('STATUS_REVISIONS', { status, })) }, onOpenStatusOptionsPopover(targetRef, status) { dispatch(openPopover('STATUS_OPTIONS', { targetRef, status, position: 'top', })) }, }) export default @injectIntl @connect(null, mapDispatchToProps) class StatusHeader extends ImmutablePureComponent { static propTypes = { intl: PropTypes.object.isRequired, status: ImmutablePropTypes.map, onOpenStatusRevisionsPopover: PropTypes.func.isRequired, onOpenStatusOptionsPopover: PropTypes.func.isRequired, reduced: PropTypes.bool, } handleOpenStatusOptionsPopover = () => { this.props.onOpenStatusOptionsPopover(this.statusOptionsButton, this.props.status) } handleOpenStatusEdits = () => { this.props.onOpenStatusRevisionsPopover(this.props.status) } setStatusOptionsButton = n => { this.statusOptionsButton = n } render() { const { intl, reduced, status, } = this.props const statusUrl = `/${status.getIn(['account', 'acct'])}/posts/${status.get('id')}` const containerClasses = cx({ default: 1, px15: 1, py10: !reduced, pb10: reduced, }) const avatarSize = reduced ? 20 : 46 const visibility = status.get('visibility') let visibilityIcon let visibilityText if (visibility === 'private') { visibilityIcon = 'lock-filled' visibilityText = intl.formatMessage(messages.private_long) } else if (visibility === 'unlisted') { visibilityIcon = 'unlock-filled' visibilityText = `${intl.formatMessage(messages.unlisted_short)} - ${intl.formatMessage(messages.unlisted_long)}` } else { visibilityIcon = 'globe' visibilityText = `${intl.formatMessage(messages.public_short)} - ${intl.formatMessage(messages.public_long)}` } return (