Files
superset2/superset/assets/javascripts/SqlLab/components/TabStatusIcon.jsx
2018-04-02 14:59:08 -07:00

43 lines
901 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
onClose: PropTypes.func.isRequired,
tabState: PropTypes.string.isRequired,
};
class TabStatusIcon extends React.Component {
constructor(props) {
super(props);
this.onMouseOver = this.onMouseOver.bind(this);
this.onMouseOut = this.onMouseOut.bind(this);
this.state = { isHovered: false };
}
onMouseOver() {
this.setState({ isHovered: true });
}
onMouseOut() {
this.setState({ isHovered: false });
}
render() {
return (
<span
onMouseOver={this.onMouseOver}
onMouseOut={this.onMouseOut}
onClick={this.props.onClose}
>
<div className={'circle ' + this.props.tabState}>
{this.state.isHovered ? '×' : null}
</div>
</span>
);
}
}
TabStatusIcon.propTypes = propTypes;
export default TabStatusIcon;