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.

87 lines
2.3 KiB

  1. // Package imports //
  2. import React from 'react';
  3. import PropTypes from 'prop-types';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import { FormattedMessage } from 'react-intl';
  6. export default class StatusPrepend extends React.PureComponent {
  7. static propTypes = {
  8. type: PropTypes.string.isRequired,
  9. account: ImmutablePropTypes.map.isRequired,
  10. parseClick: PropTypes.func.isRequired,
  11. notificationId: PropTypes.number,
  12. };
  13. handleClick = (e) => {
  14. const { account, parseClick } = this.props;
  15. parseClick(e, `/accounts/${+account.get('id')}`);
  16. }
  17. Message = () => {
  18. const { type, account } = this.props;
  19. let link = (
  20. <a
  21. onClick={this.handleClick}
  22. href={account.get('url')}
  23. className='status__display-name'
  24. >
  25. <b
  26. dangerouslySetInnerHTML={{
  27. __html : account.get('display_name_html') || account.get('username'),
  28. }}
  29. />
  30. </a>
  31. );
  32. switch (type) {
  33. case 'featured':
  34. return (
  35. <FormattedMessage id='status.pinned' defaultMessage='Pinned toot' />
  36. );
  37. case 'reblogged_by':
  38. return (
  39. <FormattedMessage
  40. id='status.reblogged_by'
  41. defaultMessage='{name} boosted'
  42. values={{ name : link }}
  43. />
  44. );
  45. case 'favourite':
  46. return (
  47. <FormattedMessage
  48. id='notification.favourite'
  49. defaultMessage='{name} favourited your status'
  50. values={{ name : link }}
  51. />
  52. );
  53. case 'reblog':
  54. return (
  55. <FormattedMessage
  56. id='notification.reblog'
  57. defaultMessage='{name} boosted your status'
  58. values={{ name : link }}
  59. />
  60. );
  61. }
  62. return null;
  63. }
  64. render () {
  65. const { Message } = this;
  66. const { type } = this.props;
  67. return !type ? null : (
  68. <aside className={type === 'reblogged_by' || type === 'featured' ? 'status__prepend' : 'notification__message'}>
  69. <div className={type === 'reblogged_by' || type === 'featured' ? 'status__prepend-icon-wrapper' : 'notification__favourite-icon-wrapper'}>
  70. <i
  71. className={`fa fa-fw fa-${
  72. type === 'favourite' ? 'star star-icon' : (type === 'featured' ? 'thumb-tack' : 'retweet')
  73. } status__prepend-icon`}
  74. />
  75. </div>
  76. <Message />
  77. </aside>
  78. );
  79. }
  80. }