@ -27,6 +27,7 @@ const checkComposeContent = compose => {
const mapStateToProps = state => ( {
const mapStateToProps = state => ( {
hasComposeContent : checkComposeContent ( state . get ( 'compose' ) ) ,
hasComposeContent : checkComposeContent ( state . get ( 'compose' ) ) ,
isEditing : state . compose . get ( 'id' ) !== null ,
} ) ;
} ) ;
const mapDispatchToProps = ( dispatch ) => ( {
const mapDispatchToProps = ( dispatch ) => ( {
@ -53,6 +54,7 @@ class ModalRoot extends React.PureComponent {
onCancelReplyCompose : PropTypes . func . isRequired ,
onCancelReplyCompose : PropTypes . func . isRequired ,
intl : PropTypes . object . isRequired ,
intl : PropTypes . object . isRequired ,
hasComposeContent : PropTypes . bool ,
hasComposeContent : PropTypes . bool ,
isEditing : PropTypes . bool ,
type : PropTypes . string ,
type : PropTypes . string ,
onCancel : PropTypes . func ,
onCancel : PropTypes . func ,
history : PropTypes . object ,
history : PropTypes . object ,
@ -72,13 +74,13 @@ class ModalRoot extends React.PureComponent {
}
}
handleOnClose = ( ) => {
handleOnClose = ( ) => {
const { onOpenModal , onCloseModal , hasComposeContent , i ntl, type , onCancelReplyCompose } = this . props ;
const { onOpenModal , onCloseModal , hasComposeContent , i sEditing, i ntl, type , onCancelReplyCompose } = this . props ;
if ( hasComposeContent && type === 'COMPOSE' ) {
if ( hasComposeContent && type === 'COMPOSE' ) {
onOpenModal ( 'CONFIRM' , {
onOpenModal ( 'CONFIRM' , {
icon : require ( '@tabler/icons/icons/trash.svg' ) ,
icon : require ( '@tabler/icons/icons/trash.svg' ) ,
heading : < FormattedMessage id = 'confirmations.delete.heading' defaultMessage = 'Delete post' / > ,
heading : isEditing ? < FormattedMessage id = 'confirmations.cancel_editing.heading' defaultMessage = 'Cancel post editing' / > : < FormattedMessage id = 'confirmations.delete.heading' defaultMessage = 'Delete post' / > ,
message : < FormattedMessage id = 'confirmations.delete.message' defaultMessage = 'Are you sure you want to delete this post?' / > ,
message : isEditing ? < FormattedMessage id = 'confirmations.cancel_editing.message' defaultMessage = 'Are you sure you want to cancel editing this post? All changes will be lost.' / > : < FormattedMessage id = 'confirmations.delete.message' defaultMessage = 'Are you sure you want to delete this post?' / > ,
confirm : intl . formatMessage ( messages . confirm ) ,
confirm : intl . formatMessage ( messages . confirm ) ,
onConfirm : ( ) => onCancelReplyCompose ( ) ,
onConfirm : ( ) => onCancelReplyCompose ( ) ,
onCancel : ( ) => onCloseModal ( 'CONFIRM' ) ,
onCancel : ( ) => onCloseModal ( 'CONFIRM' ) ,