mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
Create Chart component for all chart fetching and rendering, and apply redux architecture in dashboard view.
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import cx from 'classnames';
|
|
import TooltipWrapper from './TooltipWrapper';
|
|
import { t } from '../locales';
|
|
|
|
const propTypes = {
|
|
itemId: PropTypes.number.isRequired,
|
|
fetchFaveStar: PropTypes.func,
|
|
saveFaveStar: PropTypes.func,
|
|
isStarred: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
export default class FaveStar extends React.Component {
|
|
componentDidMount() {
|
|
this.props.fetchFaveStar(this.props.itemId);
|
|
}
|
|
|
|
onClick(e) {
|
|
e.preventDefault();
|
|
this.props.saveFaveStar(this.props.itemId, 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={t('Click to favorite/unfavorite')}
|
|
>
|
|
<a
|
|
href="#"
|
|
onClick={this.onClick.bind(this)}
|
|
className="fave-unfave-icon"
|
|
>
|
|
<i className={iconClassNames} />
|
|
</a>
|
|
</TooltipWrapper>
|
|
);
|
|
}
|
|
}
|
|
|
|
FaveStar.propTypes = propTypes;
|