logo

mastofe

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

actions_modal.js (2466B)


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