This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/assets/javascripts/components/components/status_action_bar.jsx

64 lines
2.0 KiB
React
Raw Normal View History

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,
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);
},
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 });
} 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>
<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;