logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

reply_indicator.js (2090B)


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