Allow disabling media confirmation from the confirmation dialog itself
parent
490d8fff0b
commit
056a8a8ee4
|
@ -30,6 +30,7 @@ import {
|
||||||
closeModal,
|
closeModal,
|
||||||
openModal,
|
openModal,
|
||||||
} from 'flavours/glitch/actions/modal';
|
} from 'flavours/glitch/actions/modal';
|
||||||
|
import { changeLocalSetting } from 'flavours/glitch/actions/local_settings';
|
||||||
|
|
||||||
// Components.
|
// Components.
|
||||||
import ComposerOptions from './options';
|
import ComposerOptions from './options';
|
||||||
|
@ -165,6 +166,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
message: intl.formatMessage(messages.missingDescriptionMessage),
|
message: intl.formatMessage(messages.missingDescriptionMessage),
|
||||||
confirm: intl.formatMessage(messages.missingDescriptionConfirm),
|
confirm: intl.formatMessage(messages.missingDescriptionConfirm),
|
||||||
onConfirm: () => dispatch(submitCompose(routerHistory)),
|
onConfirm: () => dispatch(submitCompose(routerHistory)),
|
||||||
|
onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_missing_media_description'], false)),
|
||||||
|
onConfirm: () => dispatch(submitCompose()),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
onSubmit(routerHistory) {
|
onSubmit(routerHistory) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ export default class ConfirmationModal extends React.PureComponent {
|
||||||
confirm: PropTypes.string.isRequired,
|
confirm: PropTypes.string.isRequired,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
|
onDoNotAsk: PropTypes.func,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,6 +22,9 @@ export default class ConfirmationModal extends React.PureComponent {
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
this.props.onClose();
|
this.props.onClose();
|
||||||
this.props.onConfirm();
|
this.props.onConfirm();
|
||||||
|
if (this.props.onDoNotAsk && this.doNotAskCheckbox.checked) {
|
||||||
|
this.props.onDoNotAsk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCancel = () => {
|
handleCancel = () => {
|
||||||
|
@ -31,8 +35,12 @@ export default class ConfirmationModal extends React.PureComponent {
|
||||||
this.button = c;
|
this.button = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDoNotAskRef = (c) => {
|
||||||
|
this.doNotAskCheckbox = c;
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { message, confirm } = this.props;
|
const { message, confirm, onDoNotAsk } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='modal-root__modal confirmation-modal'>
|
<div className='modal-root__modal confirmation-modal'>
|
||||||
|
@ -40,11 +48,21 @@ export default class ConfirmationModal extends React.PureComponent {
|
||||||
{message}
|
{message}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='confirmation-modal__action-bar'>
|
<div>
|
||||||
<Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
|
{ onDoNotAsk && (
|
||||||
<FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
|
<div className='confirmation-modal__do_not_ask_again'>
|
||||||
</Button>
|
<input type='checkbox' id='confirmation-modal__do_not_ask_again-checkbox' ref={this.setDoNotAskRef} />
|
||||||
<Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
|
<label for='confirmation-modal__do_not_ask_again-checkbox'>
|
||||||
|
<FormattedMessage id='confirmation_modal.do_not_ask_again' defaultMessage='Do not ask for confirmation again' />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className='confirmation-modal__action-bar'>
|
||||||
|
<Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
|
||||||
|
<FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
|
||||||
|
</Button>
|
||||||
|
<Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -686,6 +686,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.confirmation-modal__do_not_ask_again {
|
||||||
|
padding-left: 20px;
|
||||||
|
padding-right: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
label, input {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.confirmation-modal__container,
|
.confirmation-modal__container,
|
||||||
.mute-modal__container,
|
.mute-modal__container,
|
||||||
.report-modal__target {
|
.report-modal__target {
|
||||||
|
|
Loading…
Reference in New Issue