mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
31 lines
682 B
JavaScript
31 lines
682 B
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import {shell} from 'electron';
|
|
|
|
class Button extends Component {
|
|
_handleClick = e => {
|
|
const {onClick, onDisabledClick, disabled} = this.props;
|
|
const fn = disabled ? onDisabledClick : onClick;
|
|
|
|
if (this.props.hasOwnProperty('value')) {
|
|
fn && fn(this.props.value, e);
|
|
} else {
|
|
fn && fn(e);
|
|
}
|
|
};
|
|
|
|
render () {
|
|
const {children, value, ...props} = this.props;
|
|
return (
|
|
<button {...props} onClick={this._handleClick}>{children}</button>
|
|
)
|
|
}
|
|
}
|
|
|
|
Button.propTypes = {
|
|
value: PropTypes.any,
|
|
onDisabledClick: PropTypes.func,
|
|
onClick: PropTypes.func,
|
|
};
|
|
|
|
export default Button;
|