insomnia/app/components/RequestUrlBar.js
Gregory Schier 04a75cc841 Small fixes
2016-03-22 22:58:16 -07:00

51 lines
1.5 KiB
JavaScript

import React, {Component, PropTypes} from 'react'
import Input from './base/DebouncingInput';
import Dropdown from './base/Dropdown';
import {METHODS} from '../constants/global';
class UrlInput extends Component {
shouldComponentUpdate(nextProps) {
return this.props.request.method !== nextProps.request.method;
}
render () {
const {onUrlChange, onMethodChange, request} = this.props;
return (
<div className="grid form-control form-control--left form-control--right">
<Dropdown>
<button className="btn txt-lg">
{request.method}&nbsp;&nbsp;<i className="fa fa-caret-down"></i>
</button>
<ul className="bg-super-light">
{METHODS.map((method) => (
<li key={method}>
<button onClick={onMethodChange.bind(null, method)}>
{method}
</button>
</li>
))}
</ul>
</Dropdown>
<Input type="text"
className="txt-lg"
placeholder="https://google.com"
initialValue={request.url}
onChange={onUrlChange}/>
<button className="btn">
<i className="fa fa-repeat txt-xl"></i>
</button>
</div>
)
}
}
UrlInput.propTypes = {
onUrlChange: PropTypes.func.isRequired,
onMethodChange: PropTypes.func.isRequired,
request: PropTypes.shape({
url: PropTypes.string.isRequired,
method: PropTypes.string.isRequired
}).isRequired
};
export default UrlInput;