insomnia/app/components/modals/CurlExportModal.js

61 lines
1.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
2016-07-14 22:48:56 +00:00
import ReactDOM from 'react-dom'
import ModalComponent from '../lib/ModalComponent';
import Modal from '../base/Modal';
import ModalBody from '../base/ModalBody';
import ModalHeader from '../base/ModalHeader';
import ModalFooter from '../base/ModalFooter';
import {exportCurl} from '../../lib/export/curl';
2016-07-14 22:48:56 +00:00
class CurlExportModal extends ModalComponent {
constructor (props) {
super(props);
this.state = {cmd: ''};
}
show (request) {
super.show();
exportCurl(request._id).then(cmd => {
this.setState({cmd});
});
}
componentDidUpdate () {
ReactDOM.findDOMNode(this.refs.textarea).select();
}
render () {
const {cmd} = this.state;
return (
<Modal ref="modal" tall={true} {...this.props}>
<ModalHeader>Export Request as Curl</ModalHeader>
<ModalBody className="grid pad">
<div className="form-control form-control--outlined no-margin tall">
2016-07-14 22:48:56 +00:00
<textarea
ref="textarea"
className="no-resize monospace tall"
onChange={e => {}}
value={cmd}
/>
</div>
</ModalBody>
<ModalFooter>
2016-07-19 20:21:33 +00:00
<div className="pull-right">
<button className="btn" onClick={e => this.hide()}>Done</button>
</div>
<div className="pad faint italic txt-sm tall">
* copy/paste this command into a Unix terminal
</div>
2016-07-14 22:48:56 +00:00
</ModalFooter>
</Modal>
);
}
}
CurlExportModal.propTypes = {};
export default CurlExportModal;