gab-social/app/javascript/gabsocial/components/modal/boost_modal.js

81 lines
2.3 KiB
JavaScript
Raw Normal View History

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
const messages = defineMessages({
2020-05-01 06:50:27 +01:00
removeRepost: { id: 'status.cancel_repost_private', defaultMessage: 'Remove Repost' },
2020-03-04 22:50:15 +00:00
repost: { id: 'status.repost', defaultMessage: 'Repost' },
2020-05-01 06:50:27 +01:00
combo: { id: 'boost_modal.combo', defaultMessage: 'You can press Shift + Repost to skip this next time' },
})
2020-04-23 07:13:29 +01:00
2020-02-25 16:04:44 +00:00
export default
@injectIntl
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
static propTypes = {
status: ImmutablePropTypes.map.isRequired,
2020-03-04 22:26:01 +00:00
onRepost: PropTypes.func.isRequired,
2019-07-02 08:10:25 +01:00
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
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}
>
<div className={[_s.default, _s.px15, _s.py10, _s.mt5].join(' ')}>
<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-05-01 06:50:27 +01:00
<div className={[_s.default, _s.justifyContentCenter, _s.px15, _s.mt5, _s.mb15].join(' ')}>
<Text align='center'>
{intl.formatMessage(messages.combo)}
</Text>
<div className={[_s.default, _s.flexRow, _s.justifyContentCenter, _s.my10, _s.pt15, _s.pb5].join(' ')}>
<Button onClick={this.handleRepost} buttonRef={this.setRef}>
<Text color='inherit' className={_s.px15}>
{intl.formatMessage(buttonText)}
</Text>
</Button>
</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
}
}