]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/features/ui/components/boost_modal.js
Restore vanilla components
[mastodon.git] / app / javascript / mastodon / features / ui / components / boost_modal.js
1 import React from 'react';
2 import ImmutablePropTypes from 'react-immutable-proptypes';
3 import PropTypes from 'prop-types';
4 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
5 import Button from '../../../components/button';
6 import StatusContent from '../../../components/status_content';
7 import Avatar from '../../../components/avatar';
8 import RelativeTimestamp from '../../../components/relative_timestamp';
9 import DisplayName from '../../../components/display_name';
10 import ImmutablePureComponent from 'react-immutable-pure-component';
11
12 const messages = defineMessages({
13 reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
14 });
15
16 @injectIntl
17 export default class BoostModal extends ImmutablePureComponent {
18
19 static contextTypes = {
20 router: PropTypes.object,
21 };
22
23 static propTypes = {
24 status: ImmutablePropTypes.map.isRequired,
25 onReblog: PropTypes.func.isRequired,
26 onClose: PropTypes.func.isRequired,
27 intl: PropTypes.object.isRequired,
28 };
29
30 componentDidMount() {
31 this.button.focus();
32 }
33
34 handleReblog = () => {
35 this.props.onReblog(this.props.status);
36 this.props.onClose();
37 }
38
39 handleAccountClick = (e) => {
40 if (e.button === 0) {
41 e.preventDefault();
42 this.props.onClose();
43 this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
44 }
45 }
46
47 setRef = (c) => {
48 this.button = c;
49 }
50
51 render () {
52 const { status, intl } = this.props;
53
54 return (
55 <div className='modal-root__modal boost-modal'>
56 <div className='boost-modal__container'>
57 <div className='status light'>
58 <div className='boost-modal__status-header'>
59 <div className='boost-modal__status-time'>
60 <a href={status.get('url')} className='status__relative-time' target='_blank' rel='noopener'><RelativeTimestamp timestamp={status.get('created_at')} /></a>
61 </div>
62
63 <a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} className='status__display-name'>
64 <div className='status__avatar'>
65 <Avatar account={status.get('account')} size={48} />
66 </div>
67
68 <DisplayName account={status.get('account')} />
69 </a>
70 </div>
71
72 <StatusContent status={status} />
73 </div>
74 </div>
75
76 <div className='boost-modal__action-bar'>
77 <div><FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <i className='fa fa-retweet' /></span> }} /></div>
78 <Button text={intl.formatMessage(messages.reblog)} onClick={this.handleReblog} ref={this.setRef} />
79 </div>
80 </div>
81 );
82 }
83
84 }
This page took 0.084681 seconds and 4 git commands to generate.