2019-07-02 08:10:25 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { me } from '../../../initial_state';
|
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import ComposeFormContainer from '../../compose/containers/compose_form_container';
|
|
|
|
import IconButton from 'gabsocial/components/icon_button';
|
2019-07-23 04:10:05 +01:00
|
|
|
import { openModal } from '../../../actions/modal';
|
|
|
|
import { cancelReplyCompose } from '../../../actions/compose';
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
2019-07-23 04:10:05 +01:00
|
|
|
confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
2019-07-02 08:10:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => {
|
|
|
|
return {
|
|
|
|
account: state.getIn(['accounts', me]),
|
2019-07-23 04:10:05 +01:00
|
|
|
composeText: state.getIn(['compose', 'text']),
|
2019-08-17 12:09:15 +01:00
|
|
|
composeId: state.getIn(['compose', 'id']),
|
2019-07-02 08:10:25 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class ComposeModal extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
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-08-17 12:09:15 +01:00
|
|
|
const {composeText, composeId, dispatch, onClose, intl} = this.props;
|
2019-07-23 04:10:05 +01:00
|
|
|
|
2019-08-17 12:09:15 +01:00
|
|
|
if (!composeId && composeText) {
|
2019-07-23 04:10:05 +01:00
|
|
|
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-10-18 05:55:30 +01:00
|
|
|
const { intl } = this.props;
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='modal-root__modal compose-modal'>
|
|
|
|
<div className='compose-modal__header'>
|
2019-10-18 05:55:30 +01:00
|
|
|
<h3 className='compose-modal__header__title'>
|
|
|
|
<FormattedMessage id='navigation_bar.compose' defaultMessage='Compose new gab' />
|
|
|
|
</h3>
|
2019-10-19 00:20:08 +01:00
|
|
|
<IconButton className='compose-modal__close' title={intl.formatMessage(messages.close)} icon='times' onClick={this.onClickClose} size={20} />
|
2019-07-02 08:10:25 +01:00
|
|
|
</div>
|
2019-10-18 05:55:30 +01:00
|
|
|
<div className='compose-modal__content compose-modal__content--scroll'>
|
2019-07-02 08:10:25 +01:00
|
|
|
<div className='timeline-compose-block'>
|
|
|
|
<ComposeFormContainer />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps)(ComposeModal));
|