Ask for confirmation before canceling scheduled post
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
3c5a66648b
commit
154eab8273
3 changed files with 36 additions and 5 deletions
|
@ -6,10 +6,15 @@ import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types';
|
||||||
import IconButton from 'soapbox/components/icon_button';
|
import IconButton from 'soapbox/components/icon_button';
|
||||||
import { defineMessages, injectIntl } from 'react-intl';
|
import { defineMessages, injectIntl } from 'react-intl';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import { openModal } from 'soapbox/actions/modal';
|
||||||
import { cancelScheduledStatus } from 'soapbox/actions/scheduled_statuses';
|
import { cancelScheduledStatus } from 'soapbox/actions/scheduled_statuses';
|
||||||
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
cancel: { id: 'scheduled_status.cancel', defaultMessage: 'Cancel' },
|
cancel: { id: 'scheduled_status.cancel', defaultMessage: 'Cancel' },
|
||||||
|
deleteConfirm: { id: 'confirmations.scheduled_status_delete.confirm', defaultMessage: 'Cancel' },
|
||||||
|
deleteHeading: { id: 'confirmations.scheduled_status_delete.heading', defaultMessage: 'Cancel scheduled post' },
|
||||||
|
deleteMessage: { id: 'confirmations.scheduled_status_delete.message', defaultMessage: 'Are you sure you want to cancel this scheduled post?' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
|
@ -19,8 +24,26 @@ const mapStateToProps = state => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default @connect(mapStateToProps, null, null, { forwardRef: true })
|
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
@injectIntl
|
onCancelClick: (status) => {
|
||||||
|
dispatch((_, getState) => {
|
||||||
|
|
||||||
|
const deleteModal = getSettings(getState()).get('deleteModal');
|
||||||
|
if (!deleteModal) {
|
||||||
|
dispatch(cancelScheduledStatus(status.get('id')));
|
||||||
|
} else {
|
||||||
|
dispatch(openModal('CONFIRM', {
|
||||||
|
icon: require('@tabler/icons/icons/trash.svg'),
|
||||||
|
heading: intl.formatMessage(messages.deleteHeading),
|
||||||
|
message: intl.formatMessage(messages.deleteMessage),
|
||||||
|
confirm: intl.formatMessage(messages.deleteConfirm),
|
||||||
|
onConfirm: () => dispatch(cancelScheduledStatus(status.get('id'))),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
class ScheduledStatusActionBar extends ImmutablePureComponent {
|
class ScheduledStatusActionBar extends ImmutablePureComponent {
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
|
@ -31,11 +54,13 @@ class ScheduledStatusActionBar extends ImmutablePureComponent {
|
||||||
status: ImmutablePropTypes.map.isRequired,
|
status: ImmutablePropTypes.map.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
me: SoapboxPropTypes.me,
|
me: SoapboxPropTypes.me,
|
||||||
|
onCancelClick: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleCancelClick = e => {
|
handleCancelClick = e => {
|
||||||
const { status, dispatch } = this.props;
|
const { status, onCancelClick } = this.props;
|
||||||
dispatch(cancelScheduledStatus(status.get('id')));
|
|
||||||
|
onCancelClick(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -56,3 +81,6 @@ class ScheduledStatusActionBar extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ScheduledStatusActionBar));
|
||||||
|
|
|
@ -302,6 +302,9 @@
|
||||||
"confirmations.register.needs_confirmation": "Sprawdź swoją skrzynkę na {email}, aby znaleźć instrukcje potwierdzania. Musisz zweryfikować swój adres e-mail, aby kontynuować.",
|
"confirmations.register.needs_confirmation": "Sprawdź swoją skrzynkę na {email}, aby znaleźć instrukcje potwierdzania. Musisz zweryfikować swój adres e-mail, aby kontynuować.",
|
||||||
"confirmations.reply.confirm": "Odpowiedz",
|
"confirmations.reply.confirm": "Odpowiedz",
|
||||||
"confirmations.reply.message": "W ten sposób utracisz wpis który obecnie tworzysz. Czy na pewno chcesz to zrobić?",
|
"confirmations.reply.message": "W ten sposób utracisz wpis który obecnie tworzysz. Czy na pewno chcesz to zrobić?",
|
||||||
|
"confirmations.scheduled_status_delete.confirm": "Anuluj",
|
||||||
|
"confirmations.scheduled_status_delete.heading": "Anuluj zaplanowany wpis",
|
||||||
|
"confirmations.scheduled_status_delete.message": "Czy na pewno chcesz anulować ten zaplanowany wpis?",
|
||||||
"confirmations.unfollow.confirm": "Przestań śledzić",
|
"confirmations.unfollow.confirm": "Przestań śledzić",
|
||||||
"confirmations.unfollow.message": "Czy na pewno zamierzasz przestać śledzić {name}?",
|
"confirmations.unfollow.message": "Czy na pewno zamierzasz przestać śledzić {name}?",
|
||||||
"crypto_donate.explanation_box.message": "{siteTitle} przyjmuje darowizny w kryptowalutach. Możesz wysłać darowiznę na jeden z poniższych adresów. Dziękujemy za Wasze wsparcie!",
|
"crypto_donate.explanation_box.message": "{siteTitle} przyjmuje darowizny w kryptowalutach. Możesz wysłać darowiznę na jeden z poniższych adresów. Dziękujemy za Wasze wsparcie!",
|
||||||
|
|
Loading…
Reference in a new issue