mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
27 lines
580 B
JavaScript
27 lines
580 B
JavaScript
import React, {Component, PropTypes} from 'react';
|
|
import {shell} from 'electron';
|
|
|
|
class Link extends Component {
|
|
render () {
|
|
const {button, href, children, ...other} = this.props;
|
|
return button ? (
|
|
<button onClick={() => shell.openExternal(href)} {...other}>
|
|
{children}
|
|
</button>
|
|
) :(
|
|
<a href={href} onClick={e => {e.preventDefault(); shell.openExternal(href)}} {...other}>
|
|
{children}
|
|
</a>
|
|
)
|
|
}
|
|
}
|
|
|
|
Link.propTypes = {
|
|
href: PropTypes.string.isRequired,
|
|
|
|
// Optional
|
|
button: PropTypes.bool
|
|
};
|
|
|
|
export default Link;
|