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.

85 lines
1.8 KiB

  1. // Package imports.
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import { defineMessages } from 'react-intl';
  5. // Components.
  6. import AccountContainer from 'flavours/glitch/containers/account_container';
  7. import IconButton from 'flavours/glitch/components/icon_button';
  8. // Utils.
  9. import { assignHandlers } from 'flavours/glitch/util/react_helpers';
  10. import { isRtl } from 'flavours/glitch/util/rtl';
  11. // Messages.
  12. const messages = defineMessages({
  13. cancel: {
  14. defaultMessage: 'Cancel',
  15. id: 'reply_indicator.cancel',
  16. },
  17. });
  18. // Handlers.
  19. const handlers = {
  20. // Handles a click on the "close" button.
  21. handleClick () {
  22. const { onCancel } = this.props;
  23. if (onCancel) {
  24. onCancel();
  25. }
  26. },
  27. };
  28. // The component.
  29. export default class ComposerReply extends React.PureComponent {
  30. // Constructor.
  31. constructor (props) {
  32. super(props);
  33. assignHandlers(this, handlers);
  34. }
  35. // Rendering.
  36. render () {
  37. const { handleClick } = this.handlers;
  38. const {
  39. account,
  40. content,
  41. intl,
  42. } = this.props;
  43. // The result.
  44. return (
  45. <article className='composer--reply'>
  46. <header>
  47. <IconButton
  48. className='cancel'
  49. icon='times'
  50. onClick={handleClick}
  51. title={intl.formatMessage(messages.cancel)}
  52. />
  53. {account ? (
  54. <AccountContainer
  55. id={account}
  56. small
  57. />
  58. ) : null}
  59. </header>
  60. <div
  61. className='content'
  62. dangerouslySetInnerHTML={{ __html: content || '' }}
  63. style={{ direction: isRtl(content) ? 'rtl' : 'ltr' }}
  64. />
  65. </article>
  66. );
  67. }
  68. }
  69. ComposerReply.propTypes = {
  70. account: PropTypes.string,
  71. content: PropTypes.string,
  72. intl: PropTypes.object.isRequired,
  73. onCancel: PropTypes.func,
  74. };