]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/compose/components/reply_indicator.js
Improve eslint rules (#3147)
[mastodon.git] / app / javascript / mastodon / features / compose / components / reply_indicator.js
1 import React from 'react';
2 import ImmutablePropTypes from 'react-immutable-proptypes';
3 import PropTypes from 'prop-types';
4 import Avatar from '../../../components/avatar';
5 import IconButton from '../../../components/icon_button';
6 import DisplayName from '../../../components/display_name';
7 import emojify from '../../../emoji';
8 import { defineMessages, injectIntl } from 'react-intl';
9 import ImmutablePureComponent from 'react-immutable-pure-component';
10
11 const messages = defineMessages({
12 cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
13 });
14
15 class ReplyIndicator extends ImmutablePureComponent {
16
17 static contextTypes = {
18 router: PropTypes.object,
19 };
20
21 static propTypes = {
22 status: ImmutablePropTypes.map,
23 onCancel: PropTypes.func.isRequired,
24 intl: PropTypes.object.isRequired,
25 };
26
27 handleClick = () => {
28 this.props.onCancel();
29 }
30
31 handleAccountClick = (e) => {
32 if (e.button === 0) {
33 e.preventDefault();
34 this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
35 }
36 }
37
38 render () {
39 const { status, intl } = this.props;
40
41 if (!status) {
42 return null;
43 }
44
45 const content = { __html: emojify(status.get('content')) };
46
47 return (
48 <div className='reply-indicator'>
49 <div className='reply-indicator__header'>
50 <div className='reply-indicator__cancel'><IconButton title={intl.formatMessage(messages.cancel)} icon='times' onClick={this.handleClick} /></div>
51
52 <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='reply-indicator__display-name'>
53 <div className='reply-indicator__display-avatar'><Avatar size={24} src={status.getIn(['account', 'avatar'])} staticSrc={status.getIn(['account', 'avatar_static'])} /></div>
54 <DisplayName account={status.get('account')} />
55 </a>
56 </div>
57
58 <div className='reply-indicator__content' dangerouslySetInnerHTML={content} />
59 </div>
60 );
61 }
62
63 }
64
65 export default injectIntl(ReplyIndicator);
This page took 0.096942 seconds and 4 git commands to generate.