diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-09-21 10:35:45 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-09-21 10:44:23 +0800 |
commit | 431beb943675f2e9b7b5e5ce9c7f55d45f10905f (patch) | |
tree | f4517b6f8737d3a2d5393b18cdca463e3a1bbfd0 /ui/app/components/modal | |
parent | 2cfdc95eebc3e0a878017090f22e5136cff709a6 (diff) | |
download | tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar.gz tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar.bz2 tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar.lz tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar.xz tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.tar.zst tangerine-wallet-browser-431beb943675f2e9b7b5e5ce9c7f55d45f10905f.zip |
Fix multiplyCurrencies. Add onClose prop for Modal component. Remove hideModal from modal components.
Diffstat (limited to 'ui/app/components/modal')
-rw-r--r-- | ui/app/components/modal/modal.component.js | 20 | ||||
-rw-r--r-- | ui/app/components/modal/tests/modal.component.test.js | 16 |
2 files changed, 4 insertions, 32 deletions
diff --git a/ui/app/components/modal/modal.component.js b/ui/app/components/modal/modal.component.js index f9d8c5867..2a75b559b 100644 --- a/ui/app/components/modal/modal.component.js +++ b/ui/app/components/modal/modal.component.js @@ -7,6 +7,7 @@ export default class Modal extends PureComponent { children: PropTypes.node, // Header text headerText: PropTypes.string, + onClose: PropTypes.func, // Submit button (right button) onSubmit: PropTypes.func, submitType: PropTypes.string, @@ -22,26 +23,11 @@ export default class Modal extends PureComponent { cancelType: 'default', } - handleClose = () => { - const { onCancel, onSubmit } = this.props - - /** - * The close button should be used to dismiss the modal, without performing any actions, which - * is typically what props.onCancel does. However, if props.onCancel is undefined, that should - * mean that the modal is a simple notification modal and props.onSubmit can be used to dismiss - * it. - */ - if (onCancel && typeof onCancel === 'function') { - onCancel() - } else { - onSubmit() - } - } - render () { const { children, headerText, + onClose, onSubmit, submitType, submitText, @@ -60,7 +46,7 @@ export default class Modal extends PureComponent { </div> <div className="modal-container__header-close" - onClick={this.handleClose} + onClick={onClose} /> </div> ) diff --git a/ui/app/components/modal/tests/modal.component.test.js b/ui/app/components/modal/tests/modal.component.test.js index 31457751f..8cce1a808 100644 --- a/ui/app/components/modal/tests/modal.component.test.js +++ b/ui/app/components/modal/tests/modal.component.test.js @@ -88,6 +88,7 @@ describe('Modal Component', () => { onSubmit={handleSubmit} submitText="Submit" headerText="My Header" + onClose={handleCancel} /> ) @@ -99,19 +100,4 @@ describe('Modal Component', () => { assert.equal(handleCancel.callCount, 1) assert.equal(handleSubmit.callCount, 0) }) - - it('should call onSubmit when onCancel is undefined and the header close button is clicked', () => { - const handleSubmit = sinon.spy() - const wrapper = shallow( - <Modal - onSubmit={handleSubmit} - submitText="Submit" - headerText="My Header" - /> - ) - - assert.equal(handleSubmit.callCount, 0) - wrapper.find('.modal-container__header-close').simulate('click') - assert.equal(handleSubmit.callCount, 1) - }) }) |