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 => ({
|
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, intl, type, onCancelReplyCompose } = this.props;
|
const { onOpenModal, onCloseModal, hasComposeContent, isEditing, intl, 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'),
|
||||||
|
|
|
@ -325,6 +325,8 @@
|
||||||
"confirmations.block.confirm": "Zablokuj",
|
"confirmations.block.confirm": "Zablokuj",
|
||||||
"confirmations.block.heading": "Zablokuj @{name}",
|
"confirmations.block.heading": "Zablokuj @{name}",
|
||||||
"confirmations.block.message": "Czy na pewno chcesz zablokować {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.confirm": "Usuń",
|
||||||
"confirmations.delete.heading": "Usuń wpis",
|
"confirmations.delete.heading": "Usuń wpis",
|
||||||
"confirmations.delete.message": "Czy na pewno chcesz usunąć ten wpis?",
|
"confirmations.delete.message": "Czy na pewno chcesz usunąć ten wpis?",
|
||||||
|
|
Loading…
Reference in a new issue