2019-07-02 08:10:25 +01:00
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2020-02-24 23:25:55 +00:00
|
|
|
import { openModal } from '../../actions/modal';
|
|
|
|
import { cancelReplyCompose } from '../../actions/compose';
|
|
|
|
import ModalLayout from './modal_layout';
|
|
|
|
import TimelineComposeBlock from '../timeline_compose_block';
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
2019-07-23 04:10:05 +01:00
|
|
|
confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
2019-08-07 06:02:36 +01:00
|
|
|
title: { id: 'navigation_bar.compose', defaultMessage: 'Compose new gab' },
|
2019-07-02 08:10:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
2019-07-23 04:10:05 +01:00
|
|
|
composeText: state.getIn(['compose', 'text']),
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-25 16:04:44 +00:00
|
|
|
export default
|
|
|
|
@connect(mapStateToProps)
|
2019-08-07 06:02:36 +01:00
|
|
|
@injectIntl
|
2019-07-02 08:10:25 +01:00
|
|
|
class ComposeModal extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
2019-07-23 04:10:05 +01:00
|
|
|
composeText: PropTypes.string,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
onClickClose = () => {
|
2019-07-23 04:10:05 +01:00
|
|
|
const {composeText, dispatch, onClose, intl} = this.props;
|
|
|
|
|
|
|
|
if (composeText) {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: <FormattedMessage id='confirmations.delete.message' defaultMessage='Are you sure you want to delete this status?' />,
|
|
|
|
confirm: intl.formatMessage(messages.confirm),
|
|
|
|
onConfirm: () => dispatch(cancelReplyCompose()),
|
|
|
|
onCancel: () => dispatch(openModal('COMPOSE')),
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
onClose('COMPOSE');
|
|
|
|
}
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2019-08-13 16:54:29 +01:00
|
|
|
const { intl } = this.props;
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
return (
|
2020-01-27 19:46:42 +00:00
|
|
|
<ModalLayout title={intl.formatMessage(messages.title)} onClose={this.onClickClose}>
|
2019-08-13 16:54:29 +01:00
|
|
|
<TimelineComposeBlock />
|
2019-08-07 06:02:36 +01:00
|
|
|
</ModalLayout>
|
2019-07-02 08:10:25 +01:00
|
|
|
);
|
|
|
|
}
|
2020-01-28 16:29:37 +00:00
|
|
|
}
|