2016-09-29 15:00:45 -07:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
|
|
|
import IconButton from './icon_button';
|
2016-10-09 13:19:15 -07:00
|
|
|
import DropdownMenu from './dropdown_menu';
|
2016-09-29 15:00:45 -07:00
|
|
|
|
|
|
|
const StatusActionBar = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
status: ImmutablePropTypes.map.isRequired,
|
|
|
|
onReply: React.PropTypes.func,
|
|
|
|
onFavourite: React.PropTypes.func,
|
|
|
|
onReblog: React.PropTypes.func,
|
2016-10-24 08:11:02 -07:00
|
|
|
onDelete: React.PropTypes.func,
|
|
|
|
onMention: React.PropTypes.func
|
2016-09-29 15:00:45 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
handleReplyClick () {
|
|
|
|
this.props.onReply(this.props.status);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleFavouriteClick () {
|
|
|
|
this.props.onFavourite(this.props.status);
|
|
|
|
},
|
|
|
|
|
|
|
|
handleReblogClick () {
|
|
|
|
this.props.onReblog(this.props.status);
|
|
|
|
},
|
|
|
|
|
2016-10-09 13:19:15 -07:00
|
|
|
handleDeleteClick () {
|
2016-09-29 15:00:45 -07:00
|
|
|
this.props.onDelete(this.props.status);
|
|
|
|
},
|
|
|
|
|
2016-10-24 08:11:02 -07:00
|
|
|
handleMentionClick () {
|
|
|
|
this.props.onMention(this.props.status.get('account'));
|
|
|
|
},
|
|
|
|
|
2016-09-29 15:00:45 -07:00
|
|
|
render () {
|
|
|
|
const { status, me } = this.props;
|
2016-10-09 13:19:15 -07:00
|
|
|
let menu = [];
|
2016-09-29 15:00:45 -07:00
|
|
|
|
|
|
|
if (status.getIn(['account', 'id']) === me) {
|
2016-10-09 13:19:15 -07:00
|
|
|
menu.push({ text: 'Delete', action: this.handleDeleteClick });
|
2016-10-24 08:11:02 -07:00
|
|
|
} else {
|
|
|
|
menu.push({ text: 'Mention', action: this.handleMentionClick });
|
2016-09-29 15:00:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ marginTop: '10px', overflow: 'hidden' }}>
|
|
|
|
<div style={{ float: 'left', marginRight: '18px'}}><IconButton title='Reply' icon='reply' onClick={this.handleReplyClick} /></div>
|
|
|
|
<div style={{ float: 'left', marginRight: '18px'}}><IconButton active={status.get('reblogged')} title='Reblog' icon='retweet' onClick={this.handleReblogClick} /></div>
|
2016-11-09 16:32:32 -08:00
|
|
|
<div style={{ float: 'left', marginRight: '18px'}}><IconButton active={status.get('favourited')} title='Favourite' icon='star' onClick={this.handleFavouriteClick} activeStyle={{ color: '#ca8f04' }} /></div>
|
2016-09-29 15:00:45 -07:00
|
|
|
|
|
|
|
<div onClick={e => e.stopPropagation()} style={{ width: '18px', height: '18px', float: 'left' }}>
|
2016-10-09 13:19:15 -07:00
|
|
|
<DropdownMenu items={menu} icon='ellipsis-h' size={18} />
|
2016-09-29 15:00:45 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
export default StatusActionBar;
|