shlink-web-client/src/servers/DeleteServerModal.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-08-12 09:45:48 +03:00
import PropTypes from 'prop-types';
2018-07-20 23:14:17 +03:00
import React from 'react';
import { connect } from 'react-redux';
2018-08-12 09:45:48 +03:00
import { withRouter } from 'react-router-dom';
2018-07-20 23:14:17 +03:00
import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
2018-08-12 09:45:48 +03:00
import { compose } from 'redux';
2018-07-20 23:14:17 +03:00
import { deleteServer } from './reducers/server';
2018-08-14 21:28:46 +03:00
import { serverType } from './prop-types';
2018-07-20 23:14:17 +03:00
2018-08-12 09:45:48 +03:00
export const DeleteServerModal = ({ server, toggle, isOpen, deleteServer, history }) => {
2018-07-20 23:14:17 +03:00
const closeModal = () => {
deleteServer(server);
toggle();
history.push('/');
};
return (
<Modal isOpen={isOpen} toggle={toggle} centered={true}>
2018-07-20 23:30:54 +03:00
<ModalHeader toggle={toggle}><span className="text-danger">Delete server</span></ModalHeader>
<ModalBody>
<p>Are you sure you want to delete server <b>{server ? server.name : ''}</b>?</p>
2018-08-12 09:45:48 +03:00
<p>
No data will be deleted, only the access to that server will be removed from this host.
You can create it again at any moment.
</p>
2018-07-20 23:30:54 +03:00
</ModalBody>
2018-07-20 23:14:17 +03:00
<ModalFooter>
<button className="btn btn-link" onClick={toggle}>Cancel</button>
<button className="btn btn-danger" onClick={() => closeModal()}>Delete</button>
</ModalFooter>
</Modal>
);
};
2018-08-12 09:45:48 +03:00
DeleteServerModal.propTypes = {
toggle: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
2018-08-14 21:28:46 +03:00
server: serverType,
2018-08-12 09:45:48 +03:00
};
export default compose(
withRouter,
connect(null, { deleteServer })
)(DeleteServerModal);