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.

59 lines
2.0 KiB

  1. import React, { Fragment } from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import PropTypes from 'prop-types';
  4. import Avatar from 'mastodon/components/avatar';
  5. import DisplayName from 'mastodon/components/display_name';
  6. import Permalink from 'mastodon/components/permalink';
  7. import IconButton from 'mastodon/components/icon_button';
  8. import { defineMessages, injectIntl } from 'react-intl';
  9. import ImmutablePureComponent from 'react-immutable-pure-component';
  10. const messages = defineMessages({
  11. authorize: { id: 'follow_request.authorize', defaultMessage: 'Authorize' },
  12. reject: { id: 'follow_request.reject', defaultMessage: 'Reject' },
  13. });
  14. export default @injectIntl
  15. class FollowRequest extends ImmutablePureComponent {
  16. static propTypes = {
  17. account: ImmutablePropTypes.map.isRequired,
  18. onAuthorize: PropTypes.func.isRequired,
  19. onReject: PropTypes.func.isRequired,
  20. intl: PropTypes.object.isRequired,
  21. };
  22. render () {
  23. const { intl, hidden, account, onAuthorize, onReject } = this.props;
  24. if (!account) {
  25. return <div />;
  26. }
  27. if (hidden) {
  28. return (
  29. <Fragment>
  30. {account.get('display_name')}
  31. {account.get('username')}
  32. </Fragment>
  33. );
  34. }
  35. return (
  36. <div className='account'>
  37. <div className='account__wrapper'>
  38. <Permalink key={account.get('id')} className='account__display-name' title={account.get('acct')} href={account.get('url')} to={`/accounts/${account.get('id')}`}>
  39. <div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
  40. <DisplayName account={account} />
  41. </Permalink>
  42. <div className='account__relationship'>
  43. <IconButton title={intl.formatMessage(messages.authorize)} icon='check' onClick={onAuthorize} />
  44. <IconButton title={intl.formatMessage(messages.reject)} icon='times' onClick={onReject} />
  45. </div>
  46. </div>
  47. </div>
  48. );
  49. }
  50. }