From 056a8a8ee48e79993f42a910b86d70523aa9f0ae Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 27 Nov 2018 17:31:50 +0100 Subject: [PATCH] Allow disabling media confirmation from the confirmation dialog itself --- .../glitch/features/composer/index.js | 3 ++ .../ui/components/confirmation_modal.js | 30 +++++++++++++++---- .../glitch/styles/components/modal.scss | 12 ++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js index a8f5a5c3cde..eb0bc867b4c 100644 --- a/app/javascript/flavours/glitch/features/composer/index.js +++ b/app/javascript/flavours/glitch/features/composer/index.js @@ -30,6 +30,7 @@ import { closeModal, openModal, } from 'flavours/glitch/actions/modal'; +import { changeLocalSetting } from 'flavours/glitch/actions/local_settings'; // Components. import ComposerOptions from './options'; @@ -165,6 +166,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ message: intl.formatMessage(messages.missingDescriptionMessage), confirm: intl.formatMessage(messages.missingDescriptionConfirm), onConfirm: () => dispatch(submitCompose(routerHistory)), + onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_missing_media_description'], false)), + onConfirm: () => dispatch(submitCompose()), })); }, onSubmit(routerHistory) { diff --git a/app/javascript/flavours/glitch/features/ui/components/confirmation_modal.js b/app/javascript/flavours/glitch/features/ui/components/confirmation_modal.js index d4d1e587ee2..07281f818a1 100644 --- a/app/javascript/flavours/glitch/features/ui/components/confirmation_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/confirmation_modal.js @@ -11,6 +11,7 @@ export default class ConfirmationModal extends React.PureComponent { confirm: PropTypes.string.isRequired, onClose: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired, + onDoNotAsk: PropTypes.func, intl: PropTypes.object.isRequired, }; @@ -21,6 +22,9 @@ export default class ConfirmationModal extends React.PureComponent { handleClick = () => { this.props.onClose(); this.props.onConfirm(); + if (this.props.onDoNotAsk && this.doNotAskCheckbox.checked) { + this.props.onDoNotAsk(); + } } handleCancel = () => { @@ -31,8 +35,12 @@ export default class ConfirmationModal extends React.PureComponent { this.button = c; } + setDoNotAskRef = (c) => { + this.doNotAskCheckbox = c; + } + render () { - const { message, confirm } = this.props; + const { message, confirm, onDoNotAsk } = this.props; return (
@@ -40,11 +48,21 @@ export default class ConfirmationModal extends React.PureComponent { {message}
-
- - +
); diff --git a/app/javascript/flavours/glitch/styles/components/modal.scss b/app/javascript/flavours/glitch/styles/components/modal.scss index 1bfedc3833e..dc26ca3b5ea 100644 --- a/app/javascript/flavours/glitch/styles/components/modal.scss +++ b/app/javascript/flavours/glitch/styles/components/modal.scss @@ -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, .mute-modal__container, .report-modal__target {