2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-05-01 06:50:27 +01:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import Button from '../button'
|
|
|
|
import StatusContainer from '../../containers/status_container'
|
|
|
|
import Text from '../text'
|
|
|
|
import ModalLayout from './modal_layout'
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
class BoostModal extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
2020-05-01 06:50:27 +01:00
|
|
|
}
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
componentDidMount() {
|
2020-05-01 06:50:27 +01:00
|
|
|
this.button.focus()
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
2020-03-04 22:26:01 +00:00
|
|
|
handleRepost = () => {
|
2020-05-01 06:50:27 +01:00
|
|
|
this.props.onRepost(this.props.status)
|
|
|
|
this.props.onClose()
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setRef = (c) => {
|
2020-05-01 06:50:27 +01:00
|
|
|
this.button = c
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2020-05-01 06:50:27 +01:00
|
|
|
const { status, onClose, intl } = this.props
|
|
|
|
|
|
|
|
const buttonText = status.get('reblogged') ? messages.removeRepost : messages.repost
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
return (
|
2020-05-01 06:50:27 +01:00
|
|
|
<ModalLayout
|
|
|
|
title={intl.formatMessage(messages.repost)}
|
|
|
|
noPadding
|
|
|
|
width={480}
|
|
|
|
onClose={onClose}
|
|
|
|
>
|
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.px15, _s.py10, _s.mt5].join(' ')}>
|
2020-05-01 06:50:27 +01:00
|
|
|
<StatusContainer
|
2020-05-05 06:16:01 +01:00
|
|
|
contextType='boost-modal'
|
2020-05-01 06:50:27 +01:00
|
|
|
id={status.get('id')}
|
|
|
|
isChild
|
|
|
|
/>
|
|
|
|
</div>
|
2019-07-02 08:10:25 +01:00
|
|
|
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.jcCenter, _s.px15, _s.mt5, _s.mb15].join(' ')}>
|
2020-05-01 06:50:27 +01:00
|
|
|
<Text align='center'>
|
|
|
|
{intl.formatMessage(messages.combo)}
|
|
|
|
</Text>
|
2020-08-18 21:49:11 +01:00
|
|
|
<div className={[_s.d, _s.flexRow, _s.jcCenter, _s.my10, _s.pt15, _s.pb5].join(' ')}>
|
2020-05-01 06:50:27 +01:00
|
|
|
<Button onClick={this.handleRepost} buttonRef={this.setRef}>
|
|
|
|
<Text color='inherit' className={_s.px15}>
|
|
|
|
{intl.formatMessage(buttonText)}
|
|
|
|
</Text>
|
|
|
|
</Button>
|
2019-08-07 06:02:36 +01:00
|
|
|
</div>
|
2019-07-02 08:10:25 +01:00
|
|
|
</div>
|
2020-05-01 06:50:27 +01:00
|
|
|
</ModalLayout>
|
|
|
|
)
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-18 18:07:47 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
removeRepost: { id: 'status.cancel_repost_private', defaultMessage: 'Remove Repost' },
|
|
|
|
repost: { id: 'status.repost', defaultMessage: 'Repost' },
|
|
|
|
combo: { id: 'boost_modal.combo', defaultMessage: 'You can press Shift + Repost to skip this next time' },
|
|
|
|
})
|
|
|
|
|
|
|
|
BoostModal.propTypes = {
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
onRepost: PropTypes.func.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(BoostModal)
|