2016-03-20 23:20:00 +00:00
|
|
|
import React, {Component, PropTypes} from 'react'
|
2016-04-29 08:15:37 +00:00
|
|
|
import Input from './base/Input';
|
2016-03-22 05:01:58 +00:00
|
|
|
import Dropdown from './base/Dropdown';
|
2016-04-23 06:08:52 +00:00
|
|
|
import {METHODS} from '../lib/constants';
|
2016-03-20 23:20:00 +00:00
|
|
|
|
|
|
|
class UrlInput extends Component {
|
2016-04-26 07:29:24 +00:00
|
|
|
_handleFormSubmit (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.props.sendRequest();
|
|
|
|
}
|
|
|
|
|
2016-03-20 23:20:00 +00:00
|
|
|
render () {
|
2016-04-26 07:29:24 +00:00
|
|
|
const {onUrlChange, onMethodChange, uniquenessKey, url, method} = this.props;
|
2016-03-20 23:20:00 +00:00
|
|
|
return (
|
2016-05-01 19:56:30 +00:00
|
|
|
<div className="urlbar">
|
|
|
|
<Dropdown>
|
|
|
|
<button>
|
2016-04-26 07:29:24 +00:00
|
|
|
{method}
|
|
|
|
<i className="fa fa-caret-down"></i>
|
2016-03-21 05:47:49 +00:00
|
|
|
</button>
|
2016-04-04 07:15:30 +00:00
|
|
|
<ul>
|
2016-04-26 07:29:24 +00:00
|
|
|
{METHODS.map(m => (
|
|
|
|
<li key={m}>
|
|
|
|
<button onClick={onMethodChange.bind(null, m)}>
|
|
|
|
{m}
|
2016-03-21 05:47:49 +00:00
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
</Dropdown>
|
2016-05-01 19:56:30 +00:00
|
|
|
<form className="form-control"
|
2016-04-26 07:29:24 +00:00
|
|
|
onSubmit={this._handleFormSubmit.bind(this)}>
|
2016-04-29 08:15:37 +00:00
|
|
|
<Input
|
2016-04-09 21:08:55 +00:00
|
|
|
type="text"
|
|
|
|
placeholder="http://echo.insomnia.rest/status/200"
|
2016-04-26 07:29:24 +00:00
|
|
|
value={url}
|
|
|
|
uniquenessKey={uniquenessKey}
|
2016-04-09 21:08:55 +00:00
|
|
|
onChange={onUrlChange}/>
|
|
|
|
</form>
|
2016-05-01 19:56:30 +00:00
|
|
|
<button onClick={this._handleFormSubmit.bind(this)}>
|
2016-04-18 04:39:15 +00:00
|
|
|
Send
|
2016-05-01 19:56:30 +00:00
|
|
|
</button>
|
2016-03-20 23:20:00 +00:00
|
|
|
</div>
|
2016-04-17 22:46:17 +00:00
|
|
|
);
|
2016-03-20 23:20:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UrlInput.propTypes = {
|
2016-04-09 21:08:55 +00:00
|
|
|
sendRequest: PropTypes.func.isRequired,
|
2016-03-20 23:20:00 +00:00
|
|
|
onUrlChange: PropTypes.func.isRequired,
|
2016-03-20 23:27:46 +00:00
|
|
|
onMethodChange: PropTypes.func.isRequired,
|
2016-04-26 07:29:24 +00:00
|
|
|
uniquenessKey: PropTypes.string.isRequired,
|
|
|
|
url: PropTypes.string.isRequired,
|
|
|
|
method: PropTypes.string.isRequired
|
2016-03-20 23:20:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default UrlInput;
|