Added Confirmation Modal for Delete Network (#6776)
parent
9fd8a3d46e
commit
687984a938
@ -0,0 +1,43 @@ |
|||||||
|
import React, { PureComponent } from 'react' |
||||||
|
import PropTypes from 'prop-types' |
||||||
|
import Modal, { ModalContent } from '../../modal' |
||||||
|
|
||||||
|
export default class ConfirmDeleteNetwork extends PureComponent { |
||||||
|
static propTypes = { |
||||||
|
hideModal: PropTypes.func.isRequired, |
||||||
|
delRpcTarget: PropTypes.func.isRequired, |
||||||
|
onConfirm: PropTypes.func.isRequired, |
||||||
|
target: PropTypes.string.isRequired, |
||||||
|
} |
||||||
|
|
||||||
|
static contextTypes = { |
||||||
|
t: PropTypes.func, |
||||||
|
} |
||||||
|
|
||||||
|
handleDelete = () => { |
||||||
|
this.props.delRpcTarget(this.props.target) |
||||||
|
.then(() => { |
||||||
|
this.props.onConfirm() |
||||||
|
this.props.hideModal() |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
const { t } = this.context |
||||||
|
|
||||||
|
return ( |
||||||
|
<Modal |
||||||
|
onSubmit={this.handleDelete} |
||||||
|
onCancel={() => this.props.hideModal()} |
||||||
|
submitText={t('delete')} |
||||||
|
cancelText={t('cancel')} |
||||||
|
submitType="danger" |
||||||
|
> |
||||||
|
<ModalContent |
||||||
|
title={t('deleteNetwork')} |
||||||
|
description={t('deleteNetworkDescription')} |
||||||
|
/> |
||||||
|
</Modal> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
import { connect } from 'react-redux' |
||||||
|
import { compose } from 'recompose' |
||||||
|
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props' |
||||||
|
import ConfirmDeleteNetwork from './confirm-delete-network.component' |
||||||
|
import { delRpcTarget } from '../../../../store/actions' |
||||||
|
|
||||||
|
const mapDispatchToProps = dispatch => { |
||||||
|
return { |
||||||
|
delRpcTarget: (target) => dispatch(delRpcTarget(target)), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default compose( |
||||||
|
withModalProps, |
||||||
|
connect(null, mapDispatchToProps) |
||||||
|
)(ConfirmDeleteNetwork) |
@ -0,0 +1 @@ |
|||||||
|
export { default } from './confirm-delete-network.container' |
Loading…
Reference in new issue