Files
superset2/superset/assets/javascripts/components/FaveStar.jsx
Alanna Scott 506b781f3a [explore-v2] add fave star and edit button to chart header (#1623)
* add fave star to chart title

* add TooltipWrapper, and css for icons

* fix linting
2016-11-17 10:53:44 -08:00

45 lines
1.0 KiB
JavaScript

import React, { PropTypes } from 'react';
import cx from 'classnames';
import TooltipWrapper from './TooltipWrapper';
const propTypes = {
sliceId: PropTypes.string.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;