mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
import React, {Component, PropTypes} from 'react'
|
|
import DebouncingInput from './base/DebouncingInput';
|
|
import Dropdown from './base/Dropdown';
|
|
import {METHODS} from '../constants/global';
|
|
|
|
class UrlInput extends Component {
|
|
shouldComponentUpdate (nextProps) {
|
|
return this.props.request !== nextProps.request;
|
|
}
|
|
|
|
render () {
|
|
const {sendRequest, onUrlChange, onMethodChange, request} = this.props;
|
|
return (
|
|
<div className="grid wide form-control form-control--left form-control--right bg-super-light">
|
|
<Dropdown>
|
|
<button className="btn txt-lg">
|
|
{request.method} <i className="fa fa-caret-down"></i>
|
|
</button>
|
|
<ul>
|
|
{METHODS.map((method) => (
|
|
<li key={method}>
|
|
<button onClick={onMethodChange.bind(null, method)}>
|
|
{method}
|
|
</button>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</Dropdown>
|
|
<form className="tall grid__cell" onSubmit={e => {e.preventDefault(); sendRequest(request)}}>
|
|
<DebouncingInput
|
|
type="text"
|
|
className="txt-lg"
|
|
placeholder="http://echo.insomnia.rest/status/200"
|
|
value={request.url}
|
|
debounceMillis={1000}
|
|
onChange={onUrlChange}/>
|
|
</form>
|
|
<button className="btn" onClick={sendRequest.bind(null, request)}>
|
|
<i className="fa fa-repeat txt-xl"></i>
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
UrlInput.propTypes = {
|
|
sendRequest: PropTypes.func.isRequired,
|
|
onUrlChange: PropTypes.func.isRequired,
|
|
onMethodChange: PropTypes.func.isRequired,
|
|
request: PropTypes.shape({
|
|
url: PropTypes.string.isRequired,
|
|
method: PropTypes.string.isRequired
|
|
}).isRequired
|
|
};
|
|
|
|
export default UrlInput;
|