insomnia/app/components/RequestUrlBar.js
Gregory Schier 9e84bc4387 Workspaces, Cookies, and More! (#31)
* Start on workspace dropdown and upgrade fontawesome

* WorkspaceDropdown start and Elm components!

* Lots of CSS shit

* Refactor some db stuff and move filter out of sidebar

* Adjust dropdown css

* Handle duplicate header names, and stuff

* Shitty cookies tab

* fixed cookie table a bit

* Modal refactor

* Starteed cookie modal design

* Better cookie storage and filter cookie modal

* Cookie editor round 1

* Fix kve cursor jumping and form encoding templating

* New cookies now show up in filter

* Checkpoint

* Stuff and fix environments css

* Added manage cookies button to cookie pane

* Fix accidental sidebar item drag on sidebar resize

* Environments modal is looking pretty good now

* Pretty much done environments nad cookies

* Some changes

* Fixed codemirror in modals

* Fixed some things

* Add basic proxy support

* Updated shortcuts

* Code snippet generation

* Some style

* bug fix

* Code export now gets cookies for correct domain
2016-08-15 10:04:36 -07:00

82 lines
2.3 KiB
JavaScript

import React, {Component, PropTypes} from 'react';
import classnames from 'classnames';
import Dropdown from './base/Dropdown';
import MethodTag from './tags/MethodTag';
import {METHODS} from '../lib/constants';
import Mousetrap from '../lib/mousetrap';
import {trackEvent} from '../lib/analytics';
import {DEBOUNCE_MILLIS} from '../lib/constants';
class RequestUrlBar extends Component {
_handleFormSubmit (e) {
e.preventDefault();
this.props.sendRequest();
}
_handleUrlChange (url) {
clearTimeout(this._timeout);
this._timeout = setTimeout(() => {
this.props.onUrlChange(url);
}, DEBOUNCE_MILLIS);
}
componentDidMount () {
Mousetrap.bindGlobal('mod+l', () => {this.input.focus(); this.input.select()});
}
render () {
const {onMethodChange, url, method} = this.props;
// TODO: Implement proper error checking here
const hasError = !url;
return (
<div className={classnames({'urlbar': true, 'urlbar--error': hasError})}>
<Dropdown>
<button>
<div className="tall">
<span>{method}</span>
<i className="fa fa-caret-down"/>
</div>
</button>
<ul>
{METHODS.map(method => (
<li key={method}>
<button onClick={e => {
onMethodChange(method);
trackEvent('Changed Method', {method});
}}>
<MethodTag method={method} fullNames={true}/>
</button>
</li>
))}
</ul>
</Dropdown>
<form onSubmit={this._handleFormSubmit.bind(this)}>
<div className="form-control">
<input
ref={n => this.input = n}
type="text"
placeholder="https://api.myproduct.com/v1/users"
defaultValue={url}
onChange={e => this._handleUrlChange(e.target.value)}/>
</div>
<button>Send</button>
</form>
</div>
);
}
}
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;