2017-02-28 21:32:23 +00:00
|
|
|
import React, {PropTypes, PureComponent} from 'react';
|
2016-11-27 21:42:38 +00:00
|
|
|
import {Dropdown, DropdownButton, DropdownItem} from '../base/dropdown';
|
|
|
|
import * as constants from '../../../common/constants';
|
|
|
|
|
2017-02-28 21:32:23 +00:00
|
|
|
class MethodDropdown extends PureComponent {
|
2016-11-27 21:42:38 +00:00
|
|
|
render () {
|
|
|
|
const {method, onChange, right, ...extraProps} = this.props;
|
|
|
|
return (
|
|
|
|
<Dropdown className="method-dropdown" right={right}>
|
|
|
|
<DropdownButton type="button" {...extraProps}>
|
|
|
|
{method} <i className="fa fa-caret-down"/>
|
|
|
|
</DropdownButton>
|
|
|
|
{constants.HTTP_METHODS.map(method => (
|
|
|
|
<DropdownItem key={method}
|
|
|
|
className={`http-method-${method}`}
|
|
|
|
onClick={onChange}
|
|
|
|
value={method}>
|
|
|
|
{method}
|
|
|
|
</DropdownItem>
|
|
|
|
))}
|
|
|
|
</Dropdown>
|
2017-03-03 20:09:08 +00:00
|
|
|
);
|
2016-11-27 21:42:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodDropdown.propTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
2017-03-03 20:09:08 +00:00
|
|
|
method: PropTypes.string.isRequired
|
2016-11-27 21:42:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default MethodDropdown;
|