You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.0 KiB

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import Avatar from '../../../components/avatar';
  5. import IconButton from '../../../components/icon_button';
  6. import DisplayName from '../../../components/display_name';
  7. import emojify from '../../../emoji';
  8. import { defineMessages, injectIntl } from 'react-intl';
  9. import ImmutablePureComponent from 'react-immutable-pure-component';
  10. const messages = defineMessages({
  11. cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' }
  12. });
  13. class ReplyIndicator extends ImmutablePureComponent {
  14. static contextTypes = {
  15. router: PropTypes.object
  16. };
  17. static propTypes = {
  18. status: ImmutablePropTypes.map,
  19. onCancel: PropTypes.func.isRequired,
  20. intl: PropTypes.object.isRequired
  21. };
  22. handleClick = () => {
  23. this.props.onCancel();
  24. }
  25. handleAccountClick = (e) => {
  26. if (e.button === 0) {
  27. e.preventDefault();
  28. this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
  29. }
  30. }
  31. render () {
  32. const { status, intl } = this.props;
  33. if (!status) {
  34. return null;
  35. }
  36. const content = { __html: emojify(status.get('content')) };
  37. return (
  38. <div className='reply-indicator'>
  39. <div className='reply-indicator__header'>
  40. <div className='reply-indicator__cancel'><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} /></div>
  41. <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name'>
  42. <div className='reply-indicator__display-avatar'><Avatar size={24} src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} /></div>
  43. <DisplayName account={status.get('account')} />
  44. </a>
  45. </div>
  46. <div className='reply-indicator__content' dangerouslySetInnerHTML={content} />
  47. </div>
  48. );
  49. }
  50. }
  51. export default injectIntl(ReplyIndicator);