mirror of
https://github.com/apache/superset.git
synced 2026-04-09 19:35:21 +00:00
* Fixing PropTypes warning message React recently started warning on the upcoming deprecation of React.PropTypes, the new approach is to use the `prop-types` npm package instead. * Fixing the tests
42 lines
985 B
JavaScript
42 lines
985 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Button as BootstrapButton, Tooltip, OverlayTrigger } from 'react-bootstrap';
|
|
import { slugify } from '../modules/utils';
|
|
|
|
const propTypes = {
|
|
tooltip: PropTypes.node,
|
|
placement: PropTypes.string,
|
|
};
|
|
const defaultProps = {
|
|
bsSize: 'sm',
|
|
placement: 'top',
|
|
};
|
|
|
|
export default function Button(props) {
|
|
const buttonProps = Object.assign({}, props);
|
|
const tooltip = props.tooltip;
|
|
const placement = props.placement;
|
|
delete buttonProps.tooltip;
|
|
delete buttonProps.placement;
|
|
|
|
let button = (
|
|
<BootstrapButton {...buttonProps} >
|
|
{props.children}
|
|
</BootstrapButton>
|
|
);
|
|
if (props.tooltip) {
|
|
button = (
|
|
<OverlayTrigger
|
|
placement={placement}
|
|
overlay={<Tooltip id={`${slugify(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
|
|
>
|
|
{button}
|
|
</OverlayTrigger>
|
|
);
|
|
}
|
|
return button;
|
|
}
|
|
|
|
Button.propTypes = propTypes;
|
|
Button.defaultProps = defaultProps;
|