mirror of
https://github.com/apache/superset.git
synced 2026-04-11 04:15:33 +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
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import cx from 'classnames';
|
|
import TooltipWrapper from './TooltipWrapper';
|
|
|
|
const propTypes = {
|
|
sliceId: PropTypes.number.isRequired,
|
|
actions: PropTypes.object.isRequired,
|
|
isStarred: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
export default class FaveStar extends React.Component {
|
|
componentDidMount() {
|
|
this.props.actions.fetchFaveStar(this.props.sliceId);
|
|
}
|
|
|
|
onClick(e) {
|
|
e.preventDefault();
|
|
this.props.actions.saveFaveStar(this.props.sliceId, this.props.isStarred);
|
|
}
|
|
|
|
render() {
|
|
const iconClassNames = cx('fa', {
|
|
'fa-star': this.props.isStarred,
|
|
'fa-star-o': !this.props.isStarred,
|
|
});
|
|
|
|
return (
|
|
<TooltipWrapper
|
|
label="fave-unfave"
|
|
tooltip="Click to favorite/unfavorite"
|
|
>
|
|
<a
|
|
href="#"
|
|
onClick={this.onClick.bind(this)}
|
|
className="fave-unfave-icon"
|
|
>
|
|
<i className={iconClassNames} />
|
|
</a>
|
|
</TooltipWrapper>
|
|
);
|
|
}
|
|
}
|
|
|
|
FaveStar.propTypes = propTypes;
|