import React, {Component, PropTypes} from 'react'; import classnames from 'classnames'; import Input from './base/Input'; import Dropdown from './base/Dropdown'; import MethodTag from './MethodTag'; import {METHODS} from '../lib/constants'; import Mousetrap from '../lib/mousetrap'; class RequestUrlBar extends Component { _handleFormSubmit (e) { e.preventDefault(); this.props.sendRequest(); } _handleUrlChange (url) { this.props.onUrlChange(url); } focus () { this.refs.input.focus(); console.log('-- Focus URL Bar --'); } componentDidMount () { Mousetrap.bindGlobal('mod+l', this.focus.bind(this)); } componentWillUnmount () { Mousetrap.unbind('mod+l'); } render () { const {onMethodChange, url, method} = this.props; // TODO: Implement proper error checking here const hasError = !url; return (
    {METHODS.map(m => (
  • ))}
this._handleUrlChange(url)}/>
); } } RequestUrlBar.propTypes = { sendRequest: PropTypes.func.isRequired, onUrlChange: PropTypes.func.isRequired, onMethodChange: PropTypes.func.isRequired, url: PropTypes.string.isRequired, method: PropTypes.string.isRequired }; export default RequestUrlBar;