forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[explore-v2] add fave star and edit button to chart header (apache#1623)
* add fave star to chart title * add TooltipWrapper, and css for icons * fix linting
- Loading branch information
Alanna Scott
authored
Nov 17, 2016
1 parent
267fd5b
commit 506b781
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { Tooltip, OverlayTrigger } from 'react-bootstrap'; | ||
import { slugify } from '../modules/utils'; | ||
|
||
const propTypes = { | ||
label: PropTypes.string.isRequired, | ||
tooltip: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, | ||
placement: PropTypes.string, | ||
}; | ||
|
||
const defaultProps = { | ||
placement: 'top', | ||
}; | ||
|
||
export default function TooltipWrapper({ label, tooltip, children, placement }) { | ||
return ( | ||
<OverlayTrigger | ||
placement={placement} | ||
overlay={<Tooltip id={`${slugify(label)}-tooltip`}>{tooltip}</Tooltip>} | ||
> | ||
{children} | ||
</OverlayTrigger> | ||
); | ||
} | ||
|
||
TooltipWrapper.propTypes = propTypes; | ||
TooltipWrapper.defaultProps = defaultProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters