闭社主体 forked from https://github.com/tootsuite/mastodon
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.

71 lines
2.2 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePureComponent from 'react-immutable-pure-component';
  4. import StatusContent from '../../../components/status_content';
  5. import Avatar from '../../../components/avatar';
  6. import RelativeTimestamp from '../../../components/relative_timestamp';
  7. import DisplayName from '../../../components/display_name';
  8. import IconButton from '../../../components/icon_button';
  9. export default class ActionsModal extends ImmutablePureComponent {
  10. static propTypes = {
  11. actions: PropTypes.array,
  12. onClick: PropTypes.func,
  13. };
  14. renderAction = (action, i) => {
  15. if (action === null) {
  16. return <li key={`sep-${i}`} className='dropdown__sep' />;
  17. }
  18. const { icon = null, text, meta = null, active = false, href = '#' } = action;
  19. return (
  20. <li key={`${text}-${i}`}>
  21. <a href={href} target='_blank' rel='noopener' onClick={this.props.onClick} data-index={i} className={active && 'active'}>
  22. {icon && <IconButton title={text} icon={icon} role='presentation' tabIndex='-1' />}
  23. <div>
  24. <div>{text}</div>
  25. <div>{meta}</div>
  26. </div>
  27. </a>
  28. </li>
  29. );
  30. }
  31. render () {
  32. const status = this.props.status && (
  33. <div className='status light'>
  34. <div className='boost-modal__status-header'>
  35. <div className='boost-modal__status-time'>
  36. <a href={this.props.status.get('url')} className='status__relative-time' target='_blank' rel='noopener'>
  37. <RelativeTimestamp timestamp={this.props.status.get('created_at')} />
  38. </a>
  39. </div>
  40. <a href={this.props.status.getIn(['account', 'url'])} className='status__display-name'>
  41. <div className='status__avatar'>
  42. <Avatar account={this.props.status.get('account')} size={48} />
  43. </div>
  44. <DisplayName account={this.props.status.get('account')} />
  45. </a>
  46. </div>
  47. <StatusContent status={this.props.status} />
  48. </div>
  49. );
  50. return (
  51. <div className='modal-root__modal actions-modal'>
  52. {status}
  53. <ul>
  54. {this.props.actions.map(this.renderAction)}
  55. </ul>
  56. </div>
  57. );
  58. }
  59. }