about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/ui
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-03-26 17:34:02 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-26 17:44:00 +0100
commit9e80b34a95c39d0a1a944713f0f4d6cc5e8b8c43 (patch)
tree9952f2e08780455dc1af0febe4b374f5b8a60e2e /app/javascript/flavours/glitch/features/ui
parentfae53e1a39209726d74b5ac93c863f98d4e73f26 (diff)
[Glitch] Add a “Block & Report” button to the block confirmation dialog
Port 6df4a8296996181d56a22535b86830c0ab56086e to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/features/ui')
-rw-r--r--app/javascript/flavours/glitch/features/ui/components/confirmation_modal.js12
1 files changed, 11 insertions, 1 deletions
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 07281f818..970df30b6 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,8 @@ export default class ConfirmationModal extends React.PureComponent {
     confirm: PropTypes.string.isRequired,
     onClose: PropTypes.func.isRequired,
     onConfirm: PropTypes.func.isRequired,
+    secondary: PropTypes.string,
+    onSecondary: PropTypes.func,
     onDoNotAsk: PropTypes.func,
     intl: PropTypes.object.isRequired,
   };
@@ -27,6 +29,11 @@ export default class ConfirmationModal extends React.PureComponent {
     }
   }
 
+  handleSecondary = () => {
+    this.props.onClose();
+    this.props.onSecondary();
+  }
+
   handleCancel = () => {
     this.props.onClose();
   }
@@ -40,7 +47,7 @@ export default class ConfirmationModal extends React.PureComponent {
   }
 
   render () {
-    const { message, confirm, onDoNotAsk } = this.props;
+    const { message, confirm, secondary, onDoNotAsk } = this.props;
 
     return (
       <div className='modal-root__modal confirmation-modal'>
@@ -61,6 +68,9 @@ export default class ConfirmationModal extends React.PureComponent {
             <Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
               <FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
             </Button>
+            {secondary !== undefined && (
+              <Button text={secondary} onClick={this.handleSecondary} className='confirmation-modal__secondary-button' />
+            )}
             <Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
           </div>
         </div>