bigbuffet-rw/app/soapbox/features/ui/components/boost_modal.js

71 lines
2.2 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
2020-03-27 13:59:38 -07:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
2022-01-10 14:01:24 -08:00
import ImmutablePureComponent from 'react-immutable-pure-component';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
2022-03-17 18:17:28 -07:00
import { withRouter } from 'react-router-dom';
import Icon from 'soapbox/components/icon';
2022-03-21 11:09:01 -07:00
import { Modal, Stack, Text } from 'soapbox/components/ui';
import ReplyIndicator from 'soapbox/features/compose/components/reply_indicator';
2020-03-27 13:59:38 -07:00
const messages = defineMessages({
cancel_reblog: { id: 'status.cancel_reblog_private', defaultMessage: 'Un-repost' },
reblog: { id: 'status.reblog', defaultMessage: 'Repost' },
});
2022-03-17 18:17:28 -07:00
export default @injectIntl @withRouter
2020-03-27 13:59:38 -07:00
class BoostModal extends ImmutablePureComponent {
static propTypes = {
2022-03-23 10:14:42 -07:00
status: ImmutablePropTypes.record.isRequired,
2020-03-27 13:59:38 -07:00
onReblog: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
2022-03-17 18:17:28 -07:00
history: PropTypes.object,
2020-03-27 13:59:38 -07:00
};
handleReblog = () => {
this.props.onReblog(this.props.status);
this.props.onClose();
}
handleAccountClick = (e) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.props.onClose();
2022-03-17 18:17:28 -07:00
this.props.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
2020-03-27 13:59:38 -07:00
}
}
handleStatusClick = (e) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.props.onClose();
2022-03-17 18:17:28 -07:00
this.props.history.push(`/@${this.props.status.getIn(['account', 'acct'])}/posts/${this.props.status.get('url')}`);
2020-03-27 13:59:38 -07:00
}
}
render() {
2020-03-27 13:59:38 -07:00
const { status, intl } = this.props;
const buttonText = status.get('reblogged') ? messages.cancel_reblog : messages.reblog;
return (
2022-03-21 11:09:01 -07:00
<Modal
title='Repost?'
2022-03-21 11:09:01 -07:00
confirmationAction={this.handleReblog}
confirmationText={intl.formatMessage(buttonText)}
>
<Stack space={4}>
<ReplyIndicator status={status} hideActions />
<Text>
<FormattedMessage id='boost_modal.combo' defaultMessage='You can press {combo} to skip this next time' values={{ combo: <span>Shift + <Icon id='retweet' /></span> }} />
</Text>
</Stack>
</Modal>
2020-03-27 13:59:38 -07:00
);
}
}