Change confirmation modal for edited posts
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
615ff427e4
commit
921d7c1935
2 changed files with 7 additions and 3 deletions
|
@ -27,6 +27,7 @@ const checkComposeContent = compose => {
|
|||
|
||||
const mapStateToProps = state => ({
|
||||
hasComposeContent: checkComposeContent(state.get('compose')),
|
||||
isEditing: state.compose.get('id') !== null,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
|
@ -53,6 +54,7 @@ class ModalRoot extends React.PureComponent {
|
|||
onCancelReplyCompose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired,
|
||||
hasComposeContent: PropTypes.bool,
|
||||
isEditing: PropTypes.bool,
|
||||
type: PropTypes.string,
|
||||
onCancel: PropTypes.func,
|
||||
history: PropTypes.object,
|
||||
|
@ -72,13 +74,13 @@ class ModalRoot extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleOnClose = () => {
|
||||
const { onOpenModal, onCloseModal, hasComposeContent, intl, type, onCancelReplyCompose } = this.props;
|
||||
const { onOpenModal, onCloseModal, hasComposeContent, isEditing, intl, type, onCancelReplyCompose } = this.props;
|
||||
|
||||
if (hasComposeContent && type === 'COMPOSE') {
|
||||
onOpenModal('CONFIRM', {
|
||||
icon: require('@tabler/icons/icons/trash.svg'),
|
||||
heading: <FormattedMessage id='confirmations.delete.heading' defaultMessage='Delete post' />,
|
||||
message: <FormattedMessage id='confirmations.delete.message' defaultMessage='Are you sure you want to delete this post?' />,
|
||||
heading: isEditing ? <FormattedMessage id='confirmations.cancel_editing.heading' defaultMessage='Cancel post editing' /> : <FormattedMessage id='confirmations.delete.heading' defaultMessage='Delete 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),
|
||||
onConfirm: () => onCancelReplyCompose(),
|
||||
onCancel: () => onCloseModal('CONFIRM'),
|
||||
|
|
|
@ -325,6 +325,8 @@
|
|||
"confirmations.block.confirm": "Zablokuj",
|
||||
"confirmations.block.heading": "Zablokuj @{name}",
|
||||
"confirmations.block.message": "Czy na pewno chcesz zablokować {name}?",
|
||||
"confirmations.cancel_editing.heading": "Anuluj edycję wpisu",
|
||||
"confirmations.cancel_editing.message": "Czy na pewno chcesz anulować edytowanie wpisu? Niezapisane zmiany zostaną utracone.",
|
||||
"confirmations.delete.confirm": "Usuń",
|
||||
"confirmations.delete.heading": "Usuń wpis",
|
||||
"confirmations.delete.message": "Czy na pewno chcesz usunąć ten wpis?",
|
||||
|
|
Loading…
Reference in a new issue